summaryrefslogtreecommitdiff
path: root/lib/rdoc/task.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-02 00:32:30 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-02 00:32:30 +0000
commitcc2a16d94d744d14d4a5eb06eca22137f8a9b79e (patch)
tree2907a20e2d9ae3a2831707056bb3fe2d384b066d /lib/rdoc/task.rb
parent918f625a5eeba35b9b191cb39c1d634b4cc7efee (diff)
Import RDoc 3.5.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/task.rb')
-rw-r--r--lib/rdoc/task.rb76
1 files changed, 57 insertions, 19 deletions
diff --git a/lib/rdoc/task.rb b/lib/rdoc/task.rb
index 4a702e3fa8..ebf8ccc188 100644
--- a/lib/rdoc/task.rb
+++ b/lib/rdoc/task.rb
@@ -149,17 +149,45 @@ class RDoc::Task < Rake::TaskLib
# Create an RDoc task with the given name. See the RDoc::Task class overview
# for documentation.
- def initialize(name = :rdoc) # :yield: self
- if name.is_a? Hash then
- invalid_options = name.keys.map { |k| k.to_sym } -
- [:rdoc, :clobber_rdoc, :rerdoc]
-
- unless invalid_options.empty? then
- raise ArgumentError, "invalid options: #{invalid_options.join(", ")}"
- end
- end
+ def initialize name = :rdoc # :yield: self
+ defaults
+
+ check_names name
@name = name
+
+ yield self if block_given?
+
+ define
+ end
+
+ ##
+ # Ensures that +names+ only includes names for the :rdoc, :clobber_rdoc and
+ # :rerdoc. If other names are given an ArgumentError is raised.
+
+ def check_names names
+ return unless Hash === names
+
+ invalid_options =
+ names.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
+
+ unless invalid_options.empty? then
+ raise ArgumentError, "invalid options: #{invalid_options.join ', '}"
+ end
+ end
+
+ ##
+ # Task description for the clobber rdoc task or its renamed equivalent
+
+ def clobber_task_description
+ "Remove RDoc HTML files"
+ end
+
+ ##
+ # Sets default task values
+
+ def defaults
+ @name = :rdoc
@rdoc_files = Rake::FileList.new
@rdoc_dir = 'html'
@main = nil
@@ -167,14 +195,12 @@ class RDoc::Task < Rake::TaskLib
@template = nil
@generator = nil
@options = []
- yield self if block_given?
- define
end
##
# All source is inline now. This method is deprecated
- def inline_source() # :nodoc:
+ def inline_source # :nodoc:
warn "RDoc::Task#inline_source is deprecated"
true
end
@@ -190,13 +216,13 @@ class RDoc::Task < Rake::TaskLib
# Create the tasks defined by this task lib.
def define
- desc "Build RDoc HTML files"
+ desc rdoc_task_description
task rdoc_task_name
- desc "Rebuild RDoc HTML files"
+ desc rerdoc_task_description
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
- desc "Remove RDoc HTML files"
+ desc clobber_task_description
task clobber_task_name do
rm_r @rdoc_dir rescue nil
end
@@ -215,11 +241,9 @@ class RDoc::Task < Rake::TaskLib
@before_running_rdoc.call if @before_running_rdoc
args = option_list + @rdoc_files
- if Rake.application.options.trace then
- $stderr.puts "rdoc #{args.join ' '}"
- end
+ $stderr.puts "rdoc #{args.join ' '}" if Rake.application.options.trace
require 'rdoc/rdoc'
- RDoc::RDoc.new.document(args)
+ RDoc::RDoc.new.document args
end
self
@@ -247,6 +271,20 @@ class RDoc::Task < Rake::TaskLib
@before_running_rdoc = block
end
+ ##
+ # Task description for the rdoc task or its renamed equivalent
+
+ def rdoc_task_description
+ 'Build RDoc HTML files'
+ end
+
+ ##
+ # Task description for the rerdoc task or its renamed description
+
+ def rerdoc_task_description
+ "Rebuild RDoc HTML files"
+ end
+
private
def rdoc_target