Class: CTioga2::Commands::Documentation::Doc
- Inherits:
-
Object
- Object
- CTioga2::Commands::Documentation::Doc
- Defined in:
- lib/ctioga2/commands/doc/doc.rb
Overview
The base class for all documentation.
Instance Attribute Summary collapse
-
#backends ⇒ Object
The hash containing all the backends, as returned by Data::Backends::Backend::list_backends.
-
#commands ⇒ Object
The hash containing all the commands, as returned by Interpreter::commands.
-
#groups ⇒ Object
The hash containing all the groups, as returned by Interpreter::commands.
-
#ignore_blacklisted ⇒ Object
Wether or not to ignore blacklisted commands.
-
#types ⇒ Object
The hash containing all the types, as returned by Interpreter::commands.
Instance Method Summary collapse
-
#display_command_line_help(options) ⇒ Object
Display command-line help.
-
#documented_commands ⇒ Object
Returns a [ cmds, groups ] hash containing the list of commands, and the groups to be documented.
-
#initialize ⇒ Doc
constructor
Create a Doc object caring about the current state of registered commands and such.
Constructor Details
#initialize ⇒ Doc
Create a Doc object caring about the current state of registered commands and such.
51 52 53 54 55 56 57 58 59 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 51 def initialize @commands = Interpreter::commands @groups = Interpreter::groups @types = Interpreter::types @backends = Data::Backends::Backend::list_backends @ignore_blacklisted = ! (ENV.key?("CT2_DEV") && ! ENV["CT2_DEV"].empty?) end |
Instance Attribute Details
#backends ⇒ Object
The hash containing all the backends, as returned by Data::Backends::Backend::list_backends
44 45 46 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 44 def backends @backends end |
#commands ⇒ Object
The hash containing all the commands, as returned by Interpreter::commands.
32 33 34 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 32 def commands @commands end |
#groups ⇒ Object
The hash containing all the groups, as returned by Interpreter::commands.
36 37 38 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 36 def groups @groups end |
#ignore_blacklisted ⇒ Object
Wether or not to ignore blacklisted commands
47 48 49 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 47 def ignore_blacklisted @ignore_blacklisted end |
#types ⇒ Object
The hash containing all the types, as returned by Interpreter::commands.
40 41 42 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 40 def types @types end |
Instance Method Details
#display_command_line_help(options) ⇒ Object
Display command-line help.
86 87 88 89 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 86 def display_command_line_help() CommandLineHelp.new(). (*self.documented_commands) end |
#documented_commands ⇒ Object
Returns a [ cmds, groups ] hash containing the list of commands, and the groups to be documented.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ctioga2/commands/doc/doc.rb', line 63 def documented_commands cmds = group_commands groups = cmds.keys.sort do |a,b| if ! a 1 elsif ! b -1 else if a.priority == b.priority a.name <=> b.name else a.priority <=> b.priority end end end if @ignore_blacklisted groups.delete_if {|g| g && g.blacklisted } end return [cmds, groups] end |