Skip to content

Commit bcef91e

Browse files
Refactor rdoc's default option values.
1 parent 87d60f3 commit bcef91e

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

lib/rdoc/ri/driver.rb

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,12 @@ def message
7777

7878
attr_accessor :homepath # :nodoc:
7979

80-
def self.process_args(argv)
80+
def self.default_options
8181
options = {}
8282
options[:use_stdout] = !$stdout.tty?
8383
options[:width] = 72
8484
options[:formatter] = RDoc::RI::Formatter.for 'plain'
8585
options[:interactive] = false
86-
options[:list_classes] = false
87-
options[:list_names] = false
8886
options[:use_cache] = true
8987

9088
# By default all standard paths are used.
@@ -94,6 +92,12 @@ def self.process_args(argv)
9492
options[:use_gems] = true
9593
options[:extra_doc_dirs] = []
9694

95+
return options
96+
end
97+
98+
def self.process_args(argv)
99+
options = default_options
100+
97101
opts = OptionParser.new do |opt|
98102
opt.program_name = File.basename $0
99103
opt.version = RDoc::VERSION
@@ -152,14 +156,6 @@ def self.process_args(argv)
152156
opt.separator "Options:"
153157
opt.separator nil
154158

155-
opt.on("--classes", "-c",
156-
"Display the names of classes and modules we",
157-
"know about.") do |value|
158-
options[:list_classes] = value
159-
end
160-
161-
opt.separator nil
162-
163159
opt.on("--fmt=FORMAT", "--format=FORMAT", "-f",
164160
RDoc::RI::Formatter::FORMATTERS.keys,
165161
"Format to use when displaying output:",
@@ -252,14 +248,6 @@ def self.process_args(argv)
252248

253249
opt.separator nil
254250

255-
opt.on("--list-names", "-l",
256-
"List all the names known to RDoc, one per",
257-
"line.") do
258-
options[:list_names] = true
259-
end
260-
261-
opt.separator nil
262-
263251
opt.on("--no-pager", "-T",
264252
"Send output directly to stdout,",
265253
"rather than to a pager.") do
@@ -312,19 +300,12 @@ def self.run(argv = ARGV)
312300
ri.run
313301
end
314302

315-
def initialize(options={})
316-
@names = options[:names]
317-
318-
options[:formatter] ||= RDoc::RI::Formatter
303+
def initialize(initial_options={})
304+
options = self.class.default_options.update(initial_options)
319305

306+
@names = options[:names]
320307
@class_cache_name = 'classes'
321308

322-
options[:use_system] = true
323-
options[:use_site] = true
324-
options[:use_home] = true
325-
options[:use_gems] = true
326-
options[:use_cache] = true
327-
328309
@doc_dirs = RDoc::RI::Paths.path(options[:use_system],
329310
options[:use_site],
330311
options[:use_home],

0 commit comments

Comments
 (0)