Module: Options::OptionList

Defined in:
lib/rdoc/options.rb

Constant Summary collapse

OPTION_LIST =
[
  [ "--accessor",      "-A",   "accessorname[,..]",
    "comma separated list of additional class methods\n" +
    "that should be treated like 'attr_reader' and\n" +
    "friends. Option may be repeated. Each accessorname\n" +
    "may have '=text' appended, in which case that text\n" +
    "appears where the r/w/rw appears for normal accessors."],
                                                               
  [ "--all",           "-a",   nil,
    "include all methods (not just public)\nin the output" ],

  [ "--charset",       "-c",   "charset",
    "specifies HTML character-set" ],

  [ "--debug",         "-D",   nil,
    "displays lots on internal stuff" ],

  [ "--diagram",       "-d",   nil,
    "Generate diagrams showing modules and classes.\n" +
    "You need dot V1.8.6 or later to use the --diagram\n" +
    "option correctly. Dot is available from\n"+
    "http://www.research.att.com/sw/tools/graphviz/" ],

  [ "--exclude",       "-x",   "pattern",
    "do not process files or directories matching\n" +
    "pattern. Files given explicitly on the command\n" +
    "line will never be excluded." ],

  [ "--extension",     "-E",   "new=old",
    "Treat files ending with .new as if they ended with\n" +
    ".old. Using '-E cgi=rb' will cause xxx.cgi to be\n" +
    "parsed as a Ruby file"],

  [ "--fileboxes",     "-F",   nil,
    "classes are put in boxes which represents\n" +
    "files, where these classes reside. Classes\n" +
    "shared between more than one file are\n" +
    "shown with list of files that sharing them.\n" +
    "Silently discarded if --diagram is not given\n" +
    "Experimental." ],

  [ "--force-update",  "-U",   nil,
    "forces to scan all sources even if newer than\n" +
    "the flag file." ],

  [ "--fmt",           "-f",   "format name",
    "set the output formatter (see below)" ],

  [ "--help",          "-h",   nil,
    "you're looking at it" ],

  [ "--help-output",   "-O",   nil,
    "explain the various output options" ],

  [ "--image-format",  "-I",   "gif/png/jpg/jpeg",
    "Sets output image format for diagrams. Can\n" +
    "be png, gif, jpeg, jpg. If this option is\n" +
    "omitted, png is used. Requires --diagram." ],

  [ "--include",       "-i",   "dir[,dir...]",
    "set (or add to) the list of directories\n" +
    "to be searched when satisfying :include:\n" +
    "requests. Can be used more than once." ],

  [ "--inline-source", "-S",   nil,
    "Show method source code inline, rather\n" +
    "than via a popup link" ],

  [ "--line-numbers", "-N", nil,
    "Include line numbers in the source code" ],

  [ "--main",          "-m",   "name",
    "'name' will be the initial page displayed" ],

  [ "--merge",         "-M",   nil,
    "when creating ri output, merge processed classes\n" +
    "into previously documented classes of the name name"],

  [ "--one-file",      "-1",   nil,
    "put all the output into a single file" ],

  [ "--op",            "-o",   "dir",
    "set the output directory" ],

  [ "--opname",       "-n",    "name",
    "Set the 'name' of the output. Has no\n" +
    "effect for HTML." ],

  [ "--promiscuous",   "-p",   nil,
    "When documenting a file that contains a module\n" +
    "or class also defined in other files, show\n" +
    "all stuff for that module/class in each files\n" +
    "page. By default, only show stuff defined in\n" +
    "that particular file." ],

  [ "--quiet",         "-q",   nil,
    "don't show progress as we parse" ],

  [ "--ri",            "-r",   nil,
   "generate output for use by 'ri.' The files are\n" +
   "stored in the '.rdoc' directory under your home\n"+
   "directory unless overridden by a subsequent\n" +
   "--op parameter, so no special privileges are needed." ],

  [ "--ri-site",       "-R",   nil,
   "generate output for use by 'ri.' The files are\n" +
   "stored in a site-wide directory, making them accessible\n"+
   "to others, so special privileges are needed." ],

  [ "--ri-system",     "-Y",   nil,
   "generate output for use by 'ri.' The files are\n" +
   "stored in a system-level directory, making them accessible\n"+
   "to others, so special privileges are needed. This option\n"+
   "is intended to be used during Ruby installations" ],

  [ "--show-hash",     "-H",   nil,
    "A name of the form #name in a comment\n" +
    "is a possible hyperlink to an instance\n" +
    "method name. When displayed, the '#' is\n" +
    "removed unless this option is specified" ],

  [ "--style",         "-s",   "stylesheet url",
    "specifies the URL of a separate stylesheet." ],

  [ "--tab-width",     "-w",   "n",
    "Set the width of tab characters (default 8)"],

  [ "--template",      "-T",   "template name",
    "Set the template used when generating output" ],

  [ "--title",         "-t",   "text",
    "Set 'txt' as the title for the output" ],

  [ "--version",       "-v",   nil,
    "display  RDoc's version" ],

  [ "--webcvs",        "-W",   "url",
    "Specify a URL for linking to a web frontend\n" +
    "to CVS. If the URL contains a '\%s', the\n" +
    "name of the current file will be substituted;\n" +
    "if the URL doesn't contain a '\%s', the\n" +
    "filename will be appended to it." ],
]

