| 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 219
219: def initialize
220: @use_stdout = !STDOUT.tty?
221: @width = 72
222: @formatter = RI::TextFormatter.for("plain")
223: @list_classes = false
224: @list_names = false
225:
226: # By default all paths are used. If any of these are true, only those
227: # directories are used.
228: @use_system = false
229: @use_site = false
230: @use_home = false
231: @use_gems = false
232: @doc_dirs = []
233: end
Parse command line options.
# File lib/rdoc/ri/ri_options.rb, line 237
237: def parse(args)
238:
239: old_argv = ARGV.dup
240:
241: ARGV.replace(args)
242:
243: begin
244:
245: go = GetoptLong.new(*OptionList.options)
246: go.quiet = true
247:
248: go.each do |opt, arg|
249: case opt
250: when "--help" then OptionList.usage
251: when "--version" then show_version
252: when "--list-names" then @list_names = true
253: when "--no-pager" then @use_stdout = true
254: when "--classes" then @list_classes = true
255:
256: when "--system" then @use_system = true
257: when "--site" then @use_site = true
258: when "--home" then @use_home = true
259: when "--gems" then @use_gems = true
260:
261: when "--doc-dir"
262: if File.directory?(arg)
263: @doc_dirs << arg
264: else
265: $stderr.puts "Invalid directory: #{arg}"
266: exit 1
267: end
268:
269: when "--format"
270: @formatter = RI::TextFormatter.for(arg)
271: unless @formatter
272: $stderr.print "Invalid formatter (should be one of "
273: $stderr.puts RI::TextFormatter.list + ")"
274: exit 1
275: end
276: when "--width"
277: begin
278: @width = Integer(arg)
279: rescue
280: $stderr.puts "Invalid width: '#{arg}'"
281: exit 1
282: end
283: end
284: end
285:
286: rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
287: OptionList.error(error.message)
288:
289: end
290: end
Return the selected documentation directories.
# File lib/rdoc/ri/ri_options.rb, line 294
294: def path
295: RI::Paths.path(@use_system, @use_site, @use_home, @use_gems, *@doc_dirs)
296: end
# File lib/rdoc/ri/ri_options.rb, line 298
298: def raw_path
299: RI::Paths.raw_path(@use_system, @use_site, @use_home, @use_gems,
300: *@doc_dirs)
301: end