ctioga2 0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +339 -0
- data/Changelog +6 -0
- data/bin/ctioga2 +26 -0
- data/lib/ctioga2/commands/arguments.rb +58 -0
- data/lib/ctioga2/commands/commands.rb +258 -0
- data/lib/ctioga2/commands/doc/doc.rb +118 -0
- data/lib/ctioga2/commands/doc/documentation-commands.rb +119 -0
- data/lib/ctioga2/commands/doc/help.rb +95 -0
- data/lib/ctioga2/commands/doc/html.rb +230 -0
- data/lib/ctioga2/commands/doc/introspection.rb +211 -0
- data/lib/ctioga2/commands/doc/man.rb +279 -0
- data/lib/ctioga2/commands/doc/markup.rb +359 -0
- data/lib/ctioga2/commands/general-commands.rb +119 -0
- data/lib/ctioga2/commands/general-types.rb +118 -0
- data/lib/ctioga2/commands/groups.rb +73 -0
- data/lib/ctioga2/commands/interpreter.rb +257 -0
- data/lib/ctioga2/commands/parsers/command-line.rb +187 -0
- data/lib/ctioga2/commands/parsers/file.rb +186 -0
- data/lib/ctioga2/commands/strings.rb +303 -0
- data/lib/ctioga2/commands/type.rb +100 -0
- data/lib/ctioga2/commands/variables.rb +101 -0
- data/lib/ctioga2/data/backends/backend.rb +260 -0
- data/lib/ctioga2/data/backends/backends.rb +39 -0
- data/lib/ctioga2/data/backends/backends/gnuplot.rb +140 -0
- data/lib/ctioga2/data/backends/backends/math.rb +121 -0
- data/lib/ctioga2/data/backends/backends/text.rb +335 -0
- data/lib/ctioga2/data/backends/description.rb +405 -0
- data/lib/ctioga2/data/backends/factory.rb +73 -0
- data/lib/ctioga2/data/backends/parameter.rb +109 -0
- data/lib/ctioga2/data/datacolumn.rb +245 -0
- data/lib/ctioga2/data/dataset.rb +233 -0
- data/lib/ctioga2/data/filters.rb +131 -0
- data/lib/ctioga2/data/merge.rb +43 -0
- data/lib/ctioga2/data/point.rb +72 -0
- data/lib/ctioga2/data/stack.rb +294 -0
- data/lib/ctioga2/graphics/coordinates.rb +73 -0
- data/lib/ctioga2/graphics/elements.rb +111 -0
- data/lib/ctioga2/graphics/elements/containers.rb +111 -0
- data/lib/ctioga2/graphics/elements/curve2d.rb +155 -0
- data/lib/ctioga2/graphics/elements/element.rb +90 -0
- data/lib/ctioga2/graphics/elements/primitive.rb +256 -0
- data/lib/ctioga2/graphics/elements/subplot.rb +140 -0
- data/lib/ctioga2/graphics/generator.rb +68 -0
- data/lib/ctioga2/graphics/legends.rb +108 -0
- data/lib/ctioga2/graphics/legends/area.rb +199 -0
- data/lib/ctioga2/graphics/legends/items.rb +183 -0
- data/lib/ctioga2/graphics/legends/provider.rb +58 -0
- data/lib/ctioga2/graphics/legends/storage.rb +65 -0
- data/lib/ctioga2/graphics/root.rb +209 -0
- data/lib/ctioga2/graphics/styles.rb +30 -0
- data/lib/ctioga2/graphics/styles/axes.rb +247 -0
- data/lib/ctioga2/graphics/styles/background.rb +122 -0
- data/lib/ctioga2/graphics/styles/base.rb +115 -0
- data/lib/ctioga2/graphics/styles/carrays.rb +53 -0
- data/lib/ctioga2/graphics/styles/curve.rb +101 -0
- data/lib/ctioga2/graphics/styles/drawable.rb +87 -0
- data/lib/ctioga2/graphics/styles/factory.rb +351 -0
- data/lib/ctioga2/graphics/styles/legend.rb +63 -0
- data/lib/ctioga2/graphics/styles/plot.rb +410 -0
- data/lib/ctioga2/graphics/styles/sets.rb +64 -0
- data/lib/ctioga2/graphics/styles/texts.rb +277 -0
- data/lib/ctioga2/graphics/subplot-commands.rb +141 -0
- data/lib/ctioga2/graphics/types.rb +188 -0
- data/lib/ctioga2/graphics/types/bijection.rb +79 -0
- data/lib/ctioga2/graphics/types/boundaries.rb +170 -0
- data/lib/ctioga2/graphics/types/boxes.rb +157 -0
- data/lib/ctioga2/graphics/types/dimensions.rb +157 -0
- data/lib/ctioga2/graphics/types/point.rb +247 -0
- data/lib/ctioga2/log.rb +97 -0
- data/lib/ctioga2/metabuilder/type.rb +316 -0
- data/lib/ctioga2/metabuilder/types.rb +39 -0
- data/lib/ctioga2/metabuilder/types/coordinates.rb +124 -0
- data/lib/ctioga2/metabuilder/types/dates.rb +43 -0
- data/lib/ctioga2/metabuilder/types/lists.rb +188 -0
- data/lib/ctioga2/metabuilder/types/numbers.rb +97 -0
- data/lib/ctioga2/metabuilder/types/strings.rb +93 -0
- data/lib/ctioga2/metabuilder/types/styles.rb +178 -0
- data/lib/ctioga2/plotmaker.rb +677 -0
- data/lib/ctioga2/postprocess.rb +115 -0
- data/lib/ctioga2/utils.rb +120 -0
- data/setup.rb +1586 -0
- metadata +144 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# introspection.rb: get informations about what is known to ctioga2
|
|
2
|
+
# copyright (c) 2009 by Vincent Fourmond
|
|
3
|
+
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details (in the COPYING file).
|
|
13
|
+
|
|
14
|
+
require 'ctioga2/utils'
|
|
15
|
+
require 'ctioga2/commands/commands'
|
|
16
|
+
|
|
17
|
+
module CTioga2
|
|
18
|
+
|
|
19
|
+
Version::register_svn_info('$Revision: 36 $', '$Date: 2009-05-04 21:23:15 +0200 (Mon, 04 May 2009) $')
|
|
20
|
+
|
|
21
|
+
module Commands
|
|
22
|
+
|
|
23
|
+
# The base of the 'self-documentation' of CTioga2
|
|
24
|
+
module Documentation
|
|
25
|
+
|
|
26
|
+
# This class provides facilities to display information
|
|
27
|
+
class Introspection
|
|
28
|
+
|
|
29
|
+
# Display all known commands, along with their definition place
|
|
30
|
+
def list_commands(raw = false)
|
|
31
|
+
puts "Known commands:" unless raw
|
|
32
|
+
cmds = Interpreter::commands
|
|
33
|
+
names = cmds.keys.sort
|
|
34
|
+
if raw
|
|
35
|
+
puts names
|
|
36
|
+
else
|
|
37
|
+
max = names.inject(0) {|m,x| [m,x.size].max}
|
|
38
|
+
max2 = names.inject(0) {|m,x| [m,cmds[x].long_option.size].max}
|
|
39
|
+
for n in names
|
|
40
|
+
f,l = cmds[n].context
|
|
41
|
+
puts "\t%-#{max}s\t--%-#{max2}s\t(#{f}: #{l})" %
|
|
42
|
+
[n, cmds[n].long_option ]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# List known groups
|
|
48
|
+
def list_groups(raw = false)
|
|
49
|
+
puts "Known groups:" unless raw
|
|
50
|
+
groups = Interpreter::groups
|
|
51
|
+
names = groups.keys.sort
|
|
52
|
+
if raw
|
|
53
|
+
puts names
|
|
54
|
+
else
|
|
55
|
+
for n in names
|
|
56
|
+
f,l = groups[n].context
|
|
57
|
+
puts "\t#{n}\t(#{f}: #{l})"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# List known types
|
|
63
|
+
def list_types(raw = false)
|
|
64
|
+
puts "Known types:" unless raw
|
|
65
|
+
types = Interpreter::types
|
|
66
|
+
names = types.keys.sort
|
|
67
|
+
if raw
|
|
68
|
+
puts names
|
|
69
|
+
else
|
|
70
|
+
for n in names
|
|
71
|
+
f,l = types[n].context
|
|
72
|
+
puts "\t#{n}\t(#{f}: #{l})"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Lauches an editor to edit the given command:
|
|
78
|
+
def edit_command(cmd)
|
|
79
|
+
cmd = Interpreter::command(cmd)
|
|
80
|
+
if cmd
|
|
81
|
+
edit_file(*cmd.context)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Lauches an editor to edit the given command:
|
|
86
|
+
def edit_group(group)
|
|
87
|
+
group = Interpreter::group(group)
|
|
88
|
+
if group
|
|
89
|
+
edit_file(*group.context)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Lauches an editor to edit the given command:
|
|
94
|
+
def edit_type(type)
|
|
95
|
+
type = Interpreter::type(type)
|
|
96
|
+
if type
|
|
97
|
+
edit_file(*type.context)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
protected
|
|
103
|
+
|
|
104
|
+
# Launches an editor to edit the given file at the given place.
|
|
105
|
+
def edit_file(file, line)
|
|
106
|
+
editor = ENV['EDITOR'] || 'emacs'
|
|
107
|
+
if ENV['CT2_DEV_HOME']
|
|
108
|
+
file = "#{ENV['CT2_DEV_HOME']}/#{file}"
|
|
109
|
+
end
|
|
110
|
+
system("#{editor} +#{line} #{file} &")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
IntrospectionGroup =
|
|
116
|
+
CmdGroup.new('introspection', "Introspection",
|
|
117
|
+
"Displays information about the internals of ctioga2",
|
|
118
|
+
100, true)
|
|
119
|
+
|
|
120
|
+
RawOption = {'raw' => CmdArg.new('boolean')}
|
|
121
|
+
|
|
122
|
+
ListCommandsCmd =
|
|
123
|
+
Cmd.new('list-commands', nil, '--list-commands',
|
|
124
|
+
[], RawOption) do |p, opts|
|
|
125
|
+
Introspection.new.list_commands(opts['raw'])
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
ListCommandsCmd.describe("List known commands",
|
|
129
|
+
<<EOH, IntrospectionGroup)
|
|
130
|
+
List all commands known to ctioga2
|
|
131
|
+
EOH
|
|
132
|
+
|
|
133
|
+
ListGroupsCmd =
|
|
134
|
+
Cmd.new('list-groups', nil, '--list-groups',
|
|
135
|
+
[], RawOption) do |p, opts|
|
|
136
|
+
Introspection.new.list_groups(opts['raw'])
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
ListGroupsCmd.describe("List known groups",
|
|
140
|
+
<<EOH, IntrospectionGroup)
|
|
141
|
+
List all command groups known to ctioga2
|
|
142
|
+
EOH
|
|
143
|
+
|
|
144
|
+
ListTypesCmd =
|
|
145
|
+
Cmd.new('list-types', nil, '--list-types',
|
|
146
|
+
[], RawOption) do |p, opts|
|
|
147
|
+
Introspection.new.list_types(opts['raw'])
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
ListTypesCmd.describe("List known types",
|
|
151
|
+
<<EOH, IntrospectionGroup)
|
|
152
|
+
List all types known to ctioga2
|
|
153
|
+
EOH
|
|
154
|
+
|
|
155
|
+
EditCommandCmd =
|
|
156
|
+
Cmd.new('edit-command', nil, '--edit-command',
|
|
157
|
+
[ CmdArg.new('text')]) do |plotmaker, cmd|
|
|
158
|
+
Introspection.new.edit_command(cmd)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
EditCommandCmd.describe("Edit the command",
|
|
162
|
+
<<EOH, IntrospectionGroup)
|
|
163
|
+
Edit the given command in an editor. It will only work from the
|
|
164
|
+
top directory of a ctioga2 source tree.
|
|
165
|
+
EOH
|
|
166
|
+
|
|
167
|
+
EditGroupCmd =
|
|
168
|
+
Cmd.new('edit-group', nil, '--edit-group',
|
|
169
|
+
[ CmdArg.new('text')]) do |plotmaker, cmd|
|
|
170
|
+
Introspection.new.edit_group(cmd)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
EditGroupCmd.describe("Edit the group",
|
|
174
|
+
<<EOH, IntrospectionGroup)
|
|
175
|
+
Edit the given group in an editor. It will only work from the
|
|
176
|
+
top directory of a ctioga2 source tree.
|
|
177
|
+
EOH
|
|
178
|
+
|
|
179
|
+
EditTypeCmd =
|
|
180
|
+
Cmd.new('edit-type', nil, '--edit-type',
|
|
181
|
+
[ CmdArg.new('text')]) do |plotmaker, cmd|
|
|
182
|
+
Introspection.new.edit_type(cmd)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
EditTypeCmd.describe("Edit the type",
|
|
186
|
+
<<EOH, IntrospectionGroup)
|
|
187
|
+
Edit the given type in an editor. It will only work from the
|
|
188
|
+
top directory of a ctioga2 source tree.
|
|
189
|
+
EOH
|
|
190
|
+
|
|
191
|
+
VersionRawCmd =
|
|
192
|
+
Cmd.new('version-raw', nil, '--version-raw',
|
|
193
|
+
[ ]) do |plotmaker|
|
|
194
|
+
print Version::version
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
VersionRawCmd.describe("Raw version",
|
|
198
|
+
<<EOH, IntrospectionGroup)
|
|
199
|
+
Prints the raw version number, without any other decoration and
|
|
200
|
+
newline.
|
|
201
|
+
EOH
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
end
|
|
211
|
+
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# man.rb: conversion of the internal help into a hand-modifiable manual page.
|
|
2
|
+
# copyright (c) 2009 by Vincent Fourmond
|
|
3
|
+
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details (in the COPYING file).
|
|
13
|
+
|
|
14
|
+
require 'ctioga2/utils'
|
|
15
|
+
require 'ctioga2/log'
|
|
16
|
+
require 'ctioga2/commands/commands'
|
|
17
|
+
require 'ctioga2/commands/parsers/command-line'
|
|
18
|
+
|
|
19
|
+
module CTioga2
|
|
20
|
+
|
|
21
|
+
Version::register_svn_info('$Revision: 40 $', '$Date: 2009-05-08 00:45:47 +0200 (Fri, 08 May 2009) $')
|
|
22
|
+
|
|
23
|
+
module Commands
|
|
24
|
+
|
|
25
|
+
module Documentation
|
|
26
|
+
|
|
27
|
+
# Converts help texts found in the Command descriptions into a
|
|
28
|
+
# manual page that can be further edited and *updated* using this
|
|
29
|
+
# module.
|
|
30
|
+
class Man
|
|
31
|
+
|
|
32
|
+
include Log
|
|
33
|
+
|
|
34
|
+
# The Doc object Help2Man should be working on.
|
|
35
|
+
attr_accessor :doc
|
|
36
|
+
|
|
37
|
+
def initialize(doc)
|
|
38
|
+
@doc = doc
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
RoffCommentRE = /\.\s*\\"/
|
|
42
|
+
|
|
43
|
+
# Writes a manual page to the given _io_ stream, using _version_
|
|
44
|
+
# as the target version (the one ending up in the headers).
|
|
45
|
+
#
|
|
46
|
+
# NO... We should *input* a manual page, and spit out
|
|
47
|
+
# replacement texts.
|
|
48
|
+
def write_manual_page(version, input, out = STDOUT)
|
|
49
|
+
passed_header = false
|
|
50
|
+
if input.is_a? String
|
|
51
|
+
filename = input
|
|
52
|
+
input = File::open(input)
|
|
53
|
+
elsif input.respond_to? :path
|
|
54
|
+
filename = input.path
|
|
55
|
+
else
|
|
56
|
+
filename = "unkown"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
@cmds, @groups = @doc.documented_commands
|
|
60
|
+
@cmd_exclude = {}
|
|
61
|
+
@group_exclude = {}
|
|
62
|
+
|
|
63
|
+
while line = input.gets
|
|
64
|
+
case line
|
|
65
|
+
when /^#{RoffCommentRE}\s*write-header\s*$/
|
|
66
|
+
out.puts header_string(version, filename)
|
|
67
|
+
passed_header = true
|
|
68
|
+
when /^#{RoffCommentRE}\s*write-commands\s*$/
|
|
69
|
+
write_commands(out)
|
|
70
|
+
when /^#{RoffCommentRE}\s*write-group:\s*(.*)\s*$/
|
|
71
|
+
id = $1
|
|
72
|
+
if @groups[id]
|
|
73
|
+
write_group(out, g)
|
|
74
|
+
else
|
|
75
|
+
warn "Unkown group: #{id}"
|
|
76
|
+
end
|
|
77
|
+
when /^#{RoffCommentRE}\s*write-types\s*$/
|
|
78
|
+
write_types(out)
|
|
79
|
+
else
|
|
80
|
+
if passed_header
|
|
81
|
+
out.puts line
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
out.close
|
|
86
|
+
input.close
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
protected
|
|
90
|
+
|
|
91
|
+
ItemizeLabel = '\fB*\fR'
|
|
92
|
+
ItemizeLabelSize = 2
|
|
93
|
+
ItemizeIndent = 2
|
|
94
|
+
ManIndent = 8
|
|
95
|
+
|
|
96
|
+
# Takes up an array of MarkupItem objects and returns its
|
|
97
|
+
# equivalent in roff format. Alternativelely, it can take a
|
|
98
|
+
# String and feed it to MarkedUpText.
|
|
99
|
+
#
|
|
100
|
+
# TODO: make sure things are escaped the way they should be.
|
|
101
|
+
#
|
|
102
|
+
# if _inside_cmds_ is true, additional indentation is added
|
|
103
|
+
# for the lists, so that is looks neat in the end.
|
|
104
|
+
#
|
|
105
|
+
# TODO: try to be more clever about spaces in the target
|
|
106
|
+
# file. (does not matter too much for the output of man)
|
|
107
|
+
def markup_to_man(items, inside_cmds = true)
|
|
108
|
+
if items.is_a? String
|
|
109
|
+
mup = MarkedUpText.new(@doc, items)
|
|
110
|
+
return markup_to_man(mup.elements, inside_cmds)
|
|
111
|
+
end
|
|
112
|
+
str = ""
|
|
113
|
+
for it in items
|
|
114
|
+
case it
|
|
115
|
+
when MarkedUpText::MarkupText
|
|
116
|
+
str << it.to_s
|
|
117
|
+
when MarkedUpText::MarkupLink
|
|
118
|
+
str << "\\fI#{it.to_s}\\fR"
|
|
119
|
+
when MarkedUpText::MarkupItemize
|
|
120
|
+
indent = ItemizeIndent
|
|
121
|
+
if inside_cmds
|
|
122
|
+
indent += ManIndent
|
|
123
|
+
end
|
|
124
|
+
str << "\n.RS #{indent}"
|
|
125
|
+
str << "\n.IP \"#{ItemizeLabel}\" #{ItemizeLabelSize}\n"
|
|
126
|
+
str << it.items.map {
|
|
127
|
+
|x| markup_to_man(x)
|
|
128
|
+
}.join("\n.IP \"#{ItemizeLabel}\" #{ItemizeLabelSize}\n")
|
|
129
|
+
str << "\n.RE\n\n"
|
|
130
|
+
# We restore the indentation afterwards.
|
|
131
|
+
if inside_cmds
|
|
132
|
+
str << ".IP \"\" #{ManIndent}\n"
|
|
133
|
+
end
|
|
134
|
+
when MarkedUpText::MarkupVerbatim
|
|
135
|
+
str << it.text.gsub(/^/, ' ')
|
|
136
|
+
when MarkedUpText::MarkupParagraph
|
|
137
|
+
str << "#{markup_to_man(it.elements)}\n\n"
|
|
138
|
+
else
|
|
139
|
+
raise "Markup #{it.class} isn't implemented yet for man"
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
return str
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Writes out all commands to _out_.
|
|
146
|
+
def write_commands(out)
|
|
147
|
+
for group in @groups
|
|
148
|
+
next if @group_exclude[group]
|
|
149
|
+
write_group(out, group)
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Writes out a single _group_
|
|
154
|
+
def write_group(out, group)
|
|
155
|
+
write_group_name(out, group)
|
|
156
|
+
write_group_description(out, group)
|
|
157
|
+
write_group_commands(out, group)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Writes the name of a _group_
|
|
161
|
+
def write_group_name(out, group)
|
|
162
|
+
out.puts
|
|
163
|
+
out.puts ".SS #{group.name}"
|
|
164
|
+
out.puts
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Writes the description of a _group_.
|
|
168
|
+
def write_group_description(out, group)
|
|
169
|
+
out.puts
|
|
170
|
+
out.puts markup_to_man(group.description, false)
|
|
171
|
+
out.puts
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Writes the remaining commands of a group
|
|
175
|
+
def write_group_commands(out, group)
|
|
176
|
+
for cmd in @cmds[group].sort {|a,b|
|
|
177
|
+
a.long_option <=> b.long_option
|
|
178
|
+
}
|
|
179
|
+
next if @cmd_exclude[cmd]
|
|
180
|
+
out.puts
|
|
181
|
+
out.puts ".TP #{ManIndent}"
|
|
182
|
+
write_command(out, cmd)
|
|
183
|
+
end
|
|
184
|
+
# Now blacklist the group
|
|
185
|
+
@group_exclude[group] = true
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def write_command(out, cmd)
|
|
189
|
+
write_command_signature(out, cmd)
|
|
190
|
+
write_command_description(out, cmd)
|
|
191
|
+
out.puts ".br"
|
|
192
|
+
write_command_options(out, cmd)
|
|
193
|
+
out.puts ".br"
|
|
194
|
+
write_corresponding_command(out, cmd)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Writes a signature (ie the option specification) for the
|
|
198
|
+
# command
|
|
199
|
+
def write_command_signature(out, cmd)
|
|
200
|
+
short, long, dummy = cmd.option_strings
|
|
201
|
+
long, *args = long.split(/\s+/)
|
|
202
|
+
args = " \\fI#{args.join(' ')}\\fR"
|
|
203
|
+
out.puts ".B %s%s%s%s" % [ short, (short ? ", " : ""), long, args ]
|
|
204
|
+
# Blacklist commands whose signature we wrote.
|
|
205
|
+
@cmd_exclude[cmd] = true
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
# Returns the description for the command
|
|
210
|
+
def write_command_description(out, cmd)
|
|
211
|
+
mup = MarkedUpText.new(@doc, cmd.long_description)
|
|
212
|
+
out.puts markup_to_man(mup.elements)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Displays the optional arguments for the given command
|
|
216
|
+
def write_command_options(out, cmd)
|
|
217
|
+
if cmd.has_options?
|
|
218
|
+
# .map {|x| "/#{x}="} ??? Does not seem to help much
|
|
219
|
+
options = cmd.optional_arguments.keys.sort.join(' ')
|
|
220
|
+
out.puts ".B Optional arguments:\n.I #{options}"
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Displays the corresponding 'file' command
|
|
225
|
+
def write_corresponding_command(out, cmd)
|
|
226
|
+
arguments = cmd.arguments.map {|a| a.displayed_name}.join(',')
|
|
227
|
+
if cmd.has_options?
|
|
228
|
+
arguments += ",option=..."
|
|
229
|
+
end
|
|
230
|
+
out.puts ".B Corresponding command:\n.I #{cmd.name}(#{arguments})"
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Writes documentation about all the types known to ctioga.
|
|
234
|
+
def write_types(out)
|
|
235
|
+
first = true
|
|
236
|
+
for n, t in @doc.types.sort
|
|
237
|
+
write_type(out,t, first ? "8" : "")
|
|
238
|
+
first = false
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def write_type(out, type, indent = "")
|
|
243
|
+
out.puts ".TP #{indent}"
|
|
244
|
+
out.puts ".I #{type.name}"
|
|
245
|
+
out.puts "#{type.description}"
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Returns the header string
|
|
249
|
+
def header_string(version, file)
|
|
250
|
+
return ManualPageHeader % [ file,
|
|
251
|
+
CTioga2::Version::last_modified_date,
|
|
252
|
+
version ]
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
ManualPageHeader = <<'EOF'
|
|
256
|
+
.\" This is the manual page for ctioga2
|
|
257
|
+
.\"
|
|
258
|
+
.\" Copyright 2009 by Vincent Fourmond
|
|
259
|
+
.\"
|
|
260
|
+
.\" This file is generated from the ctioga2 code and from the file %s
|
|
261
|
+
.\"
|
|
262
|
+
.\" This program is free software; you can redistribute it and/or modify
|
|
263
|
+
.\" it under the terms of the GNU General Public License as published by
|
|
264
|
+
.\" the Free Software Foundation; either version 2 of the License, or
|
|
265
|
+
.\" (at your option) any later version.
|
|
266
|
+
.\"
|
|
267
|
+
.\" This program is distributed in the hope that it will be useful,
|
|
268
|
+
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
269
|
+
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
270
|
+
.\" GNU General Public License for more details (in the COPYING file).
|
|
271
|
+
.\"
|
|
272
|
+
.TH CTIOGA2 1 "%s" "Version %s" "Command-line interface for Tioga"
|
|
273
|
+
EOF
|
|
274
|
+
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
end
|
|
279
|
+
end
|