Class: GLI::Commands::Doc

Inherits:
GLI::Command show all
Defined in:
lib/gli/commands/doc.rb

Overview

Takes a DocListener which will be called with all of the meta-data and documentation about your app, so as to create documentation in whatever format you want

Defined Under Namespace

Classes: DocumentListener

Constant Summary collapse

FORMATS =
{
  'rdoc' => GLI::Commands::RdocDocumentListener
}

Constants inherited from GLI::Command

GLI::Command::PARENT

Instance Attribute Summary

Attributes included from GLI::CommandSupport

#parent

Attributes inherited from GLI::CommandLineToken

#aliases, #description, #long_description, #name

Instance Method Summary collapse

Methods inherited from GLI::Command

#action, #default_command, #default_desc, #example, #has_option?, name_as_string, #name_for_help

Methods included from GLI::CommandSupport

#arg_name, #arguments, #arguments_description, #arguments_options, #commands, #commands_declaration_order, #context_description, #default_description, #default_value, #desc, #examples, #execute, #flag, #flags, #get_default_command, #has_action?, #long_desc, #names, #skips_around, #skips_post, #skips_pre, #switch, #switches, #topmost_ancestor

Methods included from DSL

#arg, #arg_name, #clear_nexts, #command, #command_missing, #default_value, #desc, #flag, #flags_declaration_order, #long_desc, #switch, #switches_declaration_order

Methods inherited from GLI::CommandLineToken

#<=>, #names_and_aliases

Constructor Details

#initialize(app) ⇒ Doc

Create the Doc generator based on the GLI app passed in



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gli/commands/doc.rb', line 10

def initialize(app)
  super(:names       => "_doc",
        :description => "Generate documentation of your application's UI",
        :long_desc   => "Introspects your application's UI meta-data to generate documentation in a variety of formats.  This is intended to be extensible via the DocumentListener interface, so that you can provide your own documentation formats without them being a part of GLI",
        :skips_pre   => true, :skips_post => true, :skips_around => true, :hidden => true)

  @app = app
  @parent = @app
  @subcommand_option_handling_strategy = @app.subcommand_option_handling_strategy

  desc          'The format name of the documentation to generate or the class name to use to generate it'
  default_value 'rdoc'
  arg_name      'name_or_class'
  flag          :format

  action do |global_options,options,arguments|
    self.document(format_class(options[:format]).new(global_options,options,arguments,app))
  end
end

Instance Method Details

#document(document_listener) ⇒ Object

Generates documentation using the listener



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gli/commands/doc.rb', line 35

def document(document_listener)
  document_listener.beginning
  document_listener.program_desc(@app.program_desc) unless @app.program_desc.nil?
  document_listener.program_long_desc(@app.program_long_desc) unless @app.program_long_desc.nil?
  document_listener.version(@app.version_string)
  if any_options?(@app)
    document_listener.options 
  end
  document_flags_and_switches(document_listener,
                              @app.flags.values.sort(&by_name),
                              @app.switches.values.sort(&by_name))
  if any_options?(@app)
    document_listener.end_options 
  end
  document_listener.commands
  document_commands(document_listener,@app)
  document_listener.end_commands
  document_listener.ending
end

#nodocObject



30
31
32
# File 'lib/gli/commands/doc.rb', line 30

def nodoc
  true
end