| Module | RI::Options::OptionList |
| In: |
rdoc/ri/ri_options.rb
|
| 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" |
# File rdoc/ri/ri_options.rb, line 94 def OptionList.options OPTION_LIST.map do |long, short, arg,| option = [] option << long option << short unless short.nil? option << (arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT) option end end
# File rdoc/ri/ri_options.rb, line 106 def OptionList.strip_output(text) text =~ /^\s+/ leading_spaces = $& text.gsub!(/^#{leading_spaces}/, '') $stdout.puts text end
Show usage and exit
# File rdoc/ri/ri_options.rb, line 125 def OptionList.usage(short_form=false) puts puts(RI::VERSION_STRING) puts name = File.basename($0) directories = [ RI::Paths::SYSDIR, RI::Paths::SITEDIR, RI::Paths::HOMEDIR ] directories << "#{Gem.path}/doc/*/ri" if RI::Paths::GEMDIRS directories = directories.join("\n ") 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") if short_form puts "For help on options, type 'ri -h'" puts "For a list of classes I know about, type 'ri -c'" else puts "Options:\n\n" OPTION_LIST.each do|long, short, arg, desc| opt = '' opt << (short ? sprintf("%15s", "#{long}, #{short}") : sprintf("%15s", long)) if arg opt << " " << arg end print opt desc = desc.split("\n") if opt.size < 17 print " "*(18-opt.size) puts desc.shift else puts end desc.each do |line| puts(" "*18 + line) end puts end puts "Options may also be passed in the 'RI' environment variable" exit 0 end end
ruby-doc.org is a service of James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, AZ.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.