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.
350 351 352 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 350 def initialize(doc) @doc = doc end |
Instance Attribute Details
#doc ⇒ Object
The Doc object the Markup class should dump
348 349 350 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 348 def doc @doc end |
Instance Method Details
#dump_markup(items) ⇒ Object
382 383 384 385 386 387 388 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 382 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
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 355 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
374 375 376 377 378 379 380 |
# File 'lib/ctioga2/commands/doc/markup.rb', line 374 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 |