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.
-
document
-
reset
-
clean
-
purge
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
Paths to specifically exclude.
Additional options passed to the rdoc command.
Which files to include.
Where to save rdoc files (doc/rdoc).
Public Instance Methods
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
A no-op, there are no residuals to remove.
# File lib/detroit-ri.rb, line 107 def clean end
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
# 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
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
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
# 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
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