Class: Detroit::RI

Inherits:
Tool
  • Object
show all
Includes:
Standard
Defined in:
lib/detroit-ri.rb

Overview

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.

  • document

  • reset

  • clean

  • purge

Constant Summary collapse

MANPAGE =

Location of manpage for tool.

File.dirname(__FILE__) + '/../man/detroit-ri.5'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#excludeObject

Paths to specifically exclude.



59
60
61
# File 'lib/detroit-ri.rb', line 59

def exclude
  @exclude
end

#extraObject

Additional options passed to the rdoc command.



62
63
64
# File 'lib/detroit-ri.rb', line 62

def extra
  @extra
end

#filesObject

Which files to include.



53
54
55
# File 'lib/detroit-ri.rb', line 53

def files
  @files
end

#outputObject

Where to save rdoc files (doc/rdoc).



50
51
52
# File 'lib/detroit-ri.rb', line 50

def output
  @output
end

Instance Method Details

#assemble?(station, options = {}) ⇒ Boolean, Symbol

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

Returns:

  • (Boolean, Symbol)


122
123
124
125
126
127
128
# 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

#cleanObject

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



107
108
# File 'lib/detroit-ri.rb', line 107

def clean
end

#documentObject

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



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 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

#prerequisiteObject



36
37
38
39
40
41
42
43
44
45
46
47
# 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

#purgeObject

Remove ri products.



111
112
113
114
115
116
# File 'lib/detroit-ri.rb', line 111

def purge
  if File.directory?(output)
    rm_r(output)
    report "Removed #{output}" #unless trial?
  end
end

#resetObject

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



99
100
101
102
103
104
# File 'lib/detroit-ri.rb', line 99

def reset
  if File.directory?(output)
    File.utime(0,0,self.output)
    report "reset #{output}"
  end
end