Class: CTioga2::Commands::Documentation::Markup

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/commands/doc/markup.rb

Overview

A class dumping markup information to standard output

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#docObject

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