@@ -149,32 +149,58 @@ class RDoc::Task < Rake::TaskLib
149
149
# Create an RDoc task with the given name. See the RDoc::Task class overview
150
150
# for documentation.
151
151
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
161
156
162
157
@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
163
191
@rdoc_files = Rake ::FileList . new
164
192
@rdoc_dir = 'html'
165
193
@main = nil
166
194
@title = nil
167
195
@template = nil
168
196
@generator = nil
169
197
@options = [ ]
170
- yield self if block_given?
171
- define
172
198
end
173
199
174
200
##
175
201
# All source is inline now. This method is deprecated
176
202
177
- def inline_source ( ) # :nodoc:
203
+ def inline_source # :nodoc:
178
204
warn "RDoc::Task#inline_source is deprecated"
179
205
true
180
206
end
@@ -190,13 +216,13 @@ def inline_source=(value) # :nodoc:
190
216
# Create the tasks defined by this task lib.
191
217
192
218
def define
193
- desc "Build RDoc HTML files"
219
+ desc rdoc_task_description
194
220
task rdoc_task_name
195
221
196
- desc "Rebuild RDoc HTML files"
222
+ desc rerdoc_task_description
197
223
task rerdoc_task_name => [ clobber_task_name , rdoc_task_name ]
198
224
199
- desc "Remove RDoc HTML files"
225
+ desc clobber_task_description
200
226
task clobber_task_name do
201
227
rm_r @rdoc_dir rescue nil
202
228
end
@@ -215,11 +241,9 @@ def define
215
241
@before_running_rdoc . call if @before_running_rdoc
216
242
args = option_list + @rdoc_files
217
243
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
221
245
require 'rdoc/rdoc'
222
- RDoc ::RDoc . new . document ( args )
246
+ RDoc ::RDoc . new . document args
223
247
end
224
248
225
249
self
@@ -247,6 +271,20 @@ def before_running_rdoc(&block)
247
271
@before_running_rdoc = block
248
272
end
249
273
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
+
250
288
private
251
289
252
290
def rdoc_target
0 commit comments