Module RI::Options::OptionList
In: 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 ri/ri_options.rb, line 116
116:       def OptionList.error(msg)
117:         $stderr.puts
118:         $stderr.puts msg
119:         $stderr.puts "\nFor help on options, try 'ri --help'\n\n"
120:         exit 1
121:       end

[Source]

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

[Source]

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

Show usage and exit

[Source]

     # File ri/ri_options.rb, line 125
125:       def OptionList.usage(short_form=false)
126:         
127:         puts
128:         puts(RI::VERSION_STRING)
129:         puts
130:         
131:         name = File.basename($0)
132: 
133:         directories = [
134:           RI::Paths::SYSDIR,
135:           RI::Paths::SITEDIR,
136:           RI::Paths::HOMEDIR
137:         ]
138: 
139:         directories << "#{Gem.path}/doc/*/ri" if RI::Paths::GEMDIRS
140: 
141:         directories = directories.join("\n    ")
142: 
143:         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")
144: 
145:         if short_form
146:           puts "For help on options, type 'ri -h'"
147:           puts "For a list of classes I know about, type 'ri -c'"
148:         else
149:           puts "Options:\n\n"
150:           OPTION_LIST.each do|long, short, arg, desc|
151:             opt = ''
152:             opt << (short ? sprintf("%15s", "#{long}, #{short}") :
153:                             sprintf("%15s", long))
154:             if arg
155:               opt << " " << arg
156:             end
157:             print opt
158:             desc = desc.split("\n")
159:             if opt.size < 17
160:               print " "*(18-opt.size)
161:               puts desc.shift
162:             else
163:               puts
164:             end
165:             desc.each do |line|
166:               puts(" "*18 + line)
167:             end
168:             puts
169:           end
170:           puts "Options may also be passed in the 'RI' environment variable"
171:           exit 0
172:         end
173:       end

[Validate]