Class Method Summary collapse

Class Method Details

.error(msg) ⇒ Object

Show an error and exit



263
264
265
266
267
268
# File 'lib/rdoc/options.rb', line 263

def OptionList.error(msg)
  $stderr.puts
  $stderr.puts msg
  $stderr.puts "\nFor help on options, try 'rdoc --help'\n\n"
  exit 1
end

.help_outputObject



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/rdoc/options.rb', line 320

def OptionList.help_output
  OptionList.strip_output(<<-EOT)
  How RDoc generates output depends on the output formatter being
  used, and on the options you give.

  - HTML output is normally produced into a number of separate files
    (one per class, module, and file, along with various indices). 
    These files will appear in the directory given by the --op
    option (doc/ by default).

  - XML output by default is written to standard output. If a
    --opname option is given, the output will instead be written
    to a file with that name in the output directory.

  - .chm files (Windows help files) are written in the --op directory.
    If an --opname parameter is present, that name is used, otherwise
    the file will be called rdoc.chm.

  For information on other RDoc options, use "rdoc --help".
  EOT
  exit 0
end

.optionsObject



243
244
245
246
247
248
249
250
# File 'lib/rdoc/options.rb', line 243

def OptionList.options
  OPTION_LIST.map do |long, short, arg,|
    [ long, 
      short, 
      arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT 
    ]
  end
end

.strip_output(text) ⇒ Object



253
254
255
256
257
258
# File 'lib/rdoc/options.rb', line 253

def OptionList.strip_output(text)
  text =~ /^\s+/
  leading_spaces = $&
  text.gsub!(/^#{leading_spaces}/, '')
  $stdout.puts text
end

.usage(generator_names) ⇒ Object

Show usage and exit



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/rdoc/options.rb', line 272

def OptionList.usage(generator_names)
  
  puts
  puts(VERSION_STRING)
  puts

  name = File.basename($0)
  OptionList.strip_output(<<-EOT)
      Usage:

        #{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.

      Options:

  EOT

  OPTION_LIST.each do |long, short, arg, desc|
    opt = sprintf("%20s", "#{long}, #{short}")
    oparg = sprintf("%-7s", arg)
    print "#{opt} #{oparg}"
    desc = desc.split("\n")
    if arg.nil? || arg.length < 7
      puts desc.shift
    else
      puts
    end
    desc.each do |line|
      puts(" "*28 + line)
    end
    puts
  end

  puts "\nAvailable output formatters: " +
    generator_names.sort.join(', ') + "\n\n"

  puts "For information on where the output goes, use\n\n"
  puts "   rdoc --help-output\n\n"

  exit 0
end