Class: CTioga2::Commands::Documentation::Man
- Inherits:
-
Object
- Object
- CTioga2::Commands::Documentation::Man
- Includes:
- Log
- Defined in:
- lib/ctioga2/commands/doc/man.rb
Overview
Converts help texts found in the Command descriptions into a manual page that can be further edited and updated using this module.
Constant Summary collapse
- RoffCommentRE =
/\.\s*\\"/
Instance Attribute Summary collapse
-
#doc ⇒ Object
The Doc object Help2Man should be working on.
Instance Method Summary collapse
-
#initialize(doc) ⇒ Man
constructor
A new instance of Man.
-
#write_manual_page(version, input, out = STDOUT) ⇒ Object
Writes a manual page to the given io stream, using version as the target version (the one ending up in the headers).
Methods included from Log
context, debug, error, fatal, #format_exception, #identify, info, init_logger, log_to, logger, set_level, #spawn, warn
Constructor Details
#initialize(doc) ⇒ Man
Returns a new instance of Man.
35 36 37 |
# File 'lib/ctioga2/commands/doc/man.rb', line 35 def initialize(doc) @doc = doc end |
Instance Attribute Details
#doc ⇒ Object
The Doc object Help2Man should be working on.
33 34 35 |
# File 'lib/ctioga2/commands/doc/man.rb', line 33 def doc @doc end |
Instance Method Details
#write_manual_page(version, input, out = STDOUT) ⇒ Object
Writes a manual page to the given io stream, using version as the target version (the one ending up in the headers).
NO… We should input a manual page, and spit out replacement texts.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ctioga2/commands/doc/man.rb', line 47 def write_manual_page(version, input, out = STDOUT) passed_header = false if input.is_a? String filename = input input = File::open(input) elsif input.respond_to? :path filename = input.path else filename = "unkown" end @cmds, @groups = @doc.documented_commands @cmd_exclude = {} @group_exclude = {} while line = input.gets case line when /^#{RoffCommentRE}\s*write-header\s*$/ out.puts header_string(version, filename) passed_header = true when /^#{RoffCommentRE}\s*write-commands\s*$/ write_commands(out) # \todo add a write-backends command.... when /^#{RoffCommentRE}\s*write-group:\s*(.*)\s*$/ id = $1 if @groups[id] write_group(out, g) else warn { "Unkown group: #{id}" } end when /^#{RoffCommentRE}\s*write-types\s*$/ write_types(out) else if passed_header out.puts line end end end out.close input.close end |