| Class | RI::Options |
| In: |
lib/rdoc/ri/ri_options.rb
|
| Parent: | Object |
| doc_dir | [R] | the directory we search for original documentation |
| formatter | [R] | the formatting we apply to the output |
| list_classes | [R] | should we just display a class list and exit |
| list_names | [R] | should we display a list of all names |
| use_stdout | [RW] | No not use a pager. Writable, because ri sets it if it can‘t find a pager |
| width | [R] | The width of the output line |
# File lib/rdoc/ri/ri_options.rb, line 226
226: def initialize
227: @use_stdout = !STDOUT.tty?
228: @width = 72
229: @formatter = RI::TextFormatter.for("plain")
230: @list_classes = false
231: @list_names = false
232:
233: # By default all paths are used. If any of these are true, only those
234: # directories are used.
235: @use_system = false
236: @use_site = false
237: @use_home = false
238: @use_gems = false
239: @doc_dirs = []
240: end
Parse command line options.
# File lib/rdoc/ri/ri_options.rb, line 244
244: def parse(args)
245:
246: old_argv = ARGV.dup
247:
248: ARGV.replace(args)
249:
250: begin
251:
252: go = GetoptLong.new(*OptionList.options)
253: go.quiet = true
254:
255: go.each do |opt, arg|
256: case opt
257: when "--help" then OptionList.usage
258: when "--version" then show_version
259: when "--list-names" then @list_names = true
260: when "--no-pager" then @use_stdout = true
261: when "--classes" then @list_classes = true
262:
263: when "--system" then @use_system = true
264: when "--site" then @use_site = true
265: when "--home" then @use_home = true
266: when "--gems" then @use_gems = true
267:
268: when "--doc-dir"
269: if File.directory?(arg)
270: @doc_dirs << arg
271: else
272: $stderr.puts "Invalid directory: #{arg}"
273: exit 1
274: end
275:
276: when "--format"
277: @formatter = RI::TextFormatter.for(arg)
278: unless @formatter
279: $stderr.print "Invalid formatter (should be one of "
280: $stderr.puts RI::TextFormatter.list + ")"
281: exit 1
282: end
283: when "--width"
284: begin
285: @width = Integer(arg)
286: rescue
287: $stderr.puts "Invalid width: '#{arg}'"
288: exit 1
289: end
290: end
291: end
292:
293: rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
294: OptionList.error(error.message)
295:
296: end
297: end
Return the selected documentation directories.
# File lib/rdoc/ri/ri_options.rb, line 301
301: def path
302: RI::Paths.path(@use_system, @use_site, @use_home, @use_gems, *@doc_dirs)
303: end
# File lib/rdoc/ri/ri_options.rb, line 305
305: def raw_path
306: RI::Paths.raw_path(@use_system, @use_site, @use_home, @use_gems,
307: *@doc_dirs)
308: end