Class Options
In: rdoc/options.rb
Parent: Object

Methods

parse   title   title=  

Included Modules

Singleton

Classes and Modules

Module Options::OptionList

Attributes

all_one_file  [R]  should the output be placed into a single file
charset  [R]  character-set
css  [R]  URL of stylesheet
diagram  [R]  should diagrams be drawn
exclude  [RW]  files matching this pattern will be excluded
extra_accessor_flags  [R] 
extra_accessors  [R]  pattern for additional attr_… style methods
fileboxes  [R]  should we draw fileboxes in diagrams
files  [R]  and the list of files to be processed
generator  [RW]  description of the output generator (set with the -fmt option
image_format  [R]  image format for diagrams
include_line_numbers  [R]  include line numbers in the source listings
inline_source  [R]  should source code be included inline, or displayed in a popup
main_page  [RW]  name of the file, class or module to display in the initial index page (if not specified the first file we encounter is used)
merge  [R]  merge into classes of the name name when generating ri
op_dir  [RW]  the name of the output directory
op_name  [R]  the name to use for the output
promiscuous  [R]  Are we promiscuous about showing module contents across multiple files
quiet  [R]  Don‘t display progress as we process the files
rdoc_include  [R]  array of directories to search for files to satisfy an :include:
show_all  [RW]  include private and protected methods in the output
show_hash  [R]  include the ’#’ at the front of hyperlinked instance method names
tab_width  [R]  the number of columns in a tab
template  [R]  template to be used when generating output
webcvs  [R]  URL of web cvs frontend

Public Instance methods

Parse command line options. We‘re passed a hash containing output generators, keyed by the generator name

[Source]

# File rdoc/options.rb, line 342
  def parse(argv, generators)
    old_argv = ARGV.dup
    begin
      ARGV.replace(argv)
      @op_dir = "doc"
      @op_name = nil
      @show_all = false
      @main_page = nil
      @marge     = false
      @exclude   = []
      @quiet = false
      @generator_name = 'html'
      @generator = generators[@generator_name]
      @rdoc_include = []
      @title = nil
      @template = nil
      @diagram = false
      @fileboxes = false
      @show_hash = false
      @image_format = 'png'
      @inline_source = false
      @all_one_file  = false
      @tab_width = 8
      @include_line_numbers = false
      @extra_accessor_flags = {}
      @promiscuous = false

      @css = nil
      @webcvs = nil

      @charset = case $KCODE
                 when /^S/i
                   'Shift_JIS'
                 when /^E/i
                   'EUC-JP'
                 else
                   'iso-8859-1'
                 end

      accessors = []

      go = GetoptLong.new(*OptionList.options)
      go.quiet = true

      go.each do |opt, arg|
        case opt
        when "--all"           then @show_all      = true
        when "--charset"       then @charset       = arg
        when "--debug"         then $DEBUG         = true
        when "--exclude"       then @exclude       << Regexp.new(arg)
        when "--inline-source" then @inline_source = true
        when "--line-numbers"  then @include_line_numbers = true
        when "--main"          then @main_page     = arg
        when "--merge"         then @merge         = true
        when "--one-file"      then @all_one_file  = @inline_source = true
        when "--op"            then @op_dir        = arg
        when "--opname"        then @op_name       = arg
        when "--promiscuous"   then @promiscuous   = true
        when "--quiet"         then @quiet         = true
        when "--show-hash"     then @show_hash     = true
        when "--style"         then @css           = arg
        when "--template"      then @template      = arg
        when "--title"         then @title         = arg
        when "--webcvs"        then @webcvs        = arg

        when "--accessor" 
          arg.split(/,/).each do |accessor|
            if accessor =~ /^(\w+)(=(.*))?$/
              accessors << $1
              @extra_accessor_flags[$1] = $3
            end
          end

        when "--diagram"
          check_diagram
          @diagram = true

        when "--fileboxes"
          @fileboxes = true if @diagram

        when "--fmt"
          @generator_name = arg.downcase
          setup_generator(generators)

        when "--help"      
          OptionList.usage(generators.keys)

        when "--help-output"      
          OptionList.help_output

        when "--image-format"
          if ['gif', 'png', 'jpeg', 'jpg'].include?(arg)
            @image_format = arg
          else
            raise GetoptLong::InvalidOption.new("unknown image format: #{arg}")
          end

        when "--include"   
          @rdoc_include.concat arg.split(/\s*,\s*/)

        when "--ri", "--ri-site", "--ri-system"
          @generator_name = "ri"
          @op_dir = case opt
                    when "--ri" then RI::Paths::HOMEDIR 
                    when "--ri-site" then RI::Paths::SITEDIR
                    when "--ri-system" then RI::Paths::SYSDIR
                    else fail opt
                    end
          setup_generator(generators)

        when "--tab-width"
          begin
            @tab_width     = Integer(arg)
          rescue 
            $stderr.puts "Invalid tab width: '#{arg}'"
            exit 1
          end

        when "--extension"
          new, old = arg.split(/=/, 2)
          OptionList.error("Invalid parameter to '-E'") unless new && old
          unless RDoc::ParserFactory.alias_extension(old, new)
            OptionList.error("Unknown extension .#{old} to -E")
          end

        when "--version"
          puts VERSION_STRING
          exit
        end

      end

      @files = ARGV.dup

      @rdoc_include << "." if @rdoc_include.empty?

      if @exclude.empty?
        @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

      # Generate a regexp from the accessors
      unless accessors.empty?
        re = '^(' + accessors.map{|a| Regexp.quote(a)}.join('|') + ')$' 
        @extra_accessors = Regexp.new(re)
      end

    rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
      OptionList.error(error.message)

    ensure
      ARGV.replace(old_argv)
    end
  end

[Source]

# File rdoc/options.rb, line 506
  def title
    @title ||= "RDoc Documentation"
  end

Set the title, but only if not already set. This means that a title set from the command line trumps one set in a source file

[Source]

# File rdoc/options.rb, line 513
  def title=(string)
    @title ||= string
  end

[Validate]