Module RI::Options::OptionList
In: lib/rdoc/ri/ri_options.rb

Methods

error   options   strip_output   usage  

Constants

OPTION_LIST = [ [ "--help", "-h", nil, "you're looking at it" ], [ "--classes", "-c", nil, "Display the names of classes and modules we\n" + "know about"], [ "--doc-dir", "-d", "<dirname>", "A directory to search for documentation. If not\n" + "specified, we search the standard rdoc/ri directories.\n" + "May be repeated."], [ "--system", nil, nil, "Include documentation from Ruby's standard library:\n " + RI::Paths::SYSDIR ], [ "--site", nil, nil, "Include documentation from libraries installed in site_lib:\n " + RI::Paths::SITEDIR ], [ "--home", nil, nil, "Include documentation stored in ~/.rdoc:\n " + (RI::Paths::HOMEDIR || "No ~/.rdoc found") ], [ "--gems", nil, nil, "Include documentation from Rubygems:\n " + (RI::Paths::GEMDIRS ? "#{Gem.path}/doc/*/ri" : "No Rubygems ri found.") ], [ "--format", "-f", "<name>", "Format to use when displaying output:\n" + " " + RI::TextFormatter.list + "\n" + "Use 'bs' (backspace) with most pager programs.\n" + "To use ANSI, either also use the -T option, or\n" + "tell your pager to allow control characters\n" + "(for example using the -R option to less)"], [ "--list-names", "-l", nil, "List all the names known to RDoc, one per line"

Public Class methods

Show an error and exit

[Source]

     # File lib/rdoc/ri/ri_options.rb, line 115
115:       def OptionList.error(msg)
116:         $stderr.puts
117:         $stderr.puts msg
118:         $stderr.puts "\nFor help on options, try 'ri --help'\n\n"
119:         exit 1
120:       end

[Source]

     # File lib/rdoc/ri/ri_options.rb, line 93
 93:       def OptionList.options
 94:         OPTION_LIST.map do |long, short, arg,|
 95:           option = []
 96:           option << long
 97:           option << short unless short.nil?
 98:           option << (arg ? GetoptLong::REQUIRED_ARGUMENT :
 99:                            GetoptLong::NO_ARGUMENT)
100:           option
101:         end
102:       end

[Source]

     # File lib/rdoc/ri/ri_options.rb, line 105
105:       def OptionList.strip_output(text)
106:         text =~ /^\s+/
107:         leading_spaces = $&
108:         text.gsub!(/^#{leading_spaces}/, '')
109:         $stdout.puts text
110:       end

Show usage and exit

[Source]

     # File lib/rdoc/ri/ri_options.rb, line 124
124:       def OptionList.usage(short_form=false)
125:         
126:         puts
127:         puts(RI::VERSION_STRING)
128:         puts
129:         
130:         name = File.basename($0)
131: 
132:         directories = [
133:           RI::Paths::SYSDIR,
134:           RI::Paths::SITEDIR,
135:           RI::Paths::HOMEDIR
136:         ]
137: 
138:         directories << "#{Gem.path}/doc/*/ri" if RI::Paths::GEMDIRS
139: 
140:         directories = directories.join("\n    ")
141: 
142:         OptionList.strip_output("Usage:\n\n\#{name} [options]  [names...]\n\nDisplay information on Ruby classes, modules, and methods.\nGive the names of classes or methods to see their documentation.\nPartial names may be given: if the names match more than\none entity, a list will be shown, otherwise details on\nthat entity will be displayed.\n\nNested classes and modules can be specified using the normal\nName::Name notation, and instance methods can be distinguished\nfrom class methods using \".\" (or \"#\") instead of \"::\".\n\nFor example:\n\nri  File\nri  File.new\nri  F.n\nri  zip\n\nNote that shell quoting may be required for method names\ncontaining punctuation:\n\nri 'Array.[]'\nri compact\\\\!\n\nBy default ri searches for documentation in the following\ndirectories:\n\n\#{directories}\n\nSpecifying the --system, --site, --home, --gems or --doc-dir\noptions will limit ri to searching only the specified\ndirectories.\n\n")
143: 
144:         if short_form
145:           puts "For help on options, type 'ri -h'"
146:           puts "For a list of classes I know about, type 'ri -c'"
147:         else
148:           puts "Options:\n\n"
149:           OPTION_LIST.each do|long, short, arg, desc|
150:             opt = ''
151:             opt << (short ? sprintf("%15s", "#{long}, #{short}") :
152:                             sprintf("%15s", long))
153:             if arg
154:               opt << " " << arg
155:             end
156:             print opt
157:             desc = desc.split("\n")
158:             if opt.size < 17
159:               print " "*(18-opt.size)
160:               puts desc.shift
161:             else
162:               puts
163:             end
164:             desc.each do |line|
165:               puts(" "*18 + line)
166:             end
167:             puts
168:           end
169:           puts "Options may also be passed in the 'RI' environment variable"
170:           exit 0
171:         end
172:       end

[Validate]