Class: Options
Defined Under Namespace
Modules: OptionList
Instance Attribute Summary collapse
-
#all_one_file ⇒ Object
readonly
should the output be placed into a single file.
-
#charset ⇒ Object
readonly
character-set.
-
#css ⇒ Object
readonly
URL of stylesheet.
-
#diagram ⇒ Object
readonly
should diagrams be drawn.
-
#exclude ⇒ Object
files matching this pattern will be excluded.
-
#extra_accessor_flags ⇒ Object
readonly
Returns the value of attribute extra_accessor_flags.
-
#extra_accessors ⇒ Object
readonly
pattern for additional attr_...
-
#fileboxes ⇒ Object
readonly
should we draw fileboxes in diagrams.
-
#files ⇒ Object
readonly
and the list of files to be processed.
-
#force_update ⇒ Object
readonly
scan newer sources than the flag file if true.
-
#generator ⇒ Object
description of the output generator (set with the
-fmt
option. -
#image_format ⇒ Object
readonly
image format for diagrams.
-
#include_line_numbers ⇒ Object
readonly
include line numbers in the source listings.
-
#inline_source ⇒ Object
readonly
should source code be included inline, or displayed in a popup.
-
#main_page ⇒ Object
name of the file, class or module to display in the initial index page (if not specified the first file we encounter is used).
-
#merge ⇒ Object
readonly
merge into classes of the name name when generating ri.
-
#op_dir ⇒ Object
the name of the output directory.
-
#op_name ⇒ Object
readonly
the name to use for the output.
-
#promiscuous ⇒ Object
readonly
Are we promiscuous about showing module contents across multiple files.
-
#quiet ⇒ Object
readonly
Don't display progress as we process the files.
-
#rdoc_include ⇒ Object
readonly
array of directories to search for files to satisfy an :include:.
-
#show_all ⇒ Object
include private and protected methods in the output.
-
#show_hash ⇒ Object
readonly
include the '#' at the front of hyperlinked instance method names.
-
#tab_width ⇒ Object
readonly
the number of columns in a tab.
-
#template ⇒ Object
readonly
template to be used when generating output.
-
#webcvs ⇒ Object
readonly
URL of web cvs frontend.
Instance Method Summary collapse
-
#parse(argv, generators) ⇒ Object
Parse command line options.
- #title ⇒ Object
-
#title=(string) ⇒ Object
Set the title, but only if not already set.
Instance Attribute Details
#all_one_file ⇒ Object (readonly)
should the output be placed into a single file
72 73 74 |
# File 'lib/rdoc/options.rb', line 72 def all_one_file @all_one_file end |
#charset ⇒ Object (readonly)
character-set
66 67 68 |
# File 'lib/rdoc/options.rb', line 66 def charset @charset end |
#css ⇒ Object (readonly)
URL of stylesheet
85 86 87 |
# File 'lib/rdoc/options.rb', line 85 def css @css end |
#diagram ⇒ Object (readonly)
should diagrams be drawn
54 55 56 |
# File 'lib/rdoc/options.rb', line 54 def diagram @diagram end |
#exclude ⇒ Object
files matching this pattern will be excluded
14 15 16 |
# File 'lib/rdoc/options.rb', line 14 def exclude @exclude end |
#extra_accessor_flags ⇒ Object (readonly)
Returns the value of attribute extra_accessor_flags
82 83 84 |
# File 'lib/rdoc/options.rb', line 82 def extra_accessor_flags @extra_accessor_flags end |
#extra_accessors ⇒ Object (readonly)
pattern for additional attr_... style methods
81 82 83 |
# File 'lib/rdoc/options.rb', line 81 def extra_accessors @extra_accessors end |
#fileboxes ⇒ Object (readonly)
should we draw fileboxes in diagrams
57 58 59 |
# File 'lib/rdoc/options.rb', line 57 def fileboxes @fileboxes end |
#files ⇒ Object (readonly)
and the list of files to be processed
42 43 44 |
# File 'lib/rdoc/options.rb', line 42 def files @files end |
#force_update ⇒ Object (readonly)
scan newer sources than the flag file if true.
95 96 97 |
# File 'lib/rdoc/options.rb', line 95 def force_update @force_update end |
#generator ⇒ Object
description of the output generator (set with the -fmt
option
39 40 41 |
# File 'lib/rdoc/options.rb', line 39 def generator @generator end |
#image_format ⇒ Object (readonly)
image format for diagrams
63 64 65 |
# File 'lib/rdoc/options.rb', line 63 def image_format @image_format end |
#include_line_numbers ⇒ Object (readonly)
include line numbers in the source listings
78 79 80 |
# File 'lib/rdoc/options.rb', line 78 def include_line_numbers @include_line_numbers end |
#inline_source ⇒ Object (readonly)
should source code be included inline, or displayed in a popup
69 70 71 |
# File 'lib/rdoc/options.rb', line 69 def inline_source @inline_source end |
#main_page ⇒ Object
name of the file, class or module to display in the initial index page (if not specified the first file we encounter is used)
29 30 31 |
# File 'lib/rdoc/options.rb', line 29 def main_page @main_page end |
#merge ⇒ Object (readonly)
merge into classes of the name name when generating ri
32 33 34 |
# File 'lib/rdoc/options.rb', line 32 def merge @merge end |
#op_dir ⇒ Object
the name of the output directory
17 18 19 |
# File 'lib/rdoc/options.rb', line 17 def op_dir @op_dir end |
#op_name ⇒ Object (readonly)
the name to use for the output
20 21 22 |
# File 'lib/rdoc/options.rb', line 20 def op_name @op_name end |
#promiscuous ⇒ Object (readonly)
Are we promiscuous about showing module contents across multiple files
92 93 94 |
# File 'lib/rdoc/options.rb', line 92 def promiscuous @promiscuous end |
#quiet ⇒ Object (readonly)
Don't display progress as we process the files
35 36 37 |
# File 'lib/rdoc/options.rb', line 35 def quiet @quiet end |
#rdoc_include ⇒ Object (readonly)
array of directories to search for files to satisfy an :include:
45 46 47 |
# File 'lib/rdoc/options.rb', line 45 def rdoc_include @rdoc_include end |
#show_all ⇒ Object
include private and protected methods in the output
24 25 26 |
# File 'lib/rdoc/options.rb', line 24 def show_all @show_all end |
#show_hash ⇒ Object (readonly)
include the '#' at the front of hyperlinked instance method names
60 61 62 |
# File 'lib/rdoc/options.rb', line 60 def show_hash @show_hash end |
#tab_width ⇒ Object (readonly)
the number of columns in a tab
75 76 77 |
# File 'lib/rdoc/options.rb', line 75 def tab_width @tab_width end |
#template ⇒ Object (readonly)
template to be used when generating output
51 52 53 |
# File 'lib/rdoc/options.rb', line 51 def template @template end |
#webcvs ⇒ Object (readonly)
URL of web cvs frontend
88 89 90 |
# File 'lib/rdoc/options.rb', line 88 def webcvs @webcvs end |
Instance Method Details
#parse(argv, generators) ⇒ Object
Parse command line options. We're passed a hash containing output generators, keyed by the generator name
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/rdoc/options.rb', line 347 def parse(argv, generators) old_argv = ARGV.dup begin ARGV.replace(argv) @op_dir = "doc" @op_name = nil @show_all = false @main_page = nil @marge = false @exclude = [] @quiet = false @generator_name = 'html' @generator = generators[@generator_name] @rdoc_include = [] @title = nil @template = nil @diagram = false @fileboxes = false @show_hash = false @image_format = 'png' @inline_source = false @all_one_file = false @tab_width = 8 @include_line_numbers = false @extra_accessor_flags = {} @promiscuous = false @force_update = false @css = nil @webcvs = nil @charset = case $KCODE when /^S/i 'Shift_JIS' when /^E/i 'EUC-JP' else 'iso-8859-1' end accessors = [] go = GetoptLong.new(*OptionList.) go.quiet = true go.each do |opt, arg| case opt when "--all" then @show_all = true when "--charset" then @charset = arg when "--debug" then $DEBUG = true when "--exclude" then @exclude << Regexp.new(arg) when "--inline-source" then @inline_source = true when "--line-numbers" then @include_line_numbers = true when "--main" then @main_page = arg when "--merge" then @merge = true when "--one-file" then @all_one_file = @inline_source = true when "--op" then @op_dir = arg when "--opname" then @op_name = arg when "--promiscuous" then @promiscuous = true when "--quiet" then @quiet = true when "--show-hash" then @show_hash = true when "--style" then @css = arg when "--template" then @template = arg when "--title" then @title = arg when "--webcvs" then @webcvs = arg when "--accessor" arg.split(/,/).each do |accessor| if accessor =~ /^(\w+)(=(.*))?$/ accessors << $1 @extra_accessor_flags[$1] = $3 end end when "--diagram" check_diagram @diagram = true when "--fileboxes" @fileboxes = true if @diagram when "--fmt" @generator_name = arg.downcase setup_generator(generators) when "--help" OptionList.usage(generators.keys) when "--help-output" OptionList.help_output when "--image-format" if ['gif', 'png', 'jpeg', 'jpg'].include?(arg) @image_format = arg else raise GetoptLong::InvalidOption.new("unknown image format: #{arg}") end when "--include" @rdoc_include.concat arg.split(/\s*,\s*/) when "--ri", "--ri-site", "--ri-system" @generator_name = "ri" @op_dir = case opt when "--ri" then RI::Paths::HOMEDIR when "--ri-site" then RI::Paths::SITEDIR when "--ri-system" then RI::Paths::SYSDIR else fail opt end setup_generator(generators) when "--tab-width" begin @tab_width = Integer(arg) rescue $stderr.puts "Invalid tab width: '#{arg}'" exit 1 end when "--extension" new, old = arg.split(/=/, 2) OptionList.error("Invalid parameter to '-E'") unless new && old unless RDoc::ParserFactory.alias_extension(old, new) OptionList.error("Unknown extension .#{old} to -E") end when "--force-update" @force_update = true when "--version" puts VERSION_STRING exit end end @files = ARGV.dup @rdoc_include << "." if @rdoc_include.empty? if @exclude.empty? @exclude = nil else @exclude = Regexp.new(@exclude.join("|")) end check_files # If no template was specified, use the default # template for the output formatter @template ||= @generator_name # Generate a regexp from the accessors unless accessors.empty? re = '^(' + accessors.map{|a| Regexp.quote(a)}.join('|') + ')$' @extra_accessors = Regexp.new(re) end rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error OptionList.error(error.) ensure ARGV.replace(old_argv) end end |
#title ⇒ Object
515 516 517 |
# File 'lib/rdoc/options.rb', line 515 def title @title ||= "RDoc Documentation" end |
#title=(string) ⇒ Object
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
522 523 524 |
# File 'lib/rdoc/options.rb', line 522 def title=(string) @title ||= string end |