Class: CliMarkdown::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/cli_markdown/index.rb

Instance Method Summary collapse

Constructor Details

#initialize(cli_class, cli_name) ⇒ Index

Returns a new instance of Index.



3
4
5
6
# File 'lib/cli_markdown/index.rb', line 3

def initialize(cli_class, cli_name)
  @cli_class = cli_class
  @cli_name = cli_name
end

Instance Method Details

#command_listObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cli_markdown/index.rb', line 12

def command_list
  commands = @cli_class.commands.reject { |command_name, command| command.hidden? }
  commands.keys.sort.map.each do |command_name|
    page = Page.new(
        cli_class: @cli_class,
        cli_name: @cli_name,
        command_name: command_name,
      )
    link = page.path.sub("docs/", "")
    # Example: [lono cfn]({% link _reference/lono-cfn.md %})
    "* [#{@cli_name} #{command_name}]({% link #{link} %})"
  end.join("\n")
end

#docObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/cli_markdown/index.rb', line 26

def doc
  <<-EOL
---
title: CLI Reference
---
{% include reference.md %}

#{command_list}
EOL
end

#pathObject



8
9
10
# File 'lib/cli_markdown/index.rb', line 8

def path
  "docs/reference.md"
end