Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor rdoc's default option values.

  • Loading branch information...
commit 18e4e8020c45065f1e3bdcba5addd6116ff5d34e 1 parent 559427e
designingpatts authored
Showing with 10 additions and 29 deletions.
  1. +10 −29 lib/rdoc/ri/driver.rb
View
39 lib/rdoc/ri/driver.rb
@@ -77,14 +77,12 @@ def message
attr_accessor :homepath # :nodoc:
- def self.process_args(argv)
+ def self.default_options
options = {}
options[:use_stdout] = !$stdout.tty?
options[:width] = 72
options[:formatter] = RDoc::RI::Formatter.for 'plain'
options[:interactive] = false
- options[:list_classes] = false
- options[:list_names] = false
options[:use_cache] = true
# By default all standard paths are used.
@@ -94,6 +92,12 @@ def self.process_args(argv)
options[:use_gems] = true
options[:extra_doc_dirs] = []
+ return options
+ end
+
+ def self.process_args(argv)
+ options = default_options
+
opts = OptionParser.new do |opt|
opt.program_name = File.basename $0
opt.version = RDoc::VERSION
@@ -152,14 +156,6 @@ def self.process_args(argv)
opt.separator "Options:"
opt.separator nil
- opt.on("--classes", "-c",
- "Display the names of classes and modules we",
- "know about.") do |value|
- options[:list_classes] = value
- end
-
- opt.separator nil
-
opt.on("--fmt=FORMAT", "--format=FORMAT", "-f",
RDoc::RI::Formatter::FORMATTERS.keys,
"Format to use when displaying output:",
@@ -252,14 +248,6 @@ def self.process_args(argv)
opt.separator nil
- opt.on("--list-names", "-l",
- "List all the names known to RDoc, one per",
- "line.") do
- options[:list_names] = true
- end
-
- opt.separator nil
-
opt.on("--no-pager", "-T",
"Send output directly to stdout,",
"rather than to a pager.") do
@@ -312,19 +300,12 @@ def self.run(argv = ARGV)
ri.run
end
- def initialize(options={})
- @names = options[:names]
-
- options[:formatter] ||= RDoc::RI::Formatter
+ def initialize(initial_options={})
+ options = self.class.default_options.update(initial_options)
+ @names = options[:names]
@class_cache_name = 'classes'
- options[:use_system] = true
- options[:use_site] = true
- options[:use_home] = true
- options[:use_gems] = true
- options[:use_cache] = true
-
@doc_dirs = RDoc::RI::Paths.path(options[:use_system],
options[:use_site],
options[:use_home],

0 comments on commit 18e4e80

Please sign in to comment.
Something went wrong with that request. Please try again.