Class: RI::Options
- Inherits:
-
Object
- Object
- RI::Options
- Includes:
- Singleton
- Defined in:
- lib/rdoc/ri/ri_options.rb
Defined Under Namespace
Modules: OptionList
Instance Attribute Summary collapse
-
#doc_dir ⇒ Object
readonly
the directory we search for original documentation.
-
#formatter ⇒ Object
readonly
the formatting we apply to the output.
-
#list_classes ⇒ Object
readonly
should we just display a class list and exit.
-
#list_names ⇒ Object
readonly
should we display a list of all names.
-
#use_stdout ⇒ Object
No not use a pager.
-
#width ⇒ Object
readonly
The width of the output line.
Instance Method Summary collapse
-
#displayer ⇒ Object
Return an instance of the displayer (the thing that actually writes the information).
-
#initialize ⇒ Options
constructor
A new instance of Options.
-
#parse(args) ⇒ Object
Parse command line options.
-
#path ⇒ Object
Return the selected documentation directories.
- #raw_path ⇒ Object
-
#show_version ⇒ Object
Show the version and exit.
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/rdoc/ri/ri_options.rb', line 219 def initialize @use_stdout = !STDOUT.tty? @width = 72 @formatter = RI::TextFormatter.for("plain") @list_classes = false @list_names = false # By default all paths are used. If any of these are true, only those # directories are used. @use_system = false @use_site = false @use_home = false @use_gems = false @doc_dirs = [] end |
Instance Attribute Details
#doc_dir ⇒ Object (readonly)
the directory we search for original documentation
35 36 37 |
# File 'lib/rdoc/ri/ri_options.rb', line 35 def doc_dir @doc_dir end |
#formatter ⇒ Object (readonly)
the formatting we apply to the output
32 33 34 |
# File 'lib/rdoc/ri/ri_options.rb', line 32 def formatter @formatter end |
#list_classes ⇒ Object (readonly)
should we just display a class list and exit
23 24 25 |
# File 'lib/rdoc/ri/ri_options.rb', line 23 def list_classes @list_classes end |
#list_names ⇒ Object (readonly)
should we display a list of all names
26 27 28 |
# File 'lib/rdoc/ri/ri_options.rb', line 26 def list_names @list_names end |
#use_stdout ⇒ Object
No not use a pager. Writable, because ri sets it if it can’t find a pager
20 21 22 |
# File 'lib/rdoc/ri/ri_options.rb', line 20 def use_stdout @use_stdout end |
#width ⇒ Object (readonly)
The width of the output line
29 30 31 |
# File 'lib/rdoc/ri/ri_options.rb', line 29 def width @width end |
Instance Method Details
#displayer ⇒ Object
Return an instance of the displayer (the thing that actually writes the information). This allows us to load in new displayer classes at runtime (for example to help with IDE integration)
307 308 309 |
# File 'lib/rdoc/ri/ri_options.rb', line 307 def displayer ::RiDisplay.new(self) end |
#parse(args) ⇒ Object
Parse command line options.
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/rdoc/ri/ri_options.rb', line 237 def parse(args) old_argv = ARGV.dup ARGV.replace(args) begin go = GetoptLong.new(*OptionList.) go.quiet = true go.each do |opt, arg| case opt when "--help" then OptionList.usage when "--version" then show_version when "--list-names" then @list_names = true when "--no-pager" then @use_stdout = true when "--classes" then @list_classes = true when "--system" then @use_system = true when "--site" then @use_site = true when "--home" then @use_home = true when "--gems" then @use_gems = true when "--doc-dir" if File.directory?(arg) @doc_dirs << arg else $stderr.puts "Invalid directory: #{arg}" exit 1 end when "--format" @formatter = RI::TextFormatter.for(arg) unless @formatter $stderr.print "Invalid formatter (should be one of " $stderr.puts RI::TextFormatter.list + ")" exit 1 end when "--width" begin @width = Integer(arg) rescue $stderr.puts "Invalid width: '#{arg}'" exit 1 end end end rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error OptionList.error(error.) end end |
#path ⇒ Object
Return the selected documentation directories.
294 295 296 |
# File 'lib/rdoc/ri/ri_options.rb', line 294 def path RI::Paths.path(@use_system, @use_site, @use_home, @use_gems, *@doc_dirs) end |
#raw_path ⇒ Object
298 299 300 301 |
# File 'lib/rdoc/ri/ri_options.rb', line 298 def raw_path RI::Paths.raw_path(@use_system, @use_site, @use_home, @use_gems, *@doc_dirs) end |
#show_version ⇒ Object
Show the version and exit
214 215 216 217 |
# File 'lib/rdoc/ri/ri_options.rb', line 214 def show_version puts VERSION_STRING exit(0) end |