method
parse
v1_9_2_180 -
Show latest stable
-
0 notes -
Class: Options
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (38)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
Related methods
- Class methods (1)
- new
- Instance methods (24)
- == (>= v2_1_10)
- check_diagram (<= v1_9_1_378)
- check_files
- check_generator (>= v1_9_3_125)
- default_title= (>= v1_9_3_125)
- encode_with (>= v2_1_10)
- exclude (>= v2_6_3)
- finish (>= v1_9_3_125)
- finish_page_dir (>= v2_1_10)
- generator_descriptions (>= v1_9_3_125)
- init_ivars (>= v2_1_10)
- init_with (>= v2_1_10)
- parse
- quiet
- quiet=
- sanitize_path (>= v2_1_10)
- setup_generator
- template_dir_for (>= v1_9_3_125)
- title=
- to_yaml (>= v2_1_10)
- visibility= (>= v2_2_9)
- warn (>= v2_1_10)
- write_options (>= v2_1_10)
- yaml_initialize (>= v2_1_10)
= private
= protected
parse(argv)
public
Parse command line options.
Show source
# File lib/rdoc/options.rb, line 122 def parse(argv) ignore_invalid = true opts = OptionParser.new do |opt| opt.program_name = File.basename $0 opt.version = RDoc::VERSION opt.release = nil opt.summary_indent = ' ' * 4 opt.banner = Usage: #{opt.program_name} [options] [names...] Files are parsed, and the information they contain collected, before any output is produced. This allows cross references between all files to be resolved. If a name is a directory, it is traversed. If no names are specified, all Ruby files in the current directory (and subdirectories) are processed. How RDoc generates output depends on the output formatter being used, and on the options you give. - Darkfish creates frameless HTML output by Michael Granger. - ri creates ri data files RDoc understands the following file formats: parsers = Hash.new { |h,parser| h[parser] = [] } RDoc::Parser.parsers.each do |regexp, parser| parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source end parsers.sort.each do |parser, regexp| opt.banner << " - #{parser}: #{regexp.join ', '}\n" end opt.separator nil opt.separator "Parsing Options:" opt.separator nil opt.on("--all", "-a", "Include all methods (not just public) in", "the output.") do |value| @show_all = value end opt.separator nil opt.on("--exclude=PATTERN", "-x", Regexp, "Do not process files or directories", "matching PATTERN.") do |value| @exclude << value end opt.separator nil opt.on("--extension=NEW=OLD", "-E", "Treat files ending with .new as if they", "ended with .old. Using '-E cgi=rb' will", "cause xxx.cgi to be parsed as a Ruby file.") do |value| new, old = value.split(/=/, 2) unless new and old then raise OptionParser::InvalidArgument, "Invalid parameter to '-E'" end unless RDoc::Parser.alias_extension old, new then raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E" end end opt.separator nil opt.on("--[no-]force-update", "-U", "Forces rdoc to scan all sources even if", "newer than the flag file.") do |value| @force_update = value end opt.separator nil opt.on("--pipe", "Convert RDoc on stdin to HTML") do @pipe = true end opt.separator nil opt.separator "Generator Options:" opt.separator nil opt.on("--charset=CHARSET", "-c", "Specifies the output HTML character-set.") do |value| @charset = value end opt.separator nil generator_text = @generators.keys.map { |name| " #{name}" }.sort opt.on("--fmt=FORMAT", "--format=FORMAT", "-f", @generators.keys, "Set the output formatter. One of:", *generator_text) do |value| @generator_name = value.downcase setup_generator end opt.separator nil opt.on("--include=DIRECTORIES", "-i", Array, "Set (or add to) the list of directories to", "be searched when satisfying :include:", "requests. Can be used more than once.") do |value| @rdoc_include.concat value.map { |dir| dir.strip } end opt.separator nil opt.on("--main=NAME", "-m", "NAME will be the initial page displayed.") do |value| @main_page = value end opt.separator nil opt.on("--output=DIR", "--op", "-o", "Set the output directory.") do |value| @op_dir = value end opt.separator nil opt.on("--show-hash", "-H", "A name of the form #name in a comment is a", "possible hyperlink to an instance method", "name. When displayed, the '#' is removed", "unless this option is specified.") do |value| @show_hash = value end opt.separator nil opt.on("--tab-width=WIDTH", "-w", OptionParser::DecimalInteger, "Set the width of tab characters.") do |value| @tab_width = value end opt.separator nil opt.on("--template=NAME", "-T", "Set the template used when generating", "output.") do |value| @template = value end opt.separator nil opt.on("--title=TITLE", "-t", "Set TITLE as the title for HTML output.") do |value| @title = value end opt.separator nil opt.on("--webcvs=URL", "-W", "Specify a URL for linking to a web frontend", "to CVS. If the URL contains a '\%s', the", "name of the current file will be", "substituted; if the URL doesn't contain a", "'\%s', the filename will be appended to it.") do |value| @webcvs = value end opt.separator nil opt.on("-d", "--diagram", "Prevents -d from tripping --debug") opt.separator nil opt.separator "ri Generator Options:" opt.separator nil opt.on("--ri", "-r", "Generate output for use by `ri`. The files", "are stored in the '.rdoc' directory under", "your home directory unless overridden by a", "subsequent --op parameter, so no special", "privileges are needed.") do |value| @generator_name = "ri" @op_dir ||= RDoc::RI::Paths::HOMEDIR setup_generator end opt.separator nil opt.on("--ri-site", "-R", "Generate output for use by `ri`. The files", "are stored in a site-wide directory,", "making them accessible to others, so", "special privileges are needed.") do |value| @generator_name = "ri" @op_dir = RDoc::RI::Paths::SITEDIR setup_generator end opt.separator nil opt.separator "Generic Options:" opt.separator nil opt.on("-D", "--[no-]debug", "Displays lots on internal stuff.") do |value| $DEBUG_RDOC = value end opt.on("--[no-]ignore-invalid", "Ignore invalid options and continue.") do |value| ignore_invalid = value end opt.on("--quiet", "-q", "Don't show progress as we parse.") do |value| @verbosity = 0 end opt.on("--verbose", "-v", "Display extra progress as we parse.") do |value| @verbosity = 2 end opt.separator nil end argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT'] ignored = [] begin opts.parse! argv rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e if ignore_invalid then ignored << e.args.join(' ') retry else $stderr.puts opts $stderr.puts $stderr.puts e exit 1 end end if @pipe and not argv.empty? then @pipe = false ignored << '-p (with files)' end unless ignored.empty? or quiet then $stderr.puts "invalid options: #{ignored.join ', '}" $stderr.puts '(invalid options are ignored)' end @op_dir ||= 'doc' @files = argv.dup @rdoc_include << "." if @rdoc_include.empty? if @exclude.empty? then @exclude = nil else @exclude = Regexp.new(@exclude.join("|")) end check_files # If no template was specified, use the default template for the output # formatter @template ||= @generator_name end