From cc2a16d94d744d14d4a5eb06eca22137f8a9b79e Mon Sep 17 00:00:00 2001 From: drbrain Date: Wed, 2 Feb 2011 00:32:30 +0000 Subject: Import RDoc 3.5.1 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/options.rb | 67 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 22 deletions(-) (limited to 'lib/rdoc/options.rb') diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb index 3d76569a7e..c5f3b36b8d 100644 --- a/lib/rdoc/options.rb +++ b/lib/rdoc/options.rb @@ -71,7 +71,7 @@ class RDoc::Options attr_accessor :formatter ## - # Description of the output generator (set with the -fmt option) + # Description of the output generator (set with the --fmt option) attr_accessor :generator @@ -148,6 +148,11 @@ class RDoc::Options attr_accessor :title + ## + # Should RDoc update the timestamps in the output dir? + + attr_accessor :update_output_dir + ## # Verbosity, zero means quiet @@ -188,6 +193,7 @@ class RDoc::Options @template = nil @template_dir = nil @title = nil + @update_output_dir = true @verbosity = 1 @visibility = :protected @webcvs = nil @@ -240,6 +246,35 @@ class RDoc::Options @title ||= string end + ## + # Completes any unfinished option setup business such as filtering for + # existent files, creating a regexp for #exclude and setting a default + # #template. + + def finish + @op_dir ||= 'doc' + + @rdoc_include << "." if @rdoc_include.empty? + + if @exclude.empty? then + @exclude = nil + else + @exclude = Regexp.new(@exclude.join("|")) + end + + check_files + + # If no template was specified, use the default template for the output + # formatter + + unless @template then + @template = @generator_name + @template_dir = template_dir_for @template + end + + self + end + ## # Returns a properly-space list of generators and their descriptions. @@ -267,7 +302,7 @@ class RDoc::Options end ## - # Parse command line options. + # Parses command line options. def parse(argv) ignore_invalid = true @@ -449,9 +484,11 @@ Usage: #{opt.program_name} [options] [names...] opt.separator nil - opt.on("--[no-]coverage-report", "--[no-]dcov", "-C", + opt.on("--[no-]coverage-report=[LEVEL]", "--[no-]dcov", "-C", Integer, "Prints a report on undocumented items.", "Does not generate files.") do |value| + value = 0 if value.nil? # Integer converts -C to nil + @coverage_report = value @force_update = true if value end @@ -669,26 +706,9 @@ Usage: #{opt.program_name} [options] [names...] end end - @op_dir ||= 'doc' @files = argv.dup - @rdoc_include << "." if @rdoc_include.empty? - - if @exclude.empty? then - @exclude = nil - else - @exclude = Regexp.new(@exclude.join("|")) - end - - check_files - - # If no template was specified, use the default template for the output - # formatter - - unless @template then - @template = @generator_name - @template_dir = template_dir_for @template - end + finish end ## @@ -725,7 +745,10 @@ Usage: #{opt.program_name} [options] [names...] @generator_name = generator_name @generator_options << @generator - @generator.setup_options self if @generator.respond_to? :setup_options + if @generator.respond_to? :setup_options then + @option_parser ||= OptionParser.new + @generator.setup_options self + end end ## -- cgit v1.2.3