Module: Docscribe::CLI::Generate

Defined in:
lib/docscribe/cli/generate.rb

Overview

Generator for TagPlugin and CollectorPlugin boilerplate.

Usage:

docscribe generate tag MyPlugin
docscribe generate collector MyPlugin
docscribe generate tag MyPlugin --output lib/docscribe_plugins
docscribe generate tag MyPlugin --stdout

Constant Summary collapse

PLUGIN_TYPES =
%w[tag collector].freeze
NEXT_STEPS_TEMPLATE =
<<~TEXT
  Next steps:
    1. Open %<path>s and implement the plugin logic.
       %<hint>s

  2. Register the plugin in your docscribe_plugins.rb:

         require_relative '%<require_path>s'
         Docscribe::Plugin::Registry.register(%<base_name>s.new)

  3. Add the file to docscribe.yml:

         plugins:
           require:
             - ./docscribe_plugins
TEXT

Class Method Summary collapse

Class Method Details

.run(argv) ⇒ Integer

Run the ‘generate` subcommand.

Parameters:

  • argv (Array<String>)

Returns:

  • (Integer)

    exit code

Raises:

  • (OptionParser::InvalidOption)


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/docscribe/cli/generate.rb', line 40

def run(argv)
  opts, parser = parse_generate_options(argv)
  return 0 if opts[:help]

  plugin_type, class_name = extract_generate_args(argv)
  result = validate_generate_args(plugin_type, class_name, parser)
  return result if result

  content = render(plugin_type, class_name)
  dispatch_output(content, plugin_type, class_name, opts)
end