Name of the file, class or module to display in the initial index page (if not specified the first file we encounter is used)
Object
RDoc::Options handles the parsing and storage of options
Parse command line options.
# File lib/rdoc/options.rb, line 116
116: def parse(argv)
117: ignore_invalid = true
118:
119: opts = OptionParser.new do |opt|
120: opt.program_name = File.basename $0
121: opt.version = RDoc::VERSION
122: opt.release = nil
123: opt.summary_indent = ' ' * 4
124: 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:
125:
126: parsers = Hash.new { |h,parser| h[parser] = [] }
127:
128: RDoc::Parser.parsers.each do |regexp, parser|
129: parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
130: end
131:
132: parsers.sort.each do |parser, regexp|
133: opt.banner << " - #{parser}: #{regexp.join ', '}\n"
134: end
135:
136: opt.separator nil
137: opt.separator "Parsing Options:"
138: opt.separator nil
139:
140: opt.on("--exclude=PATTERN", "-x", Regexp,
141: "Do not process files or directories",
142: "matching PATTERN.") do |value|
143: @exclude << value
144: end
145:
146: opt.separator nil
147:
148: opt.on("--extension=NEW=OLD", "-E",
149: "Treat files ending with .new as if they",
150: "ended with .old. Using '-E cgi=rb' will",
151: "cause xxx.cgi to be parsed as a Ruby file.") do |value|
152: new, old = value.split(/=/, 2)
153:
154: unless new and old then
155: raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
156: end
157:
158: unless RDoc::Parser.alias_extension old, new then
159: raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
160: end
161: end
162:
163: opt.separator nil
164:
165: opt.on("--[no-]force-update", "-U",
166: "Forces rdoc to scan all sources even if",
167: "newer than the flag file.") do |value|
168: @force_update = value
169: end
170:
171: opt.separator nil
172:
173: opt.on("--pipe",
174: "Convert RDoc on stdin to HTML") do
175: @pipe = true
176: end
177:
178: opt.separator nil
179: opt.separator "Generator Options:"
180: opt.separator nil
181:
182: opt.on("--charset=CHARSET", "-c",
183: "Specifies the output HTML character-set.") do |value|
184: @charset = value
185: end
186:
187: opt.separator nil
188:
189: generator_text = @generators.keys.map { |name| " #{name}" }.sort
190:
191: opt.on("--fmt=FORMAT", "--format=FORMAT", "-f", @generators.keys,
192: "Set the output formatter. One of:", *generator_text) do |value|
193: @generator_name = value.downcase
194: setup_generator
195: end
196:
197: opt.separator nil
198:
199: opt.on("--include=DIRECTORIES", "-i", Array,
200: "Set (or add to) the list of directories to",
201: "be searched when satisfying :include:",
202: "requests. Can be used more than once.") do |value|
203: @rdoc_include.concat value.map { |dir| dir.strip }
204: end
205:
206: opt.separator nil
207:
208: opt.on("--main=NAME", "-m",
209: "NAME will be the initial page displayed.") do |value|
210: @main_page = value
211: end
212:
213: opt.separator nil
214:
215: opt.on("--output=DIR", "--op", "-o",
216: "Set the output directory.") do |value|
217: @op_dir = value
218: end
219:
220: opt.separator nil
221:
222: opt.on("--show-hash", "-H",
223: "A name of the form #name in a comment is a",
224: "possible hyperlink to an instance method",
225: "name. When displayed, the '#' is removed",
226: "unless this option is specified.") do |value|
227: @show_hash = value
228: end
229:
230: opt.separator nil
231:
232: opt.on("--tab-width=WIDTH", "-w", OptionParser::DecimalInteger,
233: "Set the width of tab characters.") do |value|
234: @tab_width = value
235: end
236:
237: opt.separator nil
238:
239: opt.on("--template=NAME", "-T",
240: "Set the template used when generating",
241: "output.") do |value|
242: @template = value
243: end
244:
245: opt.separator nil
246:
247: opt.on("--title=TITLE", "-t",
248: "Set TITLE as the title for HTML output.") do |value|
249: @title = value
250: end
251:
252: opt.separator nil
253:
254: opt.on("--webcvs=URL", "-W",
255: "Specify a URL for linking to a web frontend",
256: "to CVS. If the URL contains a '\%s', the",
257: "name of the current file will be",
258: "substituted; if the URL doesn't contain a",
259: "'\%s', the filename will be appended to it.") do |value|
260: @webcvs = value
261: end
262:
263: opt.separator nil
264:
265: opt.on("-d", "--diagram", "Prevents -d from tripping --debug")
266:
267: opt.separator nil
268: opt.separator "ri Generator Options:"
269: opt.separator nil
270:
271: opt.on("--ri", "-r",
272: "Generate output for use by `ri`. The files",
273: "are stored in the '.rdoc' directory under",
274: "your home directory unless overridden by a",
275: "subsequent --op parameter, so no special",
276: "privileges are needed.") do |value|
277: @generator_name = "ri"
278: @op_dir ||= RDoc::RI::Paths::HOMEDIR
279: setup_generator
280: end
281:
282: opt.separator nil
283:
284: opt.on("--ri-site", "-R",
285: "Generate output for use by `ri`. The files",
286: "are stored in a site-wide directory,",
287: "making them accessible to others, so",
288: "special privileges are needed.") do |value|
289: @generator_name = "ri"
290: @op_dir = RDoc::RI::Paths::SITEDIR
291: setup_generator
292: end
293:
294: opt.separator nil
295: opt.separator "Generic Options:"
296: opt.separator nil
297:
298: opt.on("-D", "--[no-]debug",
299: "Displays lots on internal stuff.") do |value|
300: $DEBUG_RDOC = value
301: end
302:
303: opt.on("--[no-]ignore-invalid",
304: "Ignore invalid options and continue.") do |value|
305: ignore_invalid = value
306: end
307:
308: opt.on("--quiet", "-q",
309: "Don't show progress as we parse.") do |value|
310: @verbosity = 0
311: end
312:
313: opt.on("--verbose", "-v",
314: "Display extra progress as we parse.") do |value|
315: @verbosity = 2
316: end
317:
318: opt.separator nil
319: end
320:
321: argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
322: ignored = []
323:
324: begin
325: opts.parse! argv
326: rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
327: if ignore_invalid then
328: ignored << e.args.join(' ')
329: retry
330: else
331: $stderr.puts opts
332: $stderr.puts
333: $stderr.puts e
334: exit 1
335: end
336: end
337:
338: if @pipe and not argv.empty? then
339: @pipe = false
340: ignored << '-p (with files)'
341: end
342:
343: unless ignored.empty? or quiet then
344: $stderr.puts "invalid options: #{ignored.join ', '}"
345: $stderr.puts '(invalid options are ignored)'
346: end
347:
348: @op_dir ||= 'doc'
349: @files = argv.dup
350:
351: @rdoc_include << "." if @rdoc_include.empty?
352:
353: if @exclude.empty? then
354: @exclude = nil
355: else
356: @exclude = Regexp.new(@exclude.join("|"))
357: end
358:
359: check_files
360:
361: # If no template was specified, use the default template for the output
362: # formatter
363:
364: @template ||= @generator_name
365: end
Don’t display progress as we process the files
# File lib/rdoc/options.rb, line 395
395: def quiet
396: @verbosity.zero?
397: end
Check that the files on the command line exist
# File lib/rdoc/options.rb, line 419
419: def check_files
420: @files.each do |f|
421: stat = File.stat f rescue next
422: raise RDoc::Error, "file '#{f}' not readable" unless stat.readable?
423: end
424: end
Set up an output generator for the format in @generator_name
# File lib/rdoc/options.rb, line 408
408: def setup_generator
409: @generator = @generators[@generator_name]
410:
411: unless @generator then
412: raise OptionParser::InvalidArgument, "Invalid output formatter"
413: end
414: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.