Module: ActionDoc

Defined in:
lib/actiondoc.rb,
lib/actiondoc/version.rb,
lib/actiondoc/generator.rb

Overview

The ActionDoc CLI

Defined Under Namespace

Classes: Error, Generator, TemplateModel

Constant Summary collapse

VERSION =
'0.4.0'
INPUTS_SECTION_ERB =

For ERB binding

<<~ERB
  ## Inputs

  <% inputs_table.each do |row| -%>
  <%= "|" + row.join("|") + "|" %>
  <% end -%>
ERB
NO_INPUTS =
<<~NO_INPUTS

  ## Inputs

  This action has no inputs.
NO_INPUTS

Class Method Summary collapse

Class Method Details

.build_optparser(options) ⇒ Object

Builds and returns the OptionParser



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/actiondoc.rb', line 36

def build_optparser(options)
  OptionParser.new do |opts|
    opts.banner = <<~BANNER
      Usage:

          actiondoc [options] [ACTION_YAML_FILE]

      Where:
          [ACTION_YAML_FILE]               is the path to the action.yaml file. Defaults to "action.yaml"
                                           in the current directory.

      Options:
    BANNER

    opts.on('--template=TEMPLATE_FILENAME', '-t=TEMPLATE_FILENAME', 'The template to use') do |template_filename|
      options[:template] = template_filename
    end
    opts.on('--version', 'Show the version') do
      puts "actiondoc v#{ActionDoc::VERSION}"
      exit
    end
    opts.on('--help', 'Display this help text') do
      puts opts
      exit
    end
  end
end

.parse_optionsObject

Builds the OptionParser and parses the options



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/actiondoc.rb', line 20

def parse_options
  options = {}

  optparser = build_optparser(options)
  begin
    optparser.parse!
  rescue OptionParser::InvalidOption, OptionParser::MissingArgument
    puts $ERROR_INFO.to_s
    puts optparser
    exit
  end

  options
end

.runObject

The main CLI entrypoint



13
14
15
16
17
# File 'lib/actiondoc.rb', line 13

def run
  options = parse_options

  ActionDoc::Generator.new(ARGV, options).run
end