| Class | RDoc::Options |
| In: |
options.rb
doc-tmp/rdoc/options.rb |
| Parent: | Object |
Check that the right version of ‘dot’ is available. Unfortunately this doesn‘t work correctly under Windows NT, so we‘ll bypass the test under Windows.
# File options.rb, line 645
645: def check_diagram
646: return if RUBY_PLATFORM =~ /mswin|cygwin|mingw|bccwin/
647:
648: ok = false
649: ver = nil
650:
651: IO.popen "dot -V 2>&1" do |io|
652: ver = io.read
653: if ver =~ /dot.+version(?:\s+gviz)?\s+(\d+)\.(\d+)/ then
654: ok = ($1.to_i > 1) || ($1.to_i == 1 && $2.to_i >= 8)
655: end
656: end
657:
658: unless ok then
659: if ver =~ /^dot.+version/ then
660: $stderr.puts "Warning: You may need dot V1.8.6 or later to use\n",
661: "the --diagram option correctly. You have:\n\n ",
662: ver,
663: "\nDiagrams might have strange background colors.\n\n"
664: else
665: $stderr.puts "You need the 'dot' program to produce diagrams.",
666: "(see http://www.research.att.com/sw/tools/graphviz/)\n\n"
667: exit
668: end
669: end
670: end
Check that the right version of ‘dot’ is available. Unfortunately this doesn‘t work correctly under Windows NT, so we‘ll bypass the test under Windows.
# File doc-tmp/rdoc/options.rb, line 645
645: def check_diagram
646: return if RUBY_PLATFORM =~ /mswin|cygwin|mingw|bccwin/
647:
648: ok = false
649: ver = nil
650:
651: IO.popen "dot -V 2>&1" do |io|
652: ver = io.read
653: if ver =~ /dot.+version(?:\s+gviz)?\s+(\d+)\.(\d+)/ then
654: ok = ($1.to_i > 1) || ($1.to_i == 1 && $2.to_i >= 8)
655: end
656: end
657:
658: unless ok then
659: if ver =~ /^dot.+version/ then
660: $stderr.puts "Warning: You may need dot V1.8.6 or later to use\n",
661: "the --diagram option correctly. You have:\n\n ",
662: ver,
663: "\nDiagrams might have strange background colors.\n\n"
664: else
665: $stderr.puts "You need the 'dot' program to produce diagrams.",
666: "(see http://www.research.att.com/sw/tools/graphviz/)\n\n"
667: exit
668: end
669: end
670: end
Check that the files on the command line exist
# File options.rb, line 741
741: def check_files
742: @files.each do |f|
743: stat = File.stat f
744: raise RDoc::Error, "file '#{f}' not readable" unless stat.readable?
745: end
746: end
Check that the files on the command line exist
# File doc-tmp/rdoc/options.rb, line 741
741: def check_files
742: @files.each do |f|
743: stat = File.stat f
744: raise RDoc::Error, "file '#{f}' not readable" unless stat.readable?
745: end
746: end
Check that the right version of ‘mathml.rb’ is available.
# File options.rb, line 675
675: def check_mathml
676: not_found = true
677: fpath = ""
678: $LOAD_PATH.each{ |lpath|
679: ["mathml.rb", "math_ml.rb"].each { |ml|
680: fpath = File.join(lpath, ml)
681: if File.exist?(fpath)
682: not_found = false
683: break
684: end
685: }
686: break unless not_found
687: }
688:
689: if not_found
690: $stderr.puts "You need the 'mathml.rb' to convert TeX to MathML.\n(see http://www.hinet.mydns.jp/~hiraku/hiki/, but only JAPANESE.\nYou can download 'mathml.rb' directly from\nhttp://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz)\n\n"
691: exit
692: end
693:
694: contents = File.open(fpath, "r") {|f| f.read}
695: num = 1
696: if !(contents =~ /^\s*module\s+MathML/) ||
697: !(contents =~ /^\s*module\s+LaTeX/) ||
698: !(contents =~ /^\s*class\s+Parser/) ||
699: !(contents =~ /^\s*def\s+parse/)
700: $stderr.puts "You need the 'mathml.rb' V0.8 or later to use.\n(see http://www.hinet.mydns.jp/~hiraku/hiki/, but only JAPANESE.\nYou can download 'mathml.rb' directly from\nhttp://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz)\n\n"
701:
702: exit
703: end
704: end
Check that the right version of ‘mathml.rb’ is available.
# File doc-tmp/rdoc/options.rb, line 675
675: def check_mathml
676: not_found = true
677: fpath = ""
678: $LOAD_PATH.each{ |lpath|
679: ["mathml.rb", "math_ml.rb"].each { |ml|
680: fpath = File.join(lpath, ml)
681: if File.exist?(fpath)
682: not_found = false
683: break
684: end
685: }
686: break unless not_found
687: }
688:
689: if not_found
690: $stderr.puts "You need the 'mathml.rb' to convert TeX to MathML.\n(see http://www.hinet.mydns.jp/~hiraku/hiki/, but only JAPANESE.\nYou can download 'mathml.rb' directly from\nhttp://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz)\n\n"
691: exit
692: end
693:
694: contents = File.open(fpath, "r") {|f| f.read}
695: num = 1
696: if !(contents =~ /^\s*module\s+MathML/) ||
697: !(contents =~ /^\s*module\s+LaTeX/) ||
698: !(contents =~ /^\s*class\s+Parser/) ||
699: !(contents =~ /^\s*def\s+parse/)
700: $stderr.puts "You need the 'mathml.rb' V0.8 or later to use.\n(see http://www.hinet.mydns.jp/~hiraku/hiki/, but only JAPANESE.\nYou can download 'mathml.rb' directly from\nhttp://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz)\n\n"
701:
702: exit
703: end
704: end
Parse command line options.
# File doc-tmp/rdoc/options.rb, line 205
205: def parse(argv)
206: accessors = []
207:
208: opts = OptionParser.new do |opt|
209: opt.program_name = File.basename $0
210: opt.version = RDoc::VERSION
211: opt.release = nil
212: opt.summary_indent = ' ' * 4
213: opt.banner = "Usage: \#{opt.program_name} [options] [names...]\n\nFiles are parsed, and the information they contain collected, before any\noutput is produced. This allows cross references between all files to be\nresolved. If a name is a directory, it is traversed. If no names are\nspecified, all Ruby files in the current directory (and subdirectories) are\nprocessed.\n\nHow RDoc generates output depends on the output formatter being used, and on\nthe options you give.\n\n- HTML output is normally produced into a number of separate files\n(one per class, module, and file, along with various indices).\nThese files will appear in the directory given by the --op\noption (doc/ by default).\n\n- XHTML output is the same as HTML.\n\n- XML output by default is written to standard output. If a\n--opname option is given, the output will instead be written\nto a file with that name in the output directory.\n\n- .chm files (Windows help files) are written in the --op directory.\nIf an --opname parameter is present, that name is used, otherwise\nthe file will be called rdoc.chm.\n"
214:
215: # opt.separator nil # 1.8.2 doesn't work
216: opt.separator "Options:"
217: # opt.separator nil # 1.8.2 doesn't work
218:
219: opt.on("--accessor=ACCESSORS", "-A", Array,
220: "A comma separated list of additional class",
221: "methods that should be treated like",
222: "'attr_reader' and friends.",
223: " ",
224: "Option may be repeated.",
225: " ",
226: "Each accessorname may have '=text'",
227: "appended, in which case that text appears",
228: "where the r/w/rw appears for normal.",
229: "accessors") do |value|
230: value.each do |accessor|
231: if accessor =~ /^(\w+)(=(.*))?$/
232: accessors << $1
233: @extra_accessor_flags[$1] = $3
234: end
235: end
236: end
237:
238: # opt.separator nil # 1.8.2 doesn't work
239:
240: opt.on("--all", "-a",
241: "Include all methods (not just public) in",
242: "the output.") do |value|
243: @show_all = value
244: end
245:
246: # opt.separator nil # 1.8.2 doesn't work
247:
248: opt.on("--charset=CHARSET", "-c",
249: "Specifies the output HTML character-set.") do |value|
250: @charset = value
251: end
252:
253: # opt.separator nil # 1.8.2 doesn't work
254:
255: opt.on("--debug", "-D",
256: "Displays lots on internal stuff.") do |value|
257: $DEBUG_RDOC = value
258: end
259:
260: # opt.separator nil # 1.8.2 doesn't work
261:
262: opt.on("--diagram", "-d",
263: "Generate diagrams showing modules and",
264: "classes. You need dot V1.8.6 or later to",
265: "use the --diagram option correctly. Dot is",
266: "available from http://graphviz.org") do |value|
267: check_diagram
268: @diagram = true
269: end
270:
271: # opt.separator nil # 1.8.2 doesn't work
272:
273: opt.on("--exclude=PATTERN", "-x", Regexp,
274: "Do not process files or directories",
275: "matching PATTERN.") do |value|
276: @exclude << value
277: end
278:
279: # opt.separator nil # 1.8.2 doesn't work
280:
281: opt.on("--extension=NEW=OLD", "-E",
282: "Treat files ending with .new as if they",
283: "ended with .old. Using '-E cgi=rb' will",
284: "cause xxx.cgi to be parsed as a Ruby file.") do |value|
285: new, old = value.split(/=/, 2)
286:
287: unless new and old then
288: raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
289: end
290:
291: unless RDoc::ParserFactory.alias_extension old, new then
292: raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
293: end
294: end
295:
296: # opt.separator nil # 1.8.2 doesn't work
297:
298: opt.on("--fileboxes", "-F",
299: "Classes are put in boxes which represents",
300: "files, where these classes reside. Classes",
301: "shared between more than one file are",
302: "shown with list of files that are sharing",
303: "them. Silently discarded if --diagram is",
304: "not given.") do |value|
305: @fileboxes = value
306: end
307:
308: # opt.separator nil # 1.8.2 doesn't work
309:
310: opt.on("--force-update", "-U",
311: "Forces rdoc to scan all sources even if",
312: "newer than the flag file.") do |value|
313: @force_update = value
314: end
315:
316: # opt.separator nil # 1.8.2 doesn't work
317:
318: opt.on("--fmt=FORMAT", "--format=FORMAT", "-f", @generators.keys,
319: "Set the output formatter.") do |value|
320: @generator_name = value.downcase
321: setup_generator
322: end
323:
324: # opt.separator nil # 1.8.2 doesn't work
325:
326: image_formats = %w[gif png jpg jpeg]
327: opt.on("--image-format=FORMAT", "-I", image_formats,
328: "Sets output image format for diagrams. Can",
329: "be #{image_formats.join ', '}. If this option",
330: "is omitted, png is used. Requires",
331: "diagrams.") do |value|
332: @image_format = value
333: end
334:
335: # opt.separator nil # 1.8.2 doesn't work
336:
337: opt.on("--include=DIRECTORIES", "-i", Array,
338: "set (or add to) the list of directories to",
339: "be searched when satisfying :include:",
340: "requests. Can be used more than once.") do |value|
341: @rdoc_include.concat value.map { |dir| dir.strip }
342: end
343:
344: # opt.separator nil # 1.8.2 doesn't work
345:
346: opt.on("--inline-source", "-S",
347: "Show method source code inline, rather than",
348: "via a popup link.") do |value|
349: @inline_source = value
350: end
351:
352: # opt.separator nil # 1.8.2 doesn't work
353:
354: opt.on("--line-numbers", "-N",
355: "Include line numbers in the source code.") do |value|
356: @include_line_numbers = value
357: end
358:
359: # opt.separator nil # 1.8.2 doesn't work
360:
361: opt.on("--main=NAME", "-m",
362: "NAME will be the initial page displayed.") do |value|
363: @main_page = value
364: end
365:
366: # opt.separator nil # 1.8.2 doesn't work
367:
368: opt.on("--merge", "-M",
369: "When creating ri output, merge previously",
370: "processed classes into previously",
371: "documented classes of the same name.") do |value|
372: @merge = value
373: end
374:
375: # opt.separator nil # 1.8.2 doesn't work
376:
377: opt.on("--one-file", "-1",
378: "Put all the output into a single file.") do |value|
379: @all_one_file = value
380: @inline_source = value if value
381: @template = 'one_page_html'
382: end
383:
384: # opt.separator nil # 1.8.2 doesn't work
385:
386: opt.on("--op=DIR", "-o",
387: "Set the output directory.") do |value|
388: if @css && ! (%r{^(https?:/)?/} =~ @css)
389: @css = relative_str(File.join(value, "."),
390: relative_str(File.join(@op_dir.split("/").fill(".."), ".."), @css))
391: end
392: @op_dir = value
393: end
394:
395: # opt.separator nil # 1.8.2 doesn't work
396:
397: opt.on("--opname=NAME", "-n",
398: "Set the NAME of the output. Has no effect",
399: "for HTML.") do |value|
400: @op_name = value
401: end
402:
403: # opt.separator nil # 1.8.2 doesn't work
404:
405: opt.on("--promiscuous", "-p",
406: "When documenting a file that contains a",
407: "module or class also defined in other",
408: "files, show all stuff for that module or",
409: "class in each files page. By default, only",
410: "show stuff defined in that particular file.") do |value|
411: @promiscuous = value
412: end
413:
414: # opt.separator nil # 1.8.2 doesn't work
415:
416: opt.on("--quiet", "-q",
417: "Don't show progress as we parse.") do |value|
418: @verbosity = 0
419: end
420:
421: opt.on("--verbose", "-v",
422: "Display extra progress as we parse.") do |value|
423: @verbosity = 2
424: end
425:
426:
427: # opt.separator nil # 1.8.2 doesn't work
428:
429: opt.on("--ri", "-r",
430: "Generate output for use by `ri`. The files",
431: "are stored in the '.rdoc' directory under",
432: "your home directory unless overridden by a",
433: "subsequent --op parameter, so no special",
434: "privileges are needed.") do |value|
435: @generator_name = "ri"
436: @op_dir = RDoc::RI::Paths::HOMEDIR
437: setup_generator
438: end
439:
440: # opt.separator nil # 1.8.2 doesn't work
441:
442: opt.on("--ri-site", "-R",
443: "Generate output for use by `ri`. The files",
444: "are stored in a site-wide directory,",
445: "making them accessible to others, so",
446: "special privileges are needed.") do |value|
447: @generator_name = "ri"
448: @op_dir = RDoc::RI::Paths::SITEDIR
449: setup_generator
450: end
451:
452: # opt.separator nil # 1.8.2 doesn't work
453:
454: opt.on("--ri-system", "-Y",
455: "Generate output for use by `ri`. The files",
456: "are stored in a site-wide directory,",
457: "making them accessible to others, so",
458: "special privileges are needed. This",
459: "option is intended to be used during Ruby",
460: "installation.") do |value|
461: @generator_name = "ri"
462: @op_dir = RDoc::RI::Paths::SYSDIR
463: setup_generator
464: end
465:
466: # opt.separator nil # 1.8.2 doesn't work
467:
468: opt.on("--show-hash", "-H",
469: "A name of the form #name in a comment is a",
470: "possible hyperlink to an instance method",
471: "name. When displayed, the '#' is removed",
472: "unless this option is specified.") do |value|
473: @show_hash = value
474: end
475:
476: # opt.separator nil # 1.8.2 doesn't work
477:
478: opt.on("--style=URL", "-s",
479: "Specifies the URL of a separate stylesheet.") do |value|
480: if %r{^(https?:/)?/} =~ value
481: @css = value
482: else
483: @css = relative_str(File.join(@op_dir, "."), value)
484: end
485: end
486:
487: # opt.separator nil # 1.8.2 doesn't work
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 # 1.8.2 doesn't work
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 # 1.8.2 doesn't work
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 # 1.8.2 doesn't work
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:
520: # opt.separator nil # 1.8.2 doesn't work
521:
522: opt.on("--mathml", "-l",
523: "TeX formatted formula is converted to MathML.",
524: "You need mathml.rb V0.8 or later to use the --mathml",
525: "option correctly. mathml.rb V0.8 is available from",
526: "http://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz") do |value|
527: check_mathml
528: @mathml = true
529: @generator_name = 'xhtml'
530: @template = @generator_name
531: setup_generator
532: end
533:
534: # opt.separator nil # 1.8.2 doesn't work
535:
536: opt.on("--ignore-case", "-C",
537: "The case of names of classes or modules",
538: "or methods are ignored.") do |value|
539: @ignore_case = true
540: end
541: end
542:
543: argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
544:
545: opts.parse! argv
546:
547: @files = argv.dup
548:
549: @rdoc_include << "." if @rdoc_include.empty?
550:
551: if @exclude.empty? then
552: @exclude = nil
553: else
554: @exclude = Regexp.new(@exclude.join("|"))
555: end
556:
557: check_files
558:
559: # If no template was specified, use the default template for the output
560: # formatter
561:
562: @template ||= @generator_name
563:
564: # Generate a regexp from the accessors
565: unless accessors.empty? then
566: re = '^(' + accessors.map { |a| Regexp.quote a }.join('|') + ')$'
567: @extra_accessors = Regexp.new re
568: end
569:
570: rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
571: puts opts
572: puts
573: puts e
574: exit 1
575: end
Parse command line options.
# File options.rb, line 205
205: def parse(argv)
206: accessors = []
207:
208: opts = OptionParser.new do |opt|
209: opt.program_name = File.basename $0
210: opt.version = RDoc::VERSION
211: opt.release = nil
212: opt.summary_indent = ' ' * 4
213: opt.banner = "Usage: \#{opt.program_name} [options] [names...]\n\nFiles are parsed, and the information they contain collected, before any\noutput is produced. This allows cross references between all files to be\nresolved. If a name is a directory, it is traversed. If no names are\nspecified, all Ruby files in the current directory (and subdirectories) are\nprocessed.\n\nHow RDoc generates output depends on the output formatter being used, and on\nthe options you give.\n\n- HTML output is normally produced into a number of separate files\n(one per class, module, and file, along with various indices).\nThese files will appear in the directory given by the --op\noption (doc/ by default).\n\n- XHTML output is the same as HTML.\n\n- XML output by default is written to standard output. If a\n--opname option is given, the output will instead be written\nto a file with that name in the output directory.\n\n- .chm files (Windows help files) are written in the --op directory.\nIf an --opname parameter is present, that name is used, otherwise\nthe file will be called rdoc.chm.\n"
214:
215: # opt.separator nil # 1.8.2 doesn't work
216: opt.separator "Options:"
217: # opt.separator nil # 1.8.2 doesn't work
218:
219: opt.on("--accessor=ACCESSORS", "-A", Array,
220: "A comma separated list of additional class",
221: "methods that should be treated like",
222: "'attr_reader' and friends.",
223: " ",
224: "Option may be repeated.",
225: " ",
226: "Each accessorname may have '=text'",
227: "appended, in which case that text appears",
228: "where the r/w/rw appears for normal.",
229: "accessors") do |value|
230: value.each do |accessor|
231: if accessor =~ /^(\w+)(=(.*))?$/
232: accessors << $1
233: @extra_accessor_flags[$1] = $3
234: end
235: end
236: end
237:
238: # opt.separator nil # 1.8.2 doesn't work
239:
240: opt.on("--all", "-a",
241: "Include all methods (not just public) in",
242: "the output.") do |value|
243: @show_all = value
244: end
245:
246: # opt.separator nil # 1.8.2 doesn't work
247:
248: opt.on("--charset=CHARSET", "-c",
249: "Specifies the output HTML character-set.") do |value|
250: @charset = value
251: end
252:
253: # opt.separator nil # 1.8.2 doesn't work
254:
255: opt.on("--debug", "-D",
256: "Displays lots on internal stuff.") do |value|
257: $DEBUG_RDOC = value
258: end
259:
260: # opt.separator nil # 1.8.2 doesn't work
261:
262: opt.on("--diagram", "-d",
263: "Generate diagrams showing modules and",
264: "classes. You need dot V1.8.6 or later to",
265: "use the --diagram option correctly. Dot is",
266: "available from http://graphviz.org") do |value|
267: check_diagram
268: @diagram = true
269: end
270:
271: # opt.separator nil # 1.8.2 doesn't work
272:
273: opt.on("--exclude=PATTERN", "-x", Regexp,
274: "Do not process files or directories",
275: "matching PATTERN.") do |value|
276: @exclude << value
277: end
278:
279: # opt.separator nil # 1.8.2 doesn't work
280:
281: opt.on("--extension=NEW=OLD", "-E",
282: "Treat files ending with .new as if they",
283: "ended with .old. Using '-E cgi=rb' will",
284: "cause xxx.cgi to be parsed as a Ruby file.") do |value|
285: new, old = value.split(/=/, 2)
286:
287: unless new and old then
288: raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
289: end
290:
291: unless RDoc::ParserFactory.alias_extension old, new then
292: raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
293: end
294: end
295:
296: # opt.separator nil # 1.8.2 doesn't work
297:
298: opt.on("--fileboxes", "-F",
299: "Classes are put in boxes which represents",
300: "files, where these classes reside. Classes",
301: "shared between more than one file are",
302: "shown with list of files that are sharing",
303: "them. Silently discarded if --diagram is",
304: "not given.") do |value|
305: @fileboxes = value
306: end
307:
308: # opt.separator nil # 1.8.2 doesn't work
309:
310: opt.on("--force-update", "-U",
311: "Forces rdoc to scan all sources even if",
312: "newer than the flag file.") do |value|
313: @force_update = value
314: end
315:
316: # opt.separator nil # 1.8.2 doesn't work
317:
318: opt.on("--fmt=FORMAT", "--format=FORMAT", "-f", @generators.keys,
319: "Set the output formatter.") do |value|
320: @generator_name = value.downcase
321: setup_generator
322: end
323:
324: # opt.separator nil # 1.8.2 doesn't work
325:
326: image_formats = %w[gif png jpg jpeg]
327: opt.on("--image-format=FORMAT", "-I", image_formats,
328: "Sets output image format for diagrams. Can",
329: "be #{image_formats.join ', '}. If this option",
330: "is omitted, png is used. Requires",
331: "diagrams.") do |value|
332: @image_format = value
333: end
334:
335: # opt.separator nil # 1.8.2 doesn't work
336:
337: opt.on("--include=DIRECTORIES", "-i", Array,
338: "set (or add to) the list of directories to",
339: "be searched when satisfying :include:",
340: "requests. Can be used more than once.") do |value|
341: @rdoc_include.concat value.map { |dir| dir.strip }
342: end
343:
344: # opt.separator nil # 1.8.2 doesn't work
345:
346: opt.on("--inline-source", "-S",
347: "Show method source code inline, rather than",
348: "via a popup link.") do |value|
349: @inline_source = value
350: end
351:
352: # opt.separator nil # 1.8.2 doesn't work
353:
354: opt.on("--line-numbers", "-N",
355: "Include line numbers in the source code.") do |value|
356: @include_line_numbers = value
357: end
358:
359: # opt.separator nil # 1.8.2 doesn't work
360:
361: opt.on("--main=NAME", "-m",
362: "NAME will be the initial page displayed.") do |value|
363: @main_page = value
364: end
365:
366: # opt.separator nil # 1.8.2 doesn't work
367:
368: opt.on("--merge", "-M",
369: "When creating ri output, merge previously",
370: "processed classes into previously",
371: "documented classes of the same name.") do |value|
372: @merge = value
373: end
374:
375: # opt.separator nil # 1.8.2 doesn't work
376:
377: opt.on("--one-file", "-1",
378: "Put all the output into a single file.") do |value|
379: @all_one_file = value
380: @inline_source = value if value
381: @template = 'one_page_html'
382: end
383:
384: # opt.separator nil # 1.8.2 doesn't work
385:
386: opt.on("--op=DIR", "-o",
387: "Set the output directory.") do |value|
388: if @css && ! (%r{^(https?:/)?/} =~ @css)
389: @css = relative_str(File.join(value, "."),
390: relative_str(File.join(@op_dir.split("/").fill(".."), ".."), @css))
391: end
392: @op_dir = value
393: end
394:
395: # opt.separator nil # 1.8.2 doesn't work
396:
397: opt.on("--opname=NAME", "-n",
398: "Set the NAME of the output. Has no effect",
399: "for HTML.") do |value|
400: @op_name = value
401: end
402:
403: # opt.separator nil # 1.8.2 doesn't work
404:
405: opt.on("--promiscuous", "-p",
406: "When documenting a file that contains a",
407: "module or class also defined in other",
408: "files, show all stuff for that module or",
409: "class in each files page. By default, only",
410: "show stuff defined in that particular file.") do |value|
411: @promiscuous = value
412: end
413:
414: # opt.separator nil # 1.8.2 doesn't work
415:
416: opt.on("--quiet", "-q",
417: "Don't show progress as we parse.") do |value|
418: @verbosity = 0
419: end
420:
421: opt.on("--verbose", "-v",
422: "Display extra progress as we parse.") do |value|
423: @verbosity = 2
424: end
425:
426:
427: # opt.separator nil # 1.8.2 doesn't work
428:
429: opt.on("--ri", "-r",
430: "Generate output for use by `ri`. The files",
431: "are stored in the '.rdoc' directory under",
432: "your home directory unless overridden by a",
433: "subsequent --op parameter, so no special",
434: "privileges are needed.") do |value|
435: @generator_name = "ri"
436: @op_dir = RDoc::RI::Paths::HOMEDIR
437: setup_generator
438: end
439:
440: # opt.separator nil # 1.8.2 doesn't work
441:
442: opt.on("--ri-site", "-R",
443: "Generate output for use by `ri`. The files",
444: "are stored in a site-wide directory,",
445: "making them accessible to others, so",
446: "special privileges are needed.") do |value|
447: @generator_name = "ri"
448: @op_dir = RDoc::RI::Paths::SITEDIR
449: setup_generator
450: end
451:
452: # opt.separator nil # 1.8.2 doesn't work
453:
454: opt.on("--ri-system", "-Y",
455: "Generate output for use by `ri`. The files",
456: "are stored in a site-wide directory,",
457: "making them accessible to others, so",
458: "special privileges are needed. This",
459: "option is intended to be used during Ruby",
460: "installation.") do |value|
461: @generator_name = "ri"
462: @op_dir = RDoc::RI::Paths::SYSDIR
463: setup_generator
464: end
465:
466: # opt.separator nil # 1.8.2 doesn't work
467:
468: opt.on("--show-hash", "-H",
469: "A name of the form #name in a comment is a",
470: "possible hyperlink to an instance method",
471: "name. When displayed, the '#' is removed",
472: "unless this option is specified.") do |value|
473: @show_hash = value
474: end
475:
476: # opt.separator nil # 1.8.2 doesn't work
477:
478: opt.on("--style=URL", "-s",
479: "Specifies the URL of a separate stylesheet.") do |value|
480: if %r{^(https?:/)?/} =~ value
481: @css = value
482: else
483: @css = relative_str(File.join(@op_dir, "."), value)
484: end
485: end
486:
487: # opt.separator nil # 1.8.2 doesn't work
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 # 1.8.2 doesn't work
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 # 1.8.2 doesn't work
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 # 1.8.2 doesn't work
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:
520: # opt.separator nil # 1.8.2 doesn't work
521:
522: opt.on("--mathml", "-l",
523: "TeX formatted formula is converted to MathML.",
524: "You need mathml.rb V0.8 or later to use the --mathml",
525: "option correctly. mathml.rb V0.8 is available from",
526: "http://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz") do |value|
527: check_mathml
528: @mathml = true
529: @generator_name = 'xhtml'
530: @template = @generator_name
531: setup_generator
532: end
533:
534: # opt.separator nil # 1.8.2 doesn't work
535:
536: opt.on("--ignore-case", "-C",
537: "The case of names of classes or modules",
538: "or methods are ignored.") do |value|
539: @ignore_case = true
540: end
541: end
542:
543: argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
544:
545: opts.parse! argv
546:
547: @files = argv.dup
548:
549: @rdoc_include << "." if @rdoc_include.empty?
550:
551: if @exclude.empty? then
552: @exclude = nil
553: else
554: @exclude = Regexp.new(@exclude.join("|"))
555: end
556:
557: check_files
558:
559: # If no template was specified, use the default template for the output
560: # formatter
561:
562: @template ||= @generator_name
563:
564: # Generate a regexp from the accessors
565: unless accessors.empty? then
566: re = '^(' + accessors.map { |a| Regexp.quote a }.join('|') + ')$'
567: @extra_accessors = Regexp.new re
568: end
569:
570: rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
571: puts opts
572: puts
573: puts e
574: exit 1
575: end
Don‘t display progress as we process the files
# File options.rb, line 615
615: def quiet
616: @verbosity.zero?
617: end
Don‘t display progress as we process the files
# File doc-tmp/rdoc/options.rb, line 615
615: def quiet
616: @verbosity.zero?
617: end
# File doc-tmp/rdoc/options.rb, line 619
619: def quiet=(bool)
620: @verbosity = bool ? 0 : 1
621: end
Return relative path
# File options.rb, line 723
723: def relative_str(from, target)
724: from_dir = File.dirname(from)
725: target_dir = File.dirname(target)
726: target_base = File.basename(target)
727:
728: from_ab_path = Pathname.new(File.expand_path(from_dir))
729: target_ab_path = Pathname.new(File.expand_path(target_dir))
730:
731: target_re_path = target_ab_path.relative_path_from(from_ab_path)
732:
733: result = target_re_path.to_s + "/" + target_base
734:
735: return result
736: end
Return relative path
# File doc-tmp/rdoc/options.rb, line 723
723: def relative_str(from, target)
724: from_dir = File.dirname(from)
725: target_dir = File.dirname(target)
726: target_base = File.basename(target)
727:
728: from_ab_path = Pathname.new(File.expand_path(from_dir))
729: target_ab_path = Pathname.new(File.expand_path(target_dir))
730:
731: target_re_path = target_ab_path.relative_path_from(from_ab_path)
732:
733: result = target_re_path.to_s + "/" + target_base
734:
735: return result
736: end
Set up an output generator for the format in @generator_name
# File doc-tmp/rdoc/options.rb, line 628
628: def setup_generator
629: @generator = @generators[@generator_name]
630:
631: unless @generator then
632: raise OptionParser::InvalidArgument, "Invalid output formatter"
633: end
634:
635: if @generator_name == "xml" then
636: @all_one_file = true
637: @inline_source = true
638: end
639: end
Set up an output generator for the format in @generator_name
# File options.rb, line 628
628: def setup_generator
629: @generator = @generators[@generator_name]
630:
631: unless @generator then
632: raise OptionParser::InvalidArgument, "Invalid output formatter"
633: end
634:
635: if @generator_name == "xml" then
636: @all_one_file = true
637: @inline_source = true
638: end
639: end
Set the title, but only if not already set. This means that a title set from the command line trumps one set in a source file
# File options.rb, line 608
608: def title=(string)
609: @title ||= string
610: end