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.



315
316
317
# File 'lib/ctioga2/commands/doc/markup.rb', line 315

def initialize(doc)
  @doc = doc
end

Instance Attribute Details

#docObject

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