class Detroit::RI

The ri documentation tool provides services for generating ri documentation.

By default it generates the ri documentaiton at `.rdoc`, unless an 'ri' directory exists in the project's root directory, in which case the ri documentation will be stored there.

Constants

DEFAULT_EXTRA

Default extra options to add to rdoc call.

DEFAULT_OUTPUT

Default location to store ri documentation files.

DEFAULT_OUTPUT_MATCH

Locations to check for existence in deciding where to store ri documentation.

MANPAGE

Location of manpage for tool.

Attributes

exclude[RW]

Paths to specifically exclude.

extra[RW]

Additional options passed to the rdoc command.

files[RW]

Which files to include.

output[RW]

Where to save rdoc files (doc/rdoc).

Public Instance Methods

assemble?(station, options={}) click to toggle source

This tool ties into the `document`, `reset`, `clean` and `purge` stations of the standard assembly.

@return [Boolean,Symbol]

# File lib/detroit-ri.rb, line 122
def assemble?(station, options={})
  return true if station == :document
  return true if station == :reset
  return true if station == :clean
  return true if station == :purge
  return false
end
clean() click to toggle source

A no-op, there are no residuals to remove.

# File lib/detroit-ri.rb, line 107
def clean
end
document() click to toggle source

Generate ri documentation. This utilizes rdoc to produce the appropriate files.

# File lib/detroit-ri.rb, line 67
def document
  output  = self.output
  input   = self.files
  exclude = self.exclude

  include_files = files.to_list.uniq
  exclude_files = exclude.to_list.uniq

  filelist = amass(include_files, exclude_files)

  if outofdate?(output, *filelist) or force?
    status "Generating #{output}"

    argv = ['--ri']
    argv.concat(extra.split(/\s+/))
    argv.concat ['--output', output]
    #argv.concat ['--exclude', exclude] unless exclude.empty?

    argv = argv + filelist

    dir = ri_target(output, argv)

    touch(output)

    output
  else
    status "RI docs are current (#{output})"
  end
end
prerequisite() click to toggle source
# File lib/detroit-ri.rb, line 36
def prerequisite
  # NOTE: Due to a bug in RDoc this needs to be done for now
  # so that alternate templates can be used.
  begin
    require 'rubygems'
    gem('rdoc')
  rescue LoadError
    $stderr.puts "Oh no! No modern rdoc!"
  end
  #require 'rdoc'
  require 'rdoc/rdoc'
end
purge() click to toggle source

Remove ri products.

# File lib/detroit-ri.rb, line 111
def purge
  if File.directory?(output)
    rm_r(output)
    report "Removed #{output}" #unless trial?
  end
end
reset() click to toggle source

Set the output directory's mtime to furthest time in past. This “marks” the documentation as out-of-date.

# File lib/detroit-ri.rb, line 99
def reset
  if File.directory?(output)
    File.utime(0,0,self.output)
    report "reset #{output}"
  end
end

Private Instance Methods

initialize_defaults() click to toggle source
Calls superclass method
# File lib/detroit-ri.rb, line 142
def initialize_defaults
  super

  @files  = metadata.loadpath
  @output = Dir[DEFAULT_OUTPUT_MATCH].first || DEFAULT_OUTPUT
  @extra  = DEFAULT_EXTRA
end
ri_target(output, argv=[]) click to toggle source

Generate ri docs for input targets.

TODO: Use RDoc programmatically rather than via shell.

# File lib/detroit-ri.rb, line 154
def ri_target(output, argv=[])
  rm_r(output) if exist?(output) and safe?(output)  # remove old ri docs

  if trial?
    puts "rdoc " + argv.join(" ")
  else
    trace "rdoc " + argv.join(" ") #if trace? or verbose?
    #silently do
    rdoc = ::RDoc::RDoc.new
    rdoc.document(argv)
    #end
  end
end