In Files

Parent

RDoc::Task

Create a documentation task that will generate the RDoc files for a project.

The RDoc::Task will create the following targets:

rdoc

Main task for this RDoc task.

clobber_rdoc

Delete all the rdoc files. This target is automatically added to the main clobber target.

rerdoc

Rebuild the rdoc files from scratch, even if they are not out of date.

Simple Example:

  RDoc::Task.new do |rd|
    rd.main = "README.rdoc"
    rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
  end

The rd object passed to the block is an RDoc::Task object. See the attributes list for the RDoc::Task class for available customization options.

Specifying different task names

You may wish to give the task a different name, such as if you are generating two sets of documentation. For instance, if you want to have a development set of documentation including private methods:

  RDoc::Task.new :rdoc_dev do |rd|
    rd.main = "README.doc"
    rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
    rd.options << "--all"
  end

The tasks would then be named :rdoc_dev, :clobber_rdoc_dev, and :rerdoc_dev.

If you wish to have completely different task names, then pass a Hash as first argument. With the :rdoc, :clobber_rdoc and :rerdoc options, you can customize the task names to your liking.

For example:

  RDoc::Task.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean",
                 :rerdoc => "rdoc:force")

This will create the tasks :rdoc, :rdoc:clean and :rdoc:force.

Attributes

name[RW]

Name of the main, top level task. (default is :rdoc)

rdoc_dir[RW]

Name of directory to receive the html output files. (default is “html”)

title[RW]

Title of RDoc documentation. (defaults to rdoc’s default)

main[RW]

Name of file to be used as the main, top level file of the RDoc. (default is none)

template[RW]

Name of template to be used by rdoc. (defaults to rdoc’s default)

rdoc_files[RW]

List of files to be included in the rdoc generation. (default is [])

options[RW]

Additional list of options to be passed rdoc. (default is [])

external[RW]

Whether to run the rdoc process as an external shell (default is false)

Public Class Methods

new(name = :rdoc) click to toggle source

Create an RDoc task with the given name. See the RDoc::Task class overview for documentation.

     # File lib/rdoc/task.rb, line 138
138:   def initialize(name = :rdoc)  # :yield: self
139:     if name.is_a? Hash then
140:       invalid_options = name.keys.map { |k| k.to_sym } -
141:         [:rdoc, :clobber_rdoc, :rerdoc]
142: 
143:       unless invalid_options.empty? then
144:         raise ArgumentError, "invalid options: #{invalid_options.join(", ")}"
145:       end
146:     end
147: 
148:     @name = name
149:     @rdoc_files = Rake::FileList.new
150:     @rdoc_dir = 'html'
151:     @main = nil
152:     @title = nil
153:     @template = nil
154:     @options = []
155:     yield self if block_given?
156:     define
157:   end

Public Instance Methods

before_running_rdoc(&block) click to toggle source

The block passed to this method will be called just before running the RDoc generator. It is allowed to modify RDoc::Task attributes inside the block.

     # File lib/rdoc/task.rb, line 215
215:   def before_running_rdoc(&block)
216:     @before_running_rdoc = block
217:   end
define() click to toggle source

Create the tasks defined by this task lib.

     # File lib/rdoc/task.rb, line 162
162:   def define
163:     desc "Build RDoc HTML files"
164:     task rdoc_task_name
165: 
166:     desc "Rebuild RDoc HTML files"
167:     task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
168: 
169:     desc "Remove RDoc HTML files"
170:     task clobber_task_name do
171:       rm_r @rdoc_dir rescue nil
172:     end
173: 
174:     task :clobber => [clobber_task_name]
175: 
176:     directory @rdoc_dir
177: 
178:     rdoc_target_deps = [
179:       @rdoc_files,
180:       Rake.application.rakefile
181:     ].flatten.compact
182: 
183:     task rdoc_task_name => [rdoc_target]
184:     file rdoc_target => rdoc_target_deps do
185:       @before_running_rdoc.call if @before_running_rdoc
186:       args = option_list + @rdoc_files
187: 
188:       if Rake.application.options.trace then
189:         $stderr.puts "rdoc #{args.join ' '}"
190:       end
191:       require 'rdoc/rdoc'
192:       RDoc::RDoc.new.document(args)
193:     end
194: 
195:     self
196:   end
option_list() click to toggle source

List of options that will be supplied to RDoc

     # File lib/rdoc/task.rb, line 201
201:   def option_list
202:     result = @options.dup
203:     result << "-o"      << @rdoc_dir
204:     result << "--main"  << main     if main
205:     result << "--title" << title    if title
206:     result << "-T"      << template if template
207:     result
208:   end

Private Instance Methods

clobber_task_name() click to toggle source
     # File lib/rdoc/task.rb, line 232
232:   def clobber_task_name
233:     case name
234:     when Hash then (name[:clobber_rdoc] || "clobber_rdoc").to_s
235:     else           "clobber_#{name}"
236:     end
237:   end
rdoc_target() click to toggle source
     # File lib/rdoc/task.rb, line 221
221:   def rdoc_target
222:     "#{rdoc_dir}/index.html"
223:   end
rdoc_task_name() click to toggle source
     # File lib/rdoc/task.rb, line 225
225:   def rdoc_task_name
226:     case name
227:     when Hash then (name[:rdoc] || "rdoc").to_s
228:     else           name.to_s
229:     end
230:   end
rerdoc_task_name() click to toggle source
     # File lib/rdoc/task.rb, line 239
239:   def rerdoc_task_name
240:     case name
241:     when Hash then (name[:rerdoc] || "rerdoc").to_s
242:     else           "re#{name}"
243:     end
244:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.