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.
344 345 346 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 344 def initialize(doc) @doc = doc end |
Instance Attribute Details
#doc ⇒ Object
The Doc object the Markup class should dump
342 343 344 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 342 def doc @doc end |
Instance Method Details
#dump_markup(items) ⇒ Object
376 377 378 379 380 381 382 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 376 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
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 349 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
368 369 370 371 372 373 374 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 368 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 |