Name of file to be used as the main, top level file of the RDoc. (default is none)
Rake::TaskLib
Create a documentation task that will generate the RDoc files for a project.
The RDoc::Task will create the following targets:
Main task for this RDoc task.
Delete all the rdoc files. This target is automatically added to the main clobber target.
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.
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.
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
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
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
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
# 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
# File lib/rdoc/task.rb, line 221
221: def rdoc_target
222: "#{rdoc_dir}/index.html"
223: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.