rdoc-f95 0.0.1

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