rdoc 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- data/History.txt +13 -0
- data/Manifest.txt +61 -0
- data/README.txt +34 -0
- data/Rakefile +10 -0
- data/bin/rdoc +22 -0
- data/bin/ri +6 -0
- data/lib/rdoc.rb +277 -0
- data/lib/rdoc/code_objects.rb +776 -0
- data/lib/rdoc/diagram.rb +338 -0
- data/lib/rdoc/dot.rb +249 -0
- data/lib/rdoc/generator.rb +1048 -0
- data/lib/rdoc/generator/chm.rb +113 -0
- data/lib/rdoc/generator/chm/chm.rb +98 -0
- data/lib/rdoc/generator/html.rb +370 -0
- data/lib/rdoc/generator/html/hefss.rb +414 -0
- data/lib/rdoc/generator/html/html.rb +704 -0
- data/lib/rdoc/generator/html/kilmer.rb +418 -0
- data/lib/rdoc/generator/html/one_page_html.rb +121 -0
- data/lib/rdoc/generator/ri.rb +229 -0
- data/lib/rdoc/generator/xml.rb +120 -0
- data/lib/rdoc/generator/xml/rdf.rb +113 -0
- data/lib/rdoc/generator/xml/xml.rb +111 -0
- data/lib/rdoc/markup.rb +473 -0
- data/lib/rdoc/markup/attribute_manager.rb +274 -0
- data/lib/rdoc/markup/formatter.rb +14 -0
- data/lib/rdoc/markup/fragments.rb +337 -0
- data/lib/rdoc/markup/inline.rb +101 -0
- data/lib/rdoc/markup/lines.rb +152 -0
- data/lib/rdoc/markup/preprocess.rb +71 -0
- data/lib/rdoc/markup/to_flow.rb +185 -0
- data/lib/rdoc/markup/to_html.rb +353 -0
- data/lib/rdoc/markup/to_html_crossref.rb +86 -0
- data/lib/rdoc/markup/to_latex.rb +328 -0
- data/lib/rdoc/markup/to_test.rb +50 -0
- data/lib/rdoc/options.rb +616 -0
- data/lib/rdoc/parsers/parse_c.rb +775 -0
- data/lib/rdoc/parsers/parse_f95.rb +1841 -0
- data/lib/rdoc/parsers/parse_rb.rb +2584 -0
- data/lib/rdoc/parsers/parse_simple.rb +40 -0
- data/lib/rdoc/parsers/parserfactory.rb +99 -0
- data/lib/rdoc/rdoc.rb +277 -0
- data/lib/rdoc/ri.rb +4 -0
- data/lib/rdoc/ri/cache.rb +188 -0
- data/lib/rdoc/ri/descriptions.rb +150 -0
- data/lib/rdoc/ri/display.rb +274 -0
- data/lib/rdoc/ri/driver.rb +452 -0
- data/lib/rdoc/ri/formatter.rb +616 -0
- data/lib/rdoc/ri/paths.rb +102 -0
- data/lib/rdoc/ri/reader.rb +106 -0
- data/lib/rdoc/ri/util.rb +81 -0
- data/lib/rdoc/ri/writer.rb +68 -0
- data/lib/rdoc/stats.rb +25 -0
- data/lib/rdoc/template.rb +64 -0
- data/lib/rdoc/tokenstream.rb +33 -0
- data/test/test_rdoc_c_parser.rb +261 -0
- data/test/test_rdoc_markup.rb +613 -0
- data/test/test_rdoc_markup_attribute_manager.rb +224 -0
- data/test/test_rdoc_ri_attribute_formatter.rb +42 -0
- data/test/test_rdoc_ri_default_display.rb +295 -0
- data/test/test_rdoc_ri_formatter.rb +318 -0
- data/test/test_rdoc_ri_overstrike_formatter.rb +69 -0
- metadata +134 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rdoc/markup'
|
2
|
+
require 'rdoc/markup/formatter'
|
3
|
+
|
4
|
+
##
|
5
|
+
# This Markup outputter is used for testing purposes.
|
6
|
+
|
7
|
+
class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
8
|
+
|
9
|
+
def start_accepting
|
10
|
+
@res = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_accepting
|
14
|
+
@res
|
15
|
+
end
|
16
|
+
|
17
|
+
def accept_paragraph(am, fragment)
|
18
|
+
@res << fragment.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def accept_verbatim(am, fragment)
|
22
|
+
@res << fragment.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def accept_list_start(am, fragment)
|
26
|
+
@res << fragment.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def accept_list_end(am, fragment)
|
30
|
+
@res << fragment.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def accept_list_item(am, fragment)
|
34
|
+
@res << fragment.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
def accept_blank_line(am, fragment)
|
38
|
+
@res << fragment.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
def accept_heading(am, fragment)
|
42
|
+
@res << fragment.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def accept_rule(am, fragment)
|
46
|
+
@res << fragment.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
data/lib/rdoc/options.rb
ADDED
@@ -0,0 +1,616 @@
|
|
1
|
+
# We handle the parsing of options, and subsequently as a singleton
|
2
|
+
# object to be queried for option values
|
3
|
+
|
4
|
+
require "rdoc/ri/paths"
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
class RDoc::Options
|
8
|
+
|
9
|
+
##
|
10
|
+
# Should the output be placed into a single file
|
11
|
+
|
12
|
+
attr_reader :all_one_file
|
13
|
+
|
14
|
+
##
|
15
|
+
# Character-set
|
16
|
+
|
17
|
+
attr_reader :charset
|
18
|
+
|
19
|
+
##
|
20
|
+
# URL of stylesheet
|
21
|
+
|
22
|
+
attr_reader :css
|
23
|
+
|
24
|
+
##
|
25
|
+
# Should diagrams be drawn
|
26
|
+
|
27
|
+
attr_reader :diagram
|
28
|
+
|
29
|
+
##
|
30
|
+
# Files matching this pattern will be excluded
|
31
|
+
|
32
|
+
attr_accessor :exclude
|
33
|
+
|
34
|
+
##
|
35
|
+
# Additional attr_... style method flags
|
36
|
+
|
37
|
+
attr_reader :extra_accessor_flags
|
38
|
+
|
39
|
+
##
|
40
|
+
# Pattern for additional attr_... style methods
|
41
|
+
|
42
|
+
attr_reader :extra_accessors
|
43
|
+
|
44
|
+
##
|
45
|
+
# Should we draw fileboxes in diagrams
|
46
|
+
|
47
|
+
attr_reader :fileboxes
|
48
|
+
|
49
|
+
##
|
50
|
+
# The list of files to be processed
|
51
|
+
|
52
|
+
attr_accessor :files
|
53
|
+
|
54
|
+
##
|
55
|
+
# Scan newer sources than the flag file if true.
|
56
|
+
|
57
|
+
attr_reader :force_update
|
58
|
+
|
59
|
+
##
|
60
|
+
# Description of the output generator (set with the <tt>-fmt</tt> option)
|
61
|
+
|
62
|
+
attr_accessor :generator
|
63
|
+
|
64
|
+
##
|
65
|
+
# image format for diagrams
|
66
|
+
|
67
|
+
attr_reader :image_format
|
68
|
+
|
69
|
+
##
|
70
|
+
# Include line numbers in the source listings
|
71
|
+
|
72
|
+
attr_reader :include_line_numbers
|
73
|
+
|
74
|
+
##
|
75
|
+
# Should source code be included inline, or displayed in a popup
|
76
|
+
|
77
|
+
attr_accessor :inline_source
|
78
|
+
|
79
|
+
##
|
80
|
+
# Name of the file, class or module to display in the initial index page (if
|
81
|
+
# not specified the first file we encounter is used)
|
82
|
+
|
83
|
+
attr_accessor :main_page
|
84
|
+
|
85
|
+
##
|
86
|
+
# Merge into classes of the same name when generating ri
|
87
|
+
|
88
|
+
attr_reader :merge
|
89
|
+
|
90
|
+
##
|
91
|
+
# The name of the output directory
|
92
|
+
|
93
|
+
attr_accessor :op_dir
|
94
|
+
|
95
|
+
##
|
96
|
+
# The name to use for the output
|
97
|
+
|
98
|
+
attr_reader :op_name
|
99
|
+
|
100
|
+
##
|
101
|
+
# Are we promiscuous about showing module contents across multiple files
|
102
|
+
|
103
|
+
attr_reader :promiscuous
|
104
|
+
|
105
|
+
##
|
106
|
+
# Don't display progress as we process the files
|
107
|
+
|
108
|
+
attr_reader :quiet
|
109
|
+
|
110
|
+
##
|
111
|
+
# Array of directories to search for files to satisfy an :include:
|
112
|
+
|
113
|
+
attr_reader :rdoc_include
|
114
|
+
|
115
|
+
##
|
116
|
+
# Include private and protected methods in the output
|
117
|
+
|
118
|
+
attr_accessor :show_all
|
119
|
+
|
120
|
+
##
|
121
|
+
# Include the '#' at the front of hyperlinked instance method names
|
122
|
+
|
123
|
+
attr_reader :show_hash
|
124
|
+
|
125
|
+
##
|
126
|
+
# The number of columns in a tab
|
127
|
+
|
128
|
+
attr_reader :tab_width
|
129
|
+
|
130
|
+
##
|
131
|
+
# template to be used when generating output
|
132
|
+
|
133
|
+
attr_reader :template
|
134
|
+
|
135
|
+
##
|
136
|
+
# Template class for file generation
|
137
|
+
#--
|
138
|
+
# HACK around dependencies in lib/rdoc/generator/html.rb
|
139
|
+
|
140
|
+
attr_accessor :template_class # :nodoc:
|
141
|
+
|
142
|
+
##
|
143
|
+
# Documentation title
|
144
|
+
|
145
|
+
attr_reader :title
|
146
|
+
|
147
|
+
##
|
148
|
+
# URL of web cvs frontend
|
149
|
+
|
150
|
+
attr_reader :webcvs
|
151
|
+
|
152
|
+
def initialize(generators) # :nodoc:
|
153
|
+
@op_dir = "doc"
|
154
|
+
@op_name = nil
|
155
|
+
@show_all = false
|
156
|
+
@main_page = nil
|
157
|
+
@merge = false
|
158
|
+
@exclude = []
|
159
|
+
@quiet = false
|
160
|
+
@generators = generators
|
161
|
+
@generator_name = 'html'
|
162
|
+
@generator = @generators[@generator_name]
|
163
|
+
@rdoc_include = []
|
164
|
+
@title = nil
|
165
|
+
@template = nil
|
166
|
+
@template_class = nil
|
167
|
+
@diagram = false
|
168
|
+
@fileboxes = false
|
169
|
+
@show_hash = false
|
170
|
+
@image_format = 'png'
|
171
|
+
@inline_source = false
|
172
|
+
@all_one_file = false
|
173
|
+
@tab_width = 8
|
174
|
+
@include_line_numbers = false
|
175
|
+
@extra_accessor_flags = {}
|
176
|
+
@promiscuous = false
|
177
|
+
@force_update = false
|
178
|
+
@title = "RDoc Documentation"
|
179
|
+
|
180
|
+
@css = nil
|
181
|
+
@webcvs = nil
|
182
|
+
|
183
|
+
@charset = 'iso-8859-1'
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# Parse command line options.
|
188
|
+
|
189
|
+
def parse(argv)
|
190
|
+
accessors = []
|
191
|
+
|
192
|
+
opts = OptionParser.new do |opt|
|
193
|
+
opt.program_name = File.basename $0
|
194
|
+
opt.version = RDoc::VERSION
|
195
|
+
opt.summary_indent = ' ' * 4
|
196
|
+
opt.banner = <<-EOF
|
197
|
+
Usage: #{opt.program_name} [options] [names...]
|
198
|
+
|
199
|
+
Files are parsed, and the information they contain collected, before any
|
200
|
+
output is produced. This allows cross references between all files to be
|
201
|
+
resolved. If a name is a directory, it is traversed. If no names are
|
202
|
+
specified, all Ruby files in the current directory (and subdirectories) are
|
203
|
+
processed.
|
204
|
+
|
205
|
+
How RDoc generates output depends on the output formatter being used, and on
|
206
|
+
the options you give.
|
207
|
+
|
208
|
+
- HTML output is normally produced into a number of separate files
|
209
|
+
(one per class, module, and file, along with various indices).
|
210
|
+
These files will appear in the directory given by the --op
|
211
|
+
option (doc/ by default).
|
212
|
+
|
213
|
+
- XML output by default is written to standard output. If a
|
214
|
+
--opname option is given, the output will instead be written
|
215
|
+
to a file with that name in the output directory.
|
216
|
+
|
217
|
+
- .chm files (Windows help files) are written in the --op directory.
|
218
|
+
If an --opname parameter is present, that name is used, otherwise
|
219
|
+
the file will be called rdoc.chm.
|
220
|
+
EOF
|
221
|
+
|
222
|
+
opt.separator nil
|
223
|
+
opt.separator "Options:"
|
224
|
+
opt.separator nil
|
225
|
+
|
226
|
+
opt.on("--accessor=ACCESSORS", "-A", Array,
|
227
|
+
"A comma separated list of additional class",
|
228
|
+
"methods that should be treated like",
|
229
|
+
"'attr_reader' and friends.",
|
230
|
+
" ",
|
231
|
+
"Option may be repeated.",
|
232
|
+
" ",
|
233
|
+
"Each accessorname may have '=text'",
|
234
|
+
"appended, in which case that text appears",
|
235
|
+
"where the r/w/rw appears for normal.",
|
236
|
+
"accessors") do |value|
|
237
|
+
value.each do |accessor|
|
238
|
+
if accessor =~ /^(\w+)(=(.*))?$/
|
239
|
+
accessors << $1
|
240
|
+
@extra_accessor_flags[$1] = $3
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
opt.separator nil
|
246
|
+
|
247
|
+
opt.on("--all", "-a",
|
248
|
+
"Include all methods (not just public) in",
|
249
|
+
"the output.") do |value|
|
250
|
+
@show_all = value
|
251
|
+
end
|
252
|
+
|
253
|
+
opt.separator nil
|
254
|
+
|
255
|
+
opt.on("--charset=CHARSET", "-c",
|
256
|
+
"Specifies the HTML character-set.") do |value|
|
257
|
+
@charset = value
|
258
|
+
end
|
259
|
+
|
260
|
+
opt.separator nil
|
261
|
+
|
262
|
+
opt.on("--debug", "-D",
|
263
|
+
"Displays lots on internal stuff.") do |value|
|
264
|
+
$DEBUG_RDOC = value
|
265
|
+
end
|
266
|
+
|
267
|
+
opt.separator nil
|
268
|
+
|
269
|
+
opt.on("--diagram", "-d",
|
270
|
+
"Generate diagrams showing modules and",
|
271
|
+
"classes. You need dot V1.8.6 or later to",
|
272
|
+
"use the --diagram option correctly. Dot is",
|
273
|
+
"available from http://graphviz.org") do |value|
|
274
|
+
check_diagram
|
275
|
+
@diagram = true
|
276
|
+
end
|
277
|
+
|
278
|
+
opt.separator nil
|
279
|
+
|
280
|
+
opt.on("--exclude=PATTERN", "-x", Regexp,
|
281
|
+
"Do not process files or directories",
|
282
|
+
"matching PATTERN. Files given explicitly",
|
283
|
+
"on the command line will never be",
|
284
|
+
"excluded.") do |value|
|
285
|
+
@exclude << value
|
286
|
+
end
|
287
|
+
|
288
|
+
opt.separator nil
|
289
|
+
|
290
|
+
opt.on("--extension=NEW=OLD", "-E",
|
291
|
+
"Treat files ending with .new as if they",
|
292
|
+
"ended with .old. Using '-E cgi=rb' will",
|
293
|
+
"cause xxx.cgi to be parsed as a Ruby file.") do |value|
|
294
|
+
new, old = value.split(/=/, 2)
|
295
|
+
|
296
|
+
unless new and old then
|
297
|
+
raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
|
298
|
+
end
|
299
|
+
|
300
|
+
unless RDoc::ParserFactory.alias_extension old, new then
|
301
|
+
raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
opt.separator nil
|
306
|
+
|
307
|
+
opt.on("--fileboxes", "-F",
|
308
|
+
"Classes are put in boxes which represents",
|
309
|
+
"files, where these classes reside. Classes",
|
310
|
+
"shared between more than one file are",
|
311
|
+
"shown with list of files that are sharing",
|
312
|
+
"them. Silently discarded if --diagram is",
|
313
|
+
"not given.") do |value|
|
314
|
+
@fileboxes = value
|
315
|
+
end
|
316
|
+
|
317
|
+
opt.separator nil
|
318
|
+
|
319
|
+
opt.on("--force-update", "-U",
|
320
|
+
"Forces rdoc to scan all sources even if",
|
321
|
+
"newer than the flag file.") do |value|
|
322
|
+
@force_update = value
|
323
|
+
end
|
324
|
+
|
325
|
+
opt.separator nil
|
326
|
+
|
327
|
+
opt.on("--fmt=FORMAT", "--format=FORMAT", "-f", @generators.keys,
|
328
|
+
"Set the output formatter.") do |value|
|
329
|
+
@generator_name = value.downcase
|
330
|
+
setup_generator
|
331
|
+
end
|
332
|
+
|
333
|
+
opt.separator nil
|
334
|
+
|
335
|
+
image_formats = %w[gif png jpg jpeg]
|
336
|
+
opt.on("--image-format=FORMAT", "-I", image_formats,
|
337
|
+
"Sets output image format for diagrams. Can",
|
338
|
+
"be #{image_formats.join ', '}. If this option",
|
339
|
+
"is omitted, png is used. Requires",
|
340
|
+
"diagrams.") do |value|
|
341
|
+
@image_format = value
|
342
|
+
end
|
343
|
+
|
344
|
+
opt.separator nil
|
345
|
+
|
346
|
+
opt.on("--include=DIRECTORIES", "-i", Array,
|
347
|
+
"set (or add to) the list of directories to",
|
348
|
+
"be searched when satisfying :include:",
|
349
|
+
"requests. Can be used more than once.") do |value|
|
350
|
+
@rdoc_include.concat value.map { |dir| dir.strip }
|
351
|
+
end
|
352
|
+
|
353
|
+
opt.separator nil
|
354
|
+
|
355
|
+
opt.on("--inline-source", "-S",
|
356
|
+
"Show method source code inline, rather than",
|
357
|
+
"via a popup link.") do |value|
|
358
|
+
@inline_source = value
|
359
|
+
end
|
360
|
+
|
361
|
+
opt.separator nil
|
362
|
+
|
363
|
+
opt.on("--line-numbers", "-N",
|
364
|
+
"Include line numbers in the source code.") do |value|
|
365
|
+
@include_line_numbers = value
|
366
|
+
end
|
367
|
+
|
368
|
+
opt.separator nil
|
369
|
+
|
370
|
+
opt.on("--main=NAME", "-m",
|
371
|
+
"NAME will be the initial page displayed.") do |value|
|
372
|
+
@main_page = value
|
373
|
+
end
|
374
|
+
|
375
|
+
opt.separator nil
|
376
|
+
|
377
|
+
opt.on("--merge", "-M",
|
378
|
+
"When creating ri output, merge previously",
|
379
|
+
"processed classes into previously",
|
380
|
+
"documented classes of the same name.") do |value|
|
381
|
+
@merge = value
|
382
|
+
end
|
383
|
+
|
384
|
+
opt.separator nil
|
385
|
+
|
386
|
+
opt.on("--one-file", "-1",
|
387
|
+
"Put all the output into a single file.") do |value|
|
388
|
+
@all_one_file = value
|
389
|
+
@inline_source = value if value
|
390
|
+
@template = 'one_page_html'
|
391
|
+
end
|
392
|
+
|
393
|
+
opt.separator nil
|
394
|
+
|
395
|
+
opt.on("--op=DIR", "-o",
|
396
|
+
"Set the output directory.") do |value|
|
397
|
+
@op_dir = value
|
398
|
+
end
|
399
|
+
|
400
|
+
opt.separator nil
|
401
|
+
|
402
|
+
opt.on("--opname=NAME", "-n",
|
403
|
+
"Set the NAME of the output. Has no effect",
|
404
|
+
"for HTML.") do |value|
|
405
|
+
@op_name = value
|
406
|
+
end
|
407
|
+
|
408
|
+
opt.separator nil
|
409
|
+
|
410
|
+
opt.on("--promiscuous", "-p",
|
411
|
+
"When documenting a file that contains a",
|
412
|
+
"module or class also defined in other",
|
413
|
+
"files, show all stuff for that module or",
|
414
|
+
"class in each files page. By default, only",
|
415
|
+
"show stuff defined in that particular file.") do |value|
|
416
|
+
@promiscuous = value
|
417
|
+
end
|
418
|
+
|
419
|
+
opt.separator nil
|
420
|
+
|
421
|
+
opt.on("--quiet", "-q",
|
422
|
+
"Don't show progress as we parse.") do |value|
|
423
|
+
@quiet = value
|
424
|
+
end
|
425
|
+
|
426
|
+
opt.separator nil
|
427
|
+
|
428
|
+
opt.on("--ri", "-r",
|
429
|
+
"Generate output for use by `ri`. The files",
|
430
|
+
"are stored in the '.rdoc' directory under",
|
431
|
+
"your home directory unless overridden by a",
|
432
|
+
"subsequent --op parameter, so no special",
|
433
|
+
"privileges are needed.") do |value|
|
434
|
+
@generator_name = "ri"
|
435
|
+
@op_dir = RDoc::RI::Paths::HOMEDIR
|
436
|
+
setup_generator
|
437
|
+
end
|
438
|
+
|
439
|
+
opt.separator nil
|
440
|
+
|
441
|
+
opt.on("--ri-site", "-R",
|
442
|
+
"Generate output for use by `ri`. The files",
|
443
|
+
"are stored in a site-wide directory,",
|
444
|
+
"making them accessible to others, so",
|
445
|
+
"special privileges are needed.") do |value|
|
446
|
+
@generator_name = "ri"
|
447
|
+
@op_dir = RDoc::RI::Paths::SITEDIR
|
448
|
+
setup_generator
|
449
|
+
end
|
450
|
+
|
451
|
+
opt.separator nil
|
452
|
+
|
453
|
+
opt.on("--ri-system", "-Y",
|
454
|
+
"Generate output for use by `ri`. The files",
|
455
|
+
"are stored in a site-wide directory,",
|
456
|
+
"making them accessible to others, so",
|
457
|
+
"special privileges are needed. This",
|
458
|
+
"option is intended to be used during Ruby",
|
459
|
+
"installation.") do |value|
|
460
|
+
@generator_name = "ri"
|
461
|
+
@op_dir = RDoc::RI::Paths::SYSDIR
|
462
|
+
setup_generator
|
463
|
+
end
|
464
|
+
|
465
|
+
opt.separator nil
|
466
|
+
|
467
|
+
opt.on("--show-hash", "-H",
|
468
|
+
"A name of the form #name in a comment is a",
|
469
|
+
"possible hyperlink to an instance method",
|
470
|
+
"name. When displayed, the '#' is removed",
|
471
|
+
"unless this option is specified.") do |value|
|
472
|
+
@show_hash = value
|
473
|
+
end
|
474
|
+
|
475
|
+
opt.separator nil
|
476
|
+
|
477
|
+
opt.on("--style=URL", "-s",
|
478
|
+
"Specifies the URL of a separate stylesheet.") do |value|
|
479
|
+
@css = value
|
480
|
+
end
|
481
|
+
|
482
|
+
opt.separator nil
|
483
|
+
|
484
|
+
opt.on("--tab-width=WIDTH", "-w", OptionParser::DecimalInteger,
|
485
|
+
"Set the width of tab characters.") do |value|
|
486
|
+
@tab_width = value
|
487
|
+
end
|
488
|
+
|
489
|
+
opt.separator nil
|
490
|
+
|
491
|
+
opt.on("--template=NAME", "-T",
|
492
|
+
"Set the template used when generating",
|
493
|
+
"output.") do |value|
|
494
|
+
@template = value
|
495
|
+
end
|
496
|
+
|
497
|
+
opt.separator nil
|
498
|
+
|
499
|
+
opt.on("--title=TITLE", "-t",
|
500
|
+
"Set TITLE as the title for HTML output.") do |value|
|
501
|
+
@title = value
|
502
|
+
end
|
503
|
+
|
504
|
+
opt.separator nil
|
505
|
+
|
506
|
+
opt.on("--webcvs=URL", "-W",
|
507
|
+
"Specify a URL for linking to a web frontend",
|
508
|
+
"to CVS. If the URL contains a '\%s', the",
|
509
|
+
"name of the current file will be",
|
510
|
+
"substituted; if the URL doesn't contain a",
|
511
|
+
"'\%s', the filename will be appended to it.") do |value|
|
512
|
+
@webcvs = value
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
opts.parse! argv
|
517
|
+
|
518
|
+
@files = argv.dup
|
519
|
+
|
520
|
+
@rdoc_include << "." if @rdoc_include.empty?
|
521
|
+
|
522
|
+
if @exclude.empty? then
|
523
|
+
@exclude = nil
|
524
|
+
else
|
525
|
+
@exclude = Regexp.new(@exclude.join("|"))
|
526
|
+
end
|
527
|
+
|
528
|
+
check_files
|
529
|
+
|
530
|
+
# If no template was specified, use the default template for the output
|
531
|
+
# formatter
|
532
|
+
|
533
|
+
@template ||= @generator_name
|
534
|
+
|
535
|
+
# Generate a regexp from the accessors
|
536
|
+
unless accessors.empty? then
|
537
|
+
re = '^(' + accessors.map { |a| Regexp.quote a }.join('|') + ')$'
|
538
|
+
@extra_accessors = Regexp.new re
|
539
|
+
end
|
540
|
+
|
541
|
+
rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
|
542
|
+
puts opts
|
543
|
+
puts
|
544
|
+
puts e
|
545
|
+
exit 1
|
546
|
+
end
|
547
|
+
|
548
|
+
##
|
549
|
+
# Set the title, but only if not already set. This means that a title set
|
550
|
+
# from the command line trumps one set in a source file
|
551
|
+
|
552
|
+
def title=(string)
|
553
|
+
@title ||= string
|
554
|
+
end
|
555
|
+
|
556
|
+
private
|
557
|
+
|
558
|
+
##
|
559
|
+
# Set up an output generator for the format in @generator_name
|
560
|
+
|
561
|
+
def setup_generator
|
562
|
+
@generator = @generators[@generator_name]
|
563
|
+
|
564
|
+
unless @generator then
|
565
|
+
raise OptionParser::InvalidArgument, "Invalid output formatter"
|
566
|
+
end
|
567
|
+
|
568
|
+
if @generator_name == "xml" then
|
569
|
+
@all_one_file = true
|
570
|
+
@inline_source = true
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
# Check that the right version of 'dot' is available. Unfortuately this
|
575
|
+
# doesn't work correctly under Windows NT, so we'll bypass the test under
|
576
|
+
# Windows.
|
577
|
+
|
578
|
+
def check_diagram
|
579
|
+
return if RUBY_PLATFORM =~ /mswin|cygwin|mingw|bccwin/
|
580
|
+
|
581
|
+
ok = false
|
582
|
+
ver = nil
|
583
|
+
|
584
|
+
IO.popen "dot -V 2>&1" do |io|
|
585
|
+
ver = io.read
|
586
|
+
if ver =~ /dot.+version(?:\s+gviz)?\s+(\d+)\.(\d+)/ then
|
587
|
+
ok = ($1.to_i > 1) || ($1.to_i == 1 && $2.to_i >= 8)
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
unless ok then
|
592
|
+
if ver =~ /^dot.+version/ then
|
593
|
+
$stderr.puts "Warning: You may need dot V1.8.6 or later to use\n",
|
594
|
+
"the --diagram option correctly. You have:\n\n ",
|
595
|
+
ver,
|
596
|
+
"\nDiagrams might have strange background colors.\n\n"
|
597
|
+
else
|
598
|
+
$stderr.puts "You need the 'dot' program to produce diagrams.",
|
599
|
+
"(see http://www.research.att.com/sw/tools/graphviz/)\n\n"
|
600
|
+
exit
|
601
|
+
end
|
602
|
+
end
|
603
|
+
end
|
604
|
+
|
605
|
+
##
|
606
|
+
# Check that the files on the command line exist
|
607
|
+
|
608
|
+
def check_files
|
609
|
+
@files.each do |f|
|
610
|
+
stat = File.stat f rescue abort("File not found: #{f}")
|
611
|
+
abort("File '#{f}' not readable") unless stat.readable?
|
612
|
+
end
|
613
|
+
end
|
614
|
+
|
615
|
+
end
|
616
|
+
|