iownbey-rdoc 2.0.1

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