Class: Rake::RDocTask
Overview
Create a documentation task that will generate the RDoc files for a project.
The RDocTask 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:
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
end
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:
Rake::RDocTask.new(:rdoc_dev) do |rd|
rd.main = "README.doc"
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
rd. << "--all"
end
The tasks would then be named :rdoc_dev, :clobber_rdoc_dev, and :rerdoc_dev.
Instance Attribute Summary collapse
-
#main ⇒ Object
Name of file to be used as the main, top level file of the RDoc.
-
#name ⇒ Object
Name of the main, top level task.
-
#options ⇒ Object
List of options to be passed rdoc.
-
#rdoc_dir ⇒ Object
Name of directory to receive the html output files.
-
#rdoc_files ⇒ Object
List of files to be included in the rdoc generation.
-
#template ⇒ Object
Name of template to be used by rdoc.
-
#title ⇒ Object
Title of RDoc documentation.
Instance Method Summary collapse
-
#define ⇒ Object
Create the tasks defined by this task lib.
-
#initialize(name = :rdoc) {|_self| ... } ⇒ RDocTask
constructor
Create an RDoc task named rdoc.
- #option_list ⇒ Object
- #option_string ⇒ Object
Methods inherited from TaskLib
Methods included from Cloneable
Constructor Details
#initialize(name = :rdoc) {|_self| ... } ⇒ RDocTask
Create an RDoc task named rdoc. Default task name is rdoc
.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rake/rdoctask.rb', line 68 def initialize(name=:rdoc) # :yield: self @name = name @rdoc_files = Rake::FileList.new @rdoc_dir = 'html' @main = nil @title = nil @template = 'html' @options = [] yield self if block_given? define end |
Instance Attribute Details
#main ⇒ Object
Name of file to be used as the main, top level file of the RDoc. (default is none)
56 57 58 |
# File 'lib/rake/rdoctask.rb', line 56 def main @main end |
#name ⇒ Object
Name of the main, top level task. (default is :rdoc)
46 47 48 |
# File 'lib/rake/rdoctask.rb', line 46 def name @name end |
#options ⇒ Object
List of options to be passed rdoc. (default is [])
65 66 67 |
# File 'lib/rake/rdoctask.rb', line 65 def @options end |
#rdoc_dir ⇒ Object
Name of directory to receive the html output files. (default is “html”)
49 50 51 |
# File 'lib/rake/rdoctask.rb', line 49 def rdoc_dir @rdoc_dir end |
#rdoc_files ⇒ Object
List of files to be included in the rdoc generation. (default is [])
62 63 64 |
# File 'lib/rake/rdoctask.rb', line 62 def rdoc_files @rdoc_files end |
#template ⇒ Object
Name of template to be used by rdoc. (default is ‘html’)
59 60 61 |
# File 'lib/rake/rdoctask.rb', line 59 def template @template end |
#title ⇒ Object
Title of RDoc documentation. (default is none)
52 53 54 |
# File 'lib/rake/rdoctask.rb', line 52 def title @title end |
Instance Method Details
#define ⇒ Object
Create the tasks defined by this task lib.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/rake/rdoctask.rb', line 81 def define if name.to_s != "rdoc" desc "Build the RDOC HTML Files" end desc "Build the #{name} HTML Files" task name desc "Force a rebuild of the RDOC files" task paste("re", name) => [paste("clobber_", name), name] desc "Remove rdoc products" task paste("clobber_", name) do rm_r rdoc_dir rescue nil end task :clobber => [paste("clobber_", name)] directory @rdoc_dir task name => [rdoc_target] file rdoc_target => @rdoc_files + [$rakefile] do rm_r @rdoc_dir rescue nil opts = option_list.join(' ') sh %{rdoc -o #{@rdoc_dir} #{opts} #{@rdoc_files}} end self end |
#option_list ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/rake/rdoctask.rb', line 109 def option_list result = @options.dup result << "--main" << "'#{main}'" if main result << "--title" << "'#{title}'" if title result << "-T" << "'#{template}'" if template result end |
#option_string ⇒ Object
117 118 119 |
# File 'lib/rake/rdoctask.rb', line 117 def option_string option_list.join(' ') end |