Class: CTioga2::Commands::Documentation::Markup
- Inherits:
-
Object
- Object
- CTioga2::Commands::Documentation::Markup
- Defined in:
- lib/ctioga2/commands/doc/markup.rb
Overview
A class dumping markup information to standard output
Instance Attribute Summary collapse
-
#doc ⇒ Object
The Doc object the Markup class should dump.
Instance Method Summary collapse
- #dump_markup(items) ⇒ Object
-
#initialize(doc) ⇒ Markup
constructor
A new instance of Markup.
-
#write_commands(out = STDOUT) ⇒ Object
Dumps the markup of all commands.
-
#write_types(out = STDOUT) ⇒ Object
Dumps the markup of all types.
Constructor Details
#initialize(doc) ⇒ Markup
Returns a new instance of Markup.
315 316 317 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 315 def initialize(doc) @doc = doc end |
Instance Attribute Details
#doc ⇒ Object
The Doc object the Markup class should dump
313 314 315 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 313 def doc @doc end |
Instance Method Details
#dump_markup(items) ⇒ Object
347 348 349 350 351 352 353 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 347 def dump_markup(items) if items.is_a? String mup = MarkedUpText.new(@doc, items) return dump_markup(mup.elements) end return items.map { |x| "-> #{x.dump_string}\n"} end |
#write_commands(out = STDOUT) ⇒ Object
Dumps the markup of all commands
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 320 def write_commands(out = STDOUT) cmds, groups = @doc.documented_commands for g in groups out.puts "Group markup: #{g.name}" out.puts dump_markup(g.description) commands = cmds[g].sort {|a,b| a.name <=> b.name } for cmd in commands out.puts "Command: #{cmd.name}" out.puts dump_markup(cmd.long_description) end end end |
#write_types(out = STDOUT) ⇒ Object
Dumps the markup of all types
339 340 341 342 343 344 345 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 339 def write_types(out = STDOUT) types = @doc.types.sort.map { |d| d[1]} for t in types out.puts "Type: #{t.name}" out.puts dump_markup(t.description) end end |