Class | RDoc::Options |
In: |
options.rb
doc-tmp/rdoc/options.rb |
Parent: | Object |
Check that the right version of ‘dot’ is available. Unfortuately this doesn‘t work correctly under Windows NT, so we‘ll bypass the test under Windows.
# File options.rb, line 625 625: def check_diagram 626: return if RUBY_PLATFORM =~ /mswin|cygwin|mingw|bccwin/ 627: 628: ok = false 629: ver = nil 630: 631: IO.popen "dot -V 2>&1" do |io| 632: ver = io.read 633: if ver =~ /dot.+version(?:\s+gviz)?\s+(\d+)\.(\d+)/ then 634: ok = ($1.to_i > 1) || ($1.to_i == 1 && $2.to_i >= 8) 635: end 636: end 637: 638: unless ok then 639: if ver =~ /^dot.+version/ then 640: $stderr.puts "Warning: You may need dot V1.8.6 or later to use\n", 641: "the --diagram option correctly. You have:\n\n ", 642: ver, 643: "\nDiagrams might have strange background colors.\n\n" 644: else 645: $stderr.puts "You need the 'dot' program to produce diagrams.", 646: "(see http://www.research.att.com/sw/tools/graphviz/)\n\n" 647: exit 648: end 649: end 650: end
Check that the right version of ‘dot’ is available. Unfortuately this doesn‘t work correctly under Windows NT, so we‘ll bypass the test under Windows.
# File doc-tmp/rdoc/options.rb, line 625 625: def check_diagram 626: return if RUBY_PLATFORM =~ /mswin|cygwin|mingw|bccwin/ 627: 628: ok = false 629: ver = nil 630: 631: IO.popen "dot -V 2>&1" do |io| 632: ver = io.read 633: if ver =~ /dot.+version(?:\s+gviz)?\s+(\d+)\.(\d+)/ then 634: ok = ($1.to_i > 1) || ($1.to_i == 1 && $2.to_i >= 8) 635: end 636: end 637: 638: unless ok then 639: if ver =~ /^dot.+version/ then 640: $stderr.puts "Warning: You may need dot V1.8.6 or later to use\n", 641: "the --diagram option correctly. You have:\n\n ", 642: ver, 643: "\nDiagrams might have strange background colors.\n\n" 644: else 645: $stderr.puts "You need the 'dot' program to produce diagrams.", 646: "(see http://www.research.att.com/sw/tools/graphviz/)\n\n" 647: exit 648: end 649: end 650: end
Check that the files on the command line exist
# File doc-tmp/rdoc/options.rb, line 721 721: def check_files 722: @files.each do |f| 723: stat = File.stat f rescue abort("File not found: #{f}") 724: abort("File '#{f}' not readable") unless stat.readable? 725: end 726: end
Check that the files on the command line exist
# File options.rb, line 721 721: def check_files 722: @files.each do |f| 723: stat = File.stat f rescue abort("File not found: #{f}") 724: abort("File '#{f}' not readable") unless stat.readable? 725: end 726: end
Check that the right version of ‘mathml.rb’ is available.
# File options.rb, line 655 655: def check_mathml 656: not_found = true 657: fpath = "" 658: $LOAD_PATH.each{ |lpath| 659: ["mathml.rb", "math_ml.rb"].each { |ml| 660: fpath = File.join(lpath, ml) 661: if File.exist?(fpath) 662: not_found = false 663: break 664: end 665: } 666: break unless not_found 667: } 668: 669: if not_found 670: $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" 671: exit 672: end 673: 674: contents = File.open(fpath, "r") {|f| f.read} 675: num = 1 676: if !(contents =~ /^\s*module\s+MathML/) || 677: !(contents =~ /^\s*module\s+LaTeX/) || 678: !(contents =~ /^\s*class\s+Parser/) || 679: !(contents =~ /^\s*def\s+parse/) 680: $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" 681: 682: exit 683: end 684: end
Check that the right version of ‘mathml.rb’ is available.
# File doc-tmp/rdoc/options.rb, line 655 655: def check_mathml 656: not_found = true 657: fpath = "" 658: $LOAD_PATH.each{ |lpath| 659: ["mathml.rb", "math_ml.rb"].each { |ml| 660: fpath = File.join(lpath, ml) 661: if File.exist?(fpath) 662: not_found = false 663: break 664: end 665: } 666: break unless not_found 667: } 668: 669: if not_found 670: $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" 671: exit 672: end 673: 674: contents = File.open(fpath, "r") {|f| f.read} 675: num = 1 676: if !(contents =~ /^\s*module\s+MathML/) || 677: !(contents =~ /^\s*module\s+LaTeX/) || 678: !(contents =~ /^\s*class\s+Parser/) || 679: !(contents =~ /^\s*def\s+parse/) 680: $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" 681: 682: exit 683: end 684: end
Parse command line options.
# File doc-tmp/rdoc/options.rb, line 201 201: def parse(argv) 202: accessors = [] 203: 204: opt = OptionParser.new do |opt| 205: opt.program_name = File.basename $0 206: # opt.version = RDoc::VERSION 207: opt.version = VERSION_STRING 208: opt.summary_indent = ' ' * 4 209: 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" 210: 211: # opt.separator nil # 1.8.2 doesn't work 212: opt.separator "Options:" 213: # opt.separator nil # 1.8.2 doesn't work 214: 215: opt.on("--accessor=ACCESSORS", "-A", Array, 216: "A comma separated list of additional class", 217: "methods that should be treated like", 218: "'attr_reader' and friends.", 219: " ", 220: "Option may be repeated.", 221: " ", 222: "Each accessorname may have '=text'", 223: "appended, in which case that text appears", 224: "where the r/w/rw appears for normal.", 225: "accessors") do |value| 226: value.each do |accessor| 227: if accessor =~ /^(\w+)(=(.*))?$/ 228: accessors << $1 229: @extra_accessor_flags[$1] = $3 230: end 231: end 232: end 233: 234: # opt.separator nil # 1.8.2 doesn't work 235: 236: opt.on("--all", "-a", 237: "Include all methods (not just public) in", 238: "the output.") do |value| 239: @show_all = value 240: end 241: 242: # opt.separator nil # 1.8.2 doesn't work 243: 244: opt.on("--charset=CHARSET", "-c", 245: "Specifies the HTML character-set.") do |value| 246: @charset = value 247: end 248: 249: # opt.separator nil # 1.8.2 doesn't work 250: 251: opt.on("--debug", "-D", 252: "Displays lots on internal stuff.") do |value| 253: $DEBUG_RDOC = value 254: end 255: 256: # opt.separator nil # 1.8.2 doesn't work 257: 258: opt.on("--diagram", "-d", 259: "Generate diagrams showing modules and", 260: "classes. You need dot V1.8.6 or later to", 261: "use the --diagram option correctly. Dot is", 262: "available from http://graphviz.org") do |value| 263: check_diagram 264: @diagram = true 265: end 266: 267: # opt.separator nil # 1.8.2 doesn't work 268: 269: opt.on("--exclude=PATTERN", "-x", Regexp, 270: "Do not process files or directories", 271: "matching PATTERN. Files given explicitly", 272: "on the command line will never be", 273: "excluded.") do |value| 274: @exclude << value 275: end 276: 277: # opt.separator nil # 1.8.2 doesn't work 278: 279: opt.on("--extension=NEW=OLD", "-E", 280: "Treat files ending with .new as if they", 281: "ended with .old. Using '-E cgi=rb' will", 282: "cause xxx.cgi to be parsed as a Ruby file.") do |value| 283: new, old = value.split(/=/, 2) 284: 285: unless new and old then 286: raise OptionParser::InvalidArgument, "Invalid parameter to '-E'" 287: end 288: 289: unless RDoc::ParserFactory.alias_extension old, new then 290: raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E" 291: end 292: end 293: 294: # opt.separator nil # 1.8.2 doesn't work 295: 296: opt.on("--fileboxes", "-F", 297: "Classes are put in boxes which represents", 298: "files, where these classes reside. Classes", 299: "shared between more than one file are", 300: "shown with list of files that are sharing", 301: "them. Silently discarded if --diagram is", 302: "not given.") do |value| 303: @fileboxes = value 304: end 305: 306: # opt.separator nil # 1.8.2 doesn't work 307: 308: opt.on("--force-update", "-U", 309: "Forces rdoc to scan all sources even if", 310: "newer than the flag file.") do |value| 311: @force_update = value 312: end 313: 314: # opt.separator nil # 1.8.2 doesn't work 315: 316: opt.on("--fmt=FORMAT", "--format=FORMAT", "-f", @generators.keys, 317: "Set the output formatter.") do |value| 318: @generator_name = value.downcase 319: setup_generator 320: end 321: 322: # opt.separator nil # 1.8.2 doesn't work 323: 324: image_formats = %w[gif png jpg jpeg] 325: opt.on("--image-format=FORMAT", "-I", image_formats, 326: "Sets output image format for diagrams. Can", 327: "be #{image_formats.join ', '}. If this option", 328: "is omitted, png is used. Requires", 329: "diagrams.") do |value| 330: @image_format = value 331: end 332: 333: # opt.separator nil # 1.8.2 doesn't work 334: 335: opt.on("--include=DIRECTORIES", "-i", Array, 336: "set (or add to) the list of directories to", 337: "be searched when satisfying :include:", 338: "requests. Can be used more than once.") do |value| 339: @rdoc_include.concat value.map { |dir| dir.strip } 340: end 341: 342: # opt.separator nil # 1.8.2 doesn't work 343: 344: opt.on("--inline-source", "-S", 345: "Show method source code inline, rather than", 346: "via a popup link.") do |value| 347: @inline_source = value 348: end 349: 350: # opt.separator nil # 1.8.2 doesn't work 351: 352: opt.on("--line-numbers", "-N", 353: "Include line numbers in the source code.") do |value| 354: @include_line_numbers = value 355: end 356: 357: # opt.separator nil # 1.8.2 doesn't work 358: 359: opt.on("--main=NAME", "-m", 360: "NAME will be the initial page displayed.") do |value| 361: @main_page = value 362: end 363: 364: # opt.separator nil # 1.8.2 doesn't work 365: 366: opt.on("--merge", "-M", 367: "When creating ri output, merge previously", 368: "processed classes into previously", 369: "documented classes of the same name.") do |value| 370: @merge = value 371: end 372: 373: # opt.separator nil # 1.8.2 doesn't work 374: 375: opt.on("--one-file", "-1", 376: "Put all the output into a single file.") do |value| 377: @all_one_file = value 378: @inline_source = value if value 379: @template = 'one_page_html' 380: end 381: 382: # opt.separator nil # 1.8.2 doesn't work 383: 384: opt.on("--op=DIR", "-o", 385: "Set the output directory.") do |value| 386: if @css && ! (%r{^(https?:/)?/} =~ @css) 387: @css = relative_str(File.join(value, "."), 388: relative_str(File.join(@op_dir.split("/").fill(".."), ".."), @css)) 389: end 390: @op_dir = value 391: end 392: 393: # opt.separator nil # 1.8.2 doesn't work 394: 395: opt.on("--opname=NAME", "-n", 396: "Set the NAME of the output. Has no effect", 397: "for HTML.") do |value| 398: @op_name = value 399: end 400: 401: # opt.separator nil # 1.8.2 doesn't work 402: 403: opt.on("--promiscuous", "-p", 404: "When documenting a file that contains a", 405: "module or class also defined in other", 406: "files, show all stuff for that module or", 407: "class in each files page. By default, only", 408: "show stuff defined in that particular file.") do |value| 409: @promiscuous = value 410: end 411: 412: # opt.separator nil # 1.8.2 doesn't work 413: 414: opt.on("--quiet", "-q", 415: "Don't show progress as we parse.") do |value| 416: @quiet = value 417: end 418: 419: # opt.separator nil # 1.8.2 doesn't work 420: 421: opt.on("--ri", "-r", 422: "Generate output for use by `ri`. The files", 423: "are stored in the '.rdoc' directory under", 424: "your home directory unless overridden by a", 425: "subsequent --op parameter, so no special", 426: "privileges are needed.") do |value| 427: @generator_name = "ri" 428: @op_dir = RDoc::RI::Paths::HOMEDIR 429: setup_generator 430: end 431: 432: # opt.separator nil # 1.8.2 doesn't work 433: 434: opt.on("--ri-site", "-R", 435: "Generate output for use by `ri`. The files", 436: "are stored in a site-wide directory,", 437: "making them accessible to others, so", 438: "special privileges are needed.") do |value| 439: @generator_name = "ri" 440: @op_dir = RDoc::RI::Paths::SITEDIR 441: setup_generator 442: end 443: 444: # opt.separator nil # 1.8.2 doesn't work 445: 446: opt.on("--ri-system", "-Y", 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. This", 451: "option is intended to be used during Ruby", 452: "installation.") do |value| 453: @generator_name = "ri" 454: @op_dir = RDoc::RI::Paths::SYSDIR 455: setup_generator 456: end 457: 458: # opt.separator nil # 1.8.2 doesn't work 459: 460: opt.on("--show-hash", "-H", 461: "A name of the form #name in a comment is a", 462: "possible hyperlink to an instance method", 463: "name. When displayed, the '#' is removed", 464: "unless this option is specified.") do |value| 465: @show_hash = value 466: end 467: 468: # opt.separator nil # 1.8.2 doesn't work 469: 470: opt.on("--style=URL", "-s", 471: "Specifies the URL of a separate stylesheet.") do |value| 472: if %r{^(https?:/)?/} =~ value 473: @css = value 474: else 475: @css = relative_str(File.join(@op_dir, "."), value) 476: end 477: end 478: 479: # opt.separator nil # 1.8.2 doesn't work 480: 481: opt.on("--tab-width=WIDTH", "-w", OptionParser::DecimalInteger, 482: "Set the width of tab characters.") do |value| 483: @tab_width = value 484: end 485: 486: # opt.separator nil # 1.8.2 doesn't work 487: 488: opt.on("--template=NAME", "-T", 489: "Set the template used when generating", 490: "output.") do |value| 491: @template = value 492: end 493: 494: # opt.separator nil # 1.8.2 doesn't work 495: 496: opt.on("--title=TITLE", "-t", 497: "Set TITLE as the title for HTML output.") do |value| 498: @title = value 499: end 500: 501: # opt.separator nil # 1.8.2 doesn't work 502: 503: opt.on("--webcvs=URL", "-W", 504: "Specify a URL for linking to a web frontend", 505: "to CVS. If the URL contains a '\%s', the", 506: "name of the current file will be", 507: "substituted; if the URL doesn't contain a", 508: "'\%s', the filename will be appended to it.") do |value| 509: @webcvs = value 510: end 511: 512: # opt.separator nil # 1.8.2 doesn't work 513: 514: opt.on("--mathml", "-l", 515: "TeX formatted formula is converted to MathML.", 516: "You need mathml.rb V0.8 or later to use the --mathml", 517: "option correctly. mathml.rb V0.8 is available from", 518: "http://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz") do |value| 519: check_mathml 520: @mathml = true 521: @generator_name = 'xhtml' 522: @template = @generator_name 523: setup_generator 524: end 525: 526: # opt.separator nil # 1.8.2 doesn't work 527: 528: opt.on("--ignore-case", "-C", 529: "The case of names of classes or modules", 530: "or methods are ignored.") do |value| 531: @ignore_case = true 532: end 533: end 534: 535: opt.parse! argv 536: 537: @files = argv.dup 538: 539: @rdoc_include << "." if @rdoc_include.empty? 540: 541: if @exclude.empty? then 542: @exclude = nil 543: else 544: @exclude = Regexp.new(@exclude.join("|")) 545: end 546: 547: check_files 548: 549: # If no template was specified, use the default template for the output 550: # formatter 551: 552: @template ||= @generator_name 553: 554: # Generate a regexp from the accessors 555: unless accessors.empty? then 556: re = '^(' + accessors.map { |a| Regexp.quote a }.join('|') + ')$' 557: @extra_accessors = Regexp.new re 558: end 559: 560: rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e 561: puts opt 562: puts 563: puts e 564: exit 1 565: 566: end
Parse command line options.
# File options.rb, line 201 201: def parse(argv) 202: accessors = [] 203: 204: opt = OptionParser.new do |opt| 205: opt.program_name = File.basename $0 206: # opt.version = RDoc::VERSION 207: opt.version = VERSION_STRING 208: opt.summary_indent = ' ' * 4 209: 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" 210: 211: # opt.separator nil # 1.8.2 doesn't work 212: opt.separator "Options:" 213: # opt.separator nil # 1.8.2 doesn't work 214: 215: opt.on("--accessor=ACCESSORS", "-A", Array, 216: "A comma separated list of additional class", 217: "methods that should be treated like", 218: "'attr_reader' and friends.", 219: " ", 220: "Option may be repeated.", 221: " ", 222: "Each accessorname may have '=text'", 223: "appended, in which case that text appears", 224: "where the r/w/rw appears for normal.", 225: "accessors") do |value| 226: value.each do |accessor| 227: if accessor =~ /^(\w+)(=(.*))?$/ 228: accessors << $1 229: @extra_accessor_flags[$1] = $3 230: end 231: end 232: end 233: 234: # opt.separator nil # 1.8.2 doesn't work 235: 236: opt.on("--all", "-a", 237: "Include all methods (not just public) in", 238: "the output.") do |value| 239: @show_all = value 240: end 241: 242: # opt.separator nil # 1.8.2 doesn't work 243: 244: opt.on("--charset=CHARSET", "-c", 245: "Specifies the HTML character-set.") do |value| 246: @charset = value 247: end 248: 249: # opt.separator nil # 1.8.2 doesn't work 250: 251: opt.on("--debug", "-D", 252: "Displays lots on internal stuff.") do |value| 253: $DEBUG_RDOC = value 254: end 255: 256: # opt.separator nil # 1.8.2 doesn't work 257: 258: opt.on("--diagram", "-d", 259: "Generate diagrams showing modules and", 260: "classes. You need dot V1.8.6 or later to", 261: "use the --diagram option correctly. Dot is", 262: "available from http://graphviz.org") do |value| 263: check_diagram 264: @diagram = true 265: end 266: 267: # opt.separator nil # 1.8.2 doesn't work 268: 269: opt.on("--exclude=PATTERN", "-x", Regexp, 270: "Do not process files or directories", 271: "matching PATTERN. Files given explicitly", 272: "on the command line will never be", 273: "excluded.") do |value| 274: @exclude << value 275: end 276: 277: # opt.separator nil # 1.8.2 doesn't work 278: 279: opt.on("--extension=NEW=OLD", "-E", 280: "Treat files ending with .new as if they", 281: "ended with .old. Using '-E cgi=rb' will", 282: "cause xxx.cgi to be parsed as a Ruby file.") do |value| 283: new, old = value.split(/=/, 2) 284: 285: unless new and old then 286: raise OptionParser::InvalidArgument, "Invalid parameter to '-E'" 287: end 288: 289: unless RDoc::ParserFactory.alias_extension old, new then 290: raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E" 291: end 292: end 293: 294: # opt.separator nil # 1.8.2 doesn't work 295: 296: opt.on("--fileboxes", "-F", 297: "Classes are put in boxes which represents", 298: "files, where these classes reside. Classes", 299: "shared between more than one file are", 300: "shown with list of files that are sharing", 301: "them. Silently discarded if --diagram is", 302: "not given.") do |value| 303: @fileboxes = value 304: end 305: 306: # opt.separator nil # 1.8.2 doesn't work 307: 308: opt.on("--force-update", "-U", 309: "Forces rdoc to scan all sources even if", 310: "newer than the flag file.") do |value| 311: @force_update = value 312: end 313: 314: # opt.separator nil # 1.8.2 doesn't work 315: 316: opt.on("--fmt=FORMAT", "--format=FORMAT", "-f", @generators.keys, 317: "Set the output formatter.") do |value| 318: @generator_name = value.downcase 319: setup_generator 320: end 321: 322: # opt.separator nil # 1.8.2 doesn't work 323: 324: image_formats = %w[gif png jpg jpeg] 325: opt.on("--image-format=FORMAT", "-I", image_formats, 326: "Sets output image format for diagrams. Can", 327: "be #{image_formats.join ', '}. If this option", 328: "is omitted, png is used. Requires", 329: "diagrams.") do |value| 330: @image_format = value 331: end 332: 333: # opt.separator nil # 1.8.2 doesn't work 334: 335: opt.on("--include=DIRECTORIES", "-i", Array, 336: "set (or add to) the list of directories to", 337: "be searched when satisfying :include:", 338: "requests. Can be used more than once.") do |value| 339: @rdoc_include.concat value.map { |dir| dir.strip } 340: end 341: 342: # opt.separator nil # 1.8.2 doesn't work 343: 344: opt.on("--inline-source", "-S", 345: "Show method source code inline, rather than", 346: "via a popup link.") do |value| 347: @inline_source = value 348: end 349: 350: # opt.separator nil # 1.8.2 doesn't work 351: 352: opt.on("--line-numbers", "-N", 353: "Include line numbers in the source code.") do |value| 354: @include_line_numbers = value 355: end 356: 357: # opt.separator nil # 1.8.2 doesn't work 358: 359: opt.on("--main=NAME", "-m", 360: "NAME will be the initial page displayed.") do |value| 361: @main_page = value 362: end 363: 364: # opt.separator nil # 1.8.2 doesn't work 365: 366: opt.on("--merge", "-M", 367: "When creating ri output, merge previously", 368: "processed classes into previously", 369: "documented classes of the same name.") do |value| 370: @merge = value 371: end 372: 373: # opt.separator nil # 1.8.2 doesn't work 374: 375: opt.on("--one-file", "-1", 376: "Put all the output into a single file.") do |value| 377: @all_one_file = value 378: @inline_source = value if value 379: @template = 'one_page_html' 380: end 381: 382: # opt.separator nil # 1.8.2 doesn't work 383: 384: opt.on("--op=DIR", "-o", 385: "Set the output directory.") do |value| 386: if @css && ! (%r{^(https?:/)?/} =~ @css) 387: @css = relative_str(File.join(value, "."), 388: relative_str(File.join(@op_dir.split("/").fill(".."), ".."), @css)) 389: end 390: @op_dir = value 391: end 392: 393: # opt.separator nil # 1.8.2 doesn't work 394: 395: opt.on("--opname=NAME", "-n", 396: "Set the NAME of the output. Has no effect", 397: "for HTML.") do |value| 398: @op_name = value 399: end 400: 401: # opt.separator nil # 1.8.2 doesn't work 402: 403: opt.on("--promiscuous", "-p", 404: "When documenting a file that contains a", 405: "module or class also defined in other", 406: "files, show all stuff for that module or", 407: "class in each files page. By default, only", 408: "show stuff defined in that particular file.") do |value| 409: @promiscuous = value 410: end 411: 412: # opt.separator nil # 1.8.2 doesn't work 413: 414: opt.on("--quiet", "-q", 415: "Don't show progress as we parse.") do |value| 416: @quiet = value 417: end 418: 419: # opt.separator nil # 1.8.2 doesn't work 420: 421: opt.on("--ri", "-r", 422: "Generate output for use by `ri`. The files", 423: "are stored in the '.rdoc' directory under", 424: "your home directory unless overridden by a", 425: "subsequent --op parameter, so no special", 426: "privileges are needed.") do |value| 427: @generator_name = "ri" 428: @op_dir = RDoc::RI::Paths::HOMEDIR 429: setup_generator 430: end 431: 432: # opt.separator nil # 1.8.2 doesn't work 433: 434: opt.on("--ri-site", "-R", 435: "Generate output for use by `ri`. The files", 436: "are stored in a site-wide directory,", 437: "making them accessible to others, so", 438: "special privileges are needed.") do |value| 439: @generator_name = "ri" 440: @op_dir = RDoc::RI::Paths::SITEDIR 441: setup_generator 442: end 443: 444: # opt.separator nil # 1.8.2 doesn't work 445: 446: opt.on("--ri-system", "-Y", 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. This", 451: "option is intended to be used during Ruby", 452: "installation.") do |value| 453: @generator_name = "ri" 454: @op_dir = RDoc::RI::Paths::SYSDIR 455: setup_generator 456: end 457: 458: # opt.separator nil # 1.8.2 doesn't work 459: 460: opt.on("--show-hash", "-H", 461: "A name of the form #name in a comment is a", 462: "possible hyperlink to an instance method", 463: "name. When displayed, the '#' is removed", 464: "unless this option is specified.") do |value| 465: @show_hash = value 466: end 467: 468: # opt.separator nil # 1.8.2 doesn't work 469: 470: opt.on("--style=URL", "-s", 471: "Specifies the URL of a separate stylesheet.") do |value| 472: if %r{^(https?:/)?/} =~ value 473: @css = value 474: else 475: @css = relative_str(File.join(@op_dir, "."), value) 476: end 477: end 478: 479: # opt.separator nil # 1.8.2 doesn't work 480: 481: opt.on("--tab-width=WIDTH", "-w", OptionParser::DecimalInteger, 482: "Set the width of tab characters.") do |value| 483: @tab_width = value 484: end 485: 486: # opt.separator nil # 1.8.2 doesn't work 487: 488: opt.on("--template=NAME", "-T", 489: "Set the template used when generating", 490: "output.") do |value| 491: @template = value 492: end 493: 494: # opt.separator nil # 1.8.2 doesn't work 495: 496: opt.on("--title=TITLE", "-t", 497: "Set TITLE as the title for HTML output.") do |value| 498: @title = value 499: end 500: 501: # opt.separator nil # 1.8.2 doesn't work 502: 503: opt.on("--webcvs=URL", "-W", 504: "Specify a URL for linking to a web frontend", 505: "to CVS. If the URL contains a '\%s', the", 506: "name of the current file will be", 507: "substituted; if the URL doesn't contain a", 508: "'\%s', the filename will be appended to it.") do |value| 509: @webcvs = value 510: end 511: 512: # opt.separator nil # 1.8.2 doesn't work 513: 514: opt.on("--mathml", "-l", 515: "TeX formatted formula is converted to MathML.", 516: "You need mathml.rb V0.8 or later to use the --mathml", 517: "option correctly. mathml.rb V0.8 is available from", 518: "http://www.hinet.mydns.jp/files/math_ml-0.8.0.tar.gz") do |value| 519: check_mathml 520: @mathml = true 521: @generator_name = 'xhtml' 522: @template = @generator_name 523: setup_generator 524: end 525: 526: # opt.separator nil # 1.8.2 doesn't work 527: 528: opt.on("--ignore-case", "-C", 529: "The case of names of classes or modules", 530: "or methods are ignored.") do |value| 531: @ignore_case = true 532: end 533: end 534: 535: opt.parse! argv 536: 537: @files = argv.dup 538: 539: @rdoc_include << "." if @rdoc_include.empty? 540: 541: if @exclude.empty? then 542: @exclude = nil 543: else 544: @exclude = Regexp.new(@exclude.join("|")) 545: end 546: 547: check_files 548: 549: # If no template was specified, use the default template for the output 550: # formatter 551: 552: @template ||= @generator_name 553: 554: # Generate a regexp from the accessors 555: unless accessors.empty? then 556: re = '^(' + accessors.map { |a| Regexp.quote a }.join('|') + ')$' 557: @extra_accessors = Regexp.new re 558: end 559: 560: rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e 561: puts opt 562: puts 563: puts e 564: exit 1 565: 566: end
Return relative path
# File doc-tmp/rdoc/options.rb, line 703 703: def relative_str(from, target) 704: from_dir = File.dirname(from) 705: target_dir = File.dirname(target) 706: target_base = File.basename(target) 707: 708: from_ab_path = Pathname.new(File.expand_path(from_dir)) 709: target_ab_path = Pathname.new(File.expand_path(target_dir)) 710: 711: target_re_path = target_ab_path.relative_path_from(from_ab_path) 712: 713: result = target_re_path.to_s + "/" + target_base 714: 715: return result 716: end
Return relative path
# File options.rb, line 703 703: def relative_str(from, target) 704: from_dir = File.dirname(from) 705: target_dir = File.dirname(target) 706: target_base = File.basename(target) 707: 708: from_ab_path = Pathname.new(File.expand_path(from_dir)) 709: target_ab_path = Pathname.new(File.expand_path(target_dir)) 710: 711: target_re_path = target_ab_path.relative_path_from(from_ab_path) 712: 713: result = target_re_path.to_s + "/" + target_base 714: 715: return result 716: end
Set up an output generator for the format in @generator_name
# File doc-tmp/rdoc/options.rb, line 608 608: def setup_generator 609: @generator = @generators[@generator_name] 610: 611: unless @generator then 612: raise OptionParser::InvalidArgument, "Invalid output formatter" 613: end 614: 615: if @generator_name == "xml" then 616: @all_one_file = true 617: @inline_source = true 618: end 619: end
Set up an output generator for the format in @generator_name
# File options.rb, line 608 608: def setup_generator 609: @generator = @generators[@generator_name] 610: 611: unless @generator then 612: raise OptionParser::InvalidArgument, "Invalid output formatter" 613: end 614: 615: if @generator_name == "xml" then 616: @all_one_file = true 617: @inline_source = true 618: end 619: 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 599 599: def title=(string) 600: @title ||= string 601: end