Class: Jets::Commands::Markdown::Creator
- Inherits:
-
Object
- Object
- Jets::Commands::Markdown::Creator
- Defined in:
- lib/jets/commands/markdown/creator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cli_classes ⇒ Object
- #create_all ⇒ Object
- #create_include_reference ⇒ Object
- #create_index ⇒ Object
- #create_page(page) ⇒ Object
Class Method Details
.clean ⇒ Object
10 11 12 13 |
# File 'lib/jets/commands/markdown/creator.rb', line 10 def self.clean FileUtils.rm_rf("docs/_reference") FileUtils.rm_f("docs/reference.md") end |
.create_all ⇒ Object
5 6 7 8 |
# File 'lib/jets/commands/markdown/creator.rb', line 5 def self.create_all clean new.create_all end |
Instance Method Details
#cli_classes ⇒ Object
15 16 17 18 19 20 |
# File 'lib/jets/commands/markdown/creator.rb', line 15 def cli_classes Jets::Commands::Base.namespaced_commands.map do |full_command| # IE of full_command: dynamodb:generate Jets::CLI.new([full_command]).lookup(full_command) end.uniq end |
#create_all ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jets/commands/markdown/creator.rb', line 22 def create_all create_index cli_classes.each do |cli_class| # cli_class examples: # Jets::Commands::Main # Jets::Commands::Db # Jets::Commands::Dynamodb::Migrate cli_class.commands.each do |command| command_name = command.first page = Page.new(cli_class: cli_class, command_name: command_name) create_page(page) end end end |
#create_include_reference ⇒ Object
53 54 55 56 |
# File 'lib/jets/commands/markdown/creator.rb', line 53 def create_include_reference path = "docs/_includes/reference.md" IO.write(path, "Generic tool description. Please edit #{path} with a description.") unless File.exist?(path) end |
#create_index ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/jets/commands/markdown/creator.rb', line 45 def create_index create_include_reference page = Index.new FileUtils.mkdir_p(File.dirname(page.path)) puts "Creating index: #{page.path}" IO.write(page.path, page.doc) end |
#create_page(page) ⇒ Object
39 40 41 42 43 |
# File 'lib/jets/commands/markdown/creator.rb', line 39 def create_page(page) puts "Creating page: #{page.path}..." FileUtils.mkdir_p(File.dirname(page.path)) IO.write(page.path, page.doc) end |