@@ -149,32 +149,58 @@ class RDoc::Task < Rake::TaskLib
149149 # Create an RDoc task with the given name. See the RDoc::Task class overview
150150 # for documentation.
151151
152- def initialize ( name = :rdoc ) # :yield: self
153- if name . is_a? Hash then
154- invalid_options = name . keys . map { |k | k . to_sym } -
155- [ :rdoc , :clobber_rdoc , :rerdoc ]
156-
157- unless invalid_options . empty? then
158- raise ArgumentError , "invalid options: #{ invalid_options . join ( ", " ) } "
159- end
160- end
152+ def initialize name = :rdoc # :yield: self
153+ defaults
154+
155+ check_names name
161156
162157 @name = name
158+
159+ yield self if block_given?
160+
161+ define
162+ end
163+
164+ ##
165+ # Ensures that +names+ only includes names for the :rdoc, :clobber_rdoc and
166+ # :rerdoc. If other names are given an ArgumentError is raised.
167+
168+ def check_names names
169+ return unless Hash === names
170+
171+ invalid_options =
172+ names . keys . map { |k | k . to_sym } - [ :rdoc , :clobber_rdoc , :rerdoc ]
173+
174+ unless invalid_options . empty? then
175+ raise ArgumentError , "invalid options: #{ invalid_options . join ', ' } "
176+ end
177+ end
178+
179+ ##
180+ # Task description for the clobber rdoc task or its renamed equivalent
181+
182+ def clobber_task_description
183+ "Remove RDoc HTML files"
184+ end
185+
186+ ##
187+ # Sets default task values
188+
189+ def defaults
190+ @name = :rdoc
163191 @rdoc_files = Rake ::FileList . new
164192 @rdoc_dir = 'html'
165193 @main = nil
166194 @title = nil
167195 @template = nil
168196 @generator = nil
169197 @options = [ ]
170- yield self if block_given?
171- define
172198 end
173199
174200 ##
175201 # All source is inline now. This method is deprecated
176202
177- def inline_source ( ) # :nodoc:
203+ def inline_source # :nodoc:
178204 warn "RDoc::Task#inline_source is deprecated"
179205 true
180206 end
@@ -190,13 +216,13 @@ def inline_source=(value) # :nodoc:
190216 # Create the tasks defined by this task lib.
191217
192218 def define
193- desc "Build RDoc HTML files"
219+ desc rdoc_task_description
194220 task rdoc_task_name
195221
196- desc "Rebuild RDoc HTML files"
222+ desc rerdoc_task_description
197223 task rerdoc_task_name => [ clobber_task_name , rdoc_task_name ]
198224
199- desc "Remove RDoc HTML files"
225+ desc clobber_task_description
200226 task clobber_task_name do
201227 rm_r @rdoc_dir rescue nil
202228 end
@@ -215,11 +241,9 @@ def define
215241 @before_running_rdoc . call if @before_running_rdoc
216242 args = option_list + @rdoc_files
217243
218- if Rake . application . options . trace then
219- $stderr. puts "rdoc #{ args . join ' ' } "
220- end
244+ $stderr. puts "rdoc #{ args . join ' ' } " if Rake . application . options . trace
221245 require 'rdoc/rdoc'
222- RDoc ::RDoc . new . document ( args )
246+ RDoc ::RDoc . new . document args
223247 end
224248
225249 self
@@ -247,6 +271,20 @@ def before_running_rdoc(&block)
247271 @before_running_rdoc = block
248272 end
249273
274+ ##
275+ # Task description for the rdoc task or its renamed equivalent
276+
277+ def rdoc_task_description
278+ 'Build RDoc HTML files'
279+ end
280+
281+ ##
282+ # Task description for the rerdoc task or its renamed description
283+
284+ def rerdoc_task_description
285+ "Rebuild RDoc HTML files"
286+ end
287+
250288 private
251289
252290 def rdoc_target
0 commit comments