Class: Options
- Inherits:
-
Object
- Object
- Options
- Includes:
- Singleton
- Defined in:
- lib/testdoc/testdocoptions.rb
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.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#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
-fmtoption. -
#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.
-
#text ⇒ Object
readonly
merge into classes of the name name when generating ri.
- #title ⇒ Object
-
#webcvs ⇒ Object
readonly
URL of web cvs frontend.
Instance Method Summary collapse
-
#parse(argv, generators) ⇒ Object
Parse command line options.
Instance Attribute Details
#all_one_file ⇒ Object (readonly)
should the output be placed into a single file
81 82 83 |
# File 'lib/testdoc/testdocoptions.rb', line 81 def all_one_file @all_one_file end |
#charset ⇒ Object (readonly)
character-set
75 76 77 |
# File 'lib/testdoc/testdocoptions.rb', line 75 def charset @charset end |
#css ⇒ Object (readonly)
URL of stylesheet
94 95 96 |
# File 'lib/testdoc/testdocoptions.rb', line 94 def css @css end |
#debug ⇒ Object
Returns the value of attribute debug.
53 54 55 |
# File 'lib/testdoc/testdocoptions.rb', line 53 def debug @debug end |
#diagram ⇒ Object (readonly)
should diagrams be drawn
63 64 65 |
# File 'lib/testdoc/testdocoptions.rb', line 63 def diagram @diagram end |
#exclude ⇒ Object
files matching this pattern will be excluded
14 15 16 |
# File 'lib/testdoc/testdocoptions.rb', line 14 def exclude @exclude end |
#extra_accessor_flags ⇒ Object (readonly)
Returns the value of attribute extra_accessor_flags.
91 92 93 |
# File 'lib/testdoc/testdocoptions.rb', line 91 def extra_accessor_flags @extra_accessor_flags end |
#extra_accessors ⇒ Object (readonly)
pattern for additional attr_… style methods
90 91 92 |
# File 'lib/testdoc/testdocoptions.rb', line 90 def extra_accessors @extra_accessors end |
#fileboxes ⇒ Object (readonly)
should we draw fileboxes in diagrams
66 67 68 |
# File 'lib/testdoc/testdocoptions.rb', line 66 def fileboxes @fileboxes end |
#files ⇒ Object (readonly)
and the list of files to be processed
48 49 50 |
# File 'lib/testdoc/testdocoptions.rb', line 48 def files @files end |
#force_update ⇒ Object (readonly)
scan newer sources than the flag file if true.
104 105 106 |
# File 'lib/testdoc/testdocoptions.rb', line 104 def force_update @force_update end |
#generator ⇒ Object
description of the output generator (set with the -fmt option
45 46 47 |
# File 'lib/testdoc/testdocoptions.rb', line 45 def generator @generator end |
#image_format ⇒ Object (readonly)
image format for diagrams
72 73 74 |
# File 'lib/testdoc/testdocoptions.rb', line 72 def image_format @image_format end |
#include_line_numbers ⇒ Object (readonly)
include line numbers in the source listings
87 88 89 |
# File 'lib/testdoc/testdocoptions.rb', line 87 def include_line_numbers @include_line_numbers end |
#inline_source ⇒ Object (readonly)
should source code be included inline, or displayed in a popup
78 79 80 |
# File 'lib/testdoc/testdocoptions.rb', line 78 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/testdoc/testdocoptions.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/testdoc/testdocoptions.rb', line 32 def merge @merge end |
#op_dir ⇒ Object
the name of the output directory
17 18 19 |
# File 'lib/testdoc/testdocoptions.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/testdoc/testdocoptions.rb', line 20 def op_name @op_name end |
#promiscuous ⇒ Object (readonly)
Are we promiscuous about showing module contents across multiple files
101 102 103 |
# File 'lib/testdoc/testdocoptions.rb', line 101 def promiscuous @promiscuous end |
#quiet ⇒ Object (readonly)
Don’t display progress as we process the files
41 42 43 |
# File 'lib/testdoc/testdocoptions.rb', line 41 def quiet @quiet end |
#rdoc_include ⇒ Object (readonly)
array of directories to search for files to satisfy an :include:
51 52 53 |
# File 'lib/testdoc/testdocoptions.rb', line 51 def rdoc_include @rdoc_include end |
#show_all ⇒ Object
include private and protected methods in the output
24 25 26 |
# File 'lib/testdoc/testdocoptions.rb', line 24 def show_all @show_all end |
#show_hash ⇒ Object (readonly)
include the ‘#’ at the front of hyperlinked instance method names
69 70 71 |
# File 'lib/testdoc/testdocoptions.rb', line 69 def show_hash @show_hash end |
#tab_width ⇒ Object (readonly)
the number of columns in a tab
84 85 86 |
# File 'lib/testdoc/testdocoptions.rb', line 84 def tab_width @tab_width end |
#template ⇒ Object (readonly)
template to be used when generating output
60 61 62 |
# File 'lib/testdoc/testdocoptions.rb', line 60 def template @template end |
#text ⇒ Object (readonly)
merge into classes of the name name when generating ri
37 38 39 |
# File 'lib/testdoc/testdocoptions.rb', line 37 def text @text end |
#title ⇒ Object
536 537 538 |
# File 'lib/testdoc/testdocoptions.rb', line 536 def title @title ||= "TestDoc" end |
#webcvs ⇒ Object (readonly)
URL of web cvs frontend
97 98 99 |
# File 'lib/testdoc/testdocoptions.rb', line 97 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
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 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
# File 'lib/testdoc/testdocoptions.rb', line 367 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 "--text" then @text = 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 |