rake 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rake might be problematic. Click here for more details.
- data/CHANGES +27 -0
- data/README +84 -173
- data/Rakefile +2 -4
- data/doc/command_line_usage.rdoc +102 -0
- data/doc/rakefile.rdoc +4 -4
- data/doc/release_notes/rake-0.8.4.rdoc +137 -0
- data/lib/rake.rb +43 -33
- data/lib/rake/contrib/publisher.rb +1 -1
- data/lib/rake/contrib/sys.rb +1 -1
- data/lib/rake/gempackagetask.rb +0 -6
- data/lib/rake/loaders/makefile.rb +8 -1
- data/lib/rake/packagetask.rb +0 -1
- data/lib/rake/rdoctask.rb +80 -18
- data/lib/rake/repaired_system.rb +145 -0
- data/lib/rake/testtask.rb +2 -2
- data/lib/rake/win32.rb +11 -9
- data/test/data/sample.mf +2 -0
- data/test/rake_test_setup.rb +14 -0
- data/test/session_functional.rb +2 -0
- data/test/test_application.rb +33 -14
- data/test/test_definitions.rb +4 -1
- data/test/test_file_task.rb +20 -16
- data/test/test_filelist.rb +3 -1
- data/test/test_fileutils.rb +31 -19
- data/test/test_invocation_chain.rb +8 -2
- data/test/test_makefile_loader.rb +2 -1
- data/test/test_namespace.rb +30 -11
- data/test/test_package_task.rb +3 -1
- data/test/test_pathmap.rb +3 -2
- data/test/test_rdoc_task.rb +88 -0
- data/test/test_require.rb +3 -1
- data/test/test_rules.rb +7 -5
- data/test/test_task_manager.rb +4 -1
- data/test/test_tasks.rb +6 -3
- data/test/test_test_task.rb +2 -0
- data/test/test_top_level_functions.rb +4 -2
- data/test/test_win32.rb +29 -14
- metadata +9 -3
data/doc/rakefile.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Rakefile Format (as of version 0.8.
|
1
|
+
= Rakefile Format (as of version 0.8.3)
|
2
2
|
|
3
3
|
First of all, there is no special format for a Rakefile. A Rakefile
|
4
4
|
contains executable Ruby code. Anything legal in a ruby script is
|
@@ -225,8 +225,8 @@ where we specify default values for the first and last names:
|
|
225
225
|
=== Tasks that Expect Parameters and Have Prerequisites
|
226
226
|
|
227
227
|
Tasks that use parameters have a slightly different format for
|
228
|
-
prerequisites. Use the
|
229
|
-
|
228
|
+
prerequisites. Use the arrow notation to indicate the prerequisites
|
229
|
+
for tasks with arguments. For example:
|
230
230
|
|
231
231
|
task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
|
232
232
|
args.with_defaults(:first_name => "John", :last_name => "Dough")
|
@@ -237,7 +237,7 @@ prerequisites for tasks with arguments. For example:
|
|
237
237
|
=== Deprecated Task Parameters Format
|
238
238
|
|
239
239
|
There is an older format for declaring task parameters that omitted
|
240
|
-
the task array and used the :needs keyword to introduce the
|
240
|
+
the task argument array and used the :needs keyword to introduce the
|
241
241
|
dependencies. That format is still supported for compatibility, but
|
242
242
|
is not recommended for use.
|
243
243
|
|
@@ -0,0 +1,137 @@
|
|
1
|
+
= Rake 0.8.4 Released
|
2
|
+
|
3
|
+
Rake version 0.8.4 is a bug-fix release of rake.
|
4
|
+
|
5
|
+
NOTE: The version of Rake that comes with Ruby 1.9 has diverged
|
6
|
+
slightly from the core Rake code base. Rake 0.8.4 will work
|
7
|
+
with Ruby 1.9, but is not a strict upgrade for the Rake that
|
8
|
+
comes with Ruby 1.9. A (near) future release of Rake will unify
|
9
|
+
those two codebases.
|
10
|
+
|
11
|
+
== Changes
|
12
|
+
|
13
|
+
=== New Features / Enhancements in Version 0.8.4
|
14
|
+
|
15
|
+
* Case is preserved on rakefile names. (patch from James
|
16
|
+
M. Lawrence/quix)
|
17
|
+
|
18
|
+
* Improved Rakefile case insensitivity testing (patch from Luis
|
19
|
+
Lavena).
|
20
|
+
|
21
|
+
* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH,
|
22
|
+
APPDATA, USERPROFILE (patch from Luis Lavena)
|
23
|
+
|
24
|
+
* MingGW is now recognized as a windows platform. (patch from Luis
|
25
|
+
Lavena)
|
26
|
+
|
27
|
+
=== Bug Fixes in Version 0.8.4
|
28
|
+
|
29
|
+
* Removed reference to manage_gem to fix the warning produced by the
|
30
|
+
gem package task.
|
31
|
+
|
32
|
+
* Fixed stray ARGV option problem that was interfering with
|
33
|
+
Test::Unit::Runner. (patch from Pivotal Labs)
|
34
|
+
|
35
|
+
=== Infrastructure Improvements in Version 0.8.4
|
36
|
+
|
37
|
+
* Numerous fixes to the windows test suite (patch from Luis Lavena).
|
38
|
+
|
39
|
+
* Improved Rakefile case insensitivity testing (patch from Luis
|
40
|
+
Lavena).
|
41
|
+
|
42
|
+
* Better support for windows paths in the test task (patch from Simon
|
43
|
+
Chiang/bahuvrihi)
|
44
|
+
|
45
|
+
== What is Rake
|
46
|
+
|
47
|
+
Rake is a build tool similar to the make program in many ways. But
|
48
|
+
instead of cryptic make recipes, Rake uses standard Ruby code to
|
49
|
+
declare tasks and dependencies. You have the full power of a modern
|
50
|
+
scripting language built right into your build tool.
|
51
|
+
|
52
|
+
== Availability
|
53
|
+
|
54
|
+
The easiest way to get and install rake is via RubyGems ...
|
55
|
+
|
56
|
+
gem install rake (you may need root/admin privileges)
|
57
|
+
|
58
|
+
Otherwise, you can get it from the more traditional places:
|
59
|
+
|
60
|
+
Home Page:: http://rake.rubyforge.org/
|
61
|
+
Download:: http://rubyforge.org/project/showfiles.php?group_id=50
|
62
|
+
GitHub:: git://github.com/jimweirich/rake.git
|
63
|
+
|
64
|
+
== Task Argument Examples
|
65
|
+
|
66
|
+
Prior to version 0.8.0, rake was only able to handle command line
|
67
|
+
arguments of the form NAME=VALUE that were passed into Rake via the
|
68
|
+
ENV hash. Many folks had asked for some kind of simple command line
|
69
|
+
arguments, perhaps using "--" to separate regular task names from
|
70
|
+
argument values on the command line. The problem is that there was no
|
71
|
+
easy way to associate positional arguments on the command line with
|
72
|
+
different tasks. Suppose both tasks :a and :b expect a command line
|
73
|
+
argument: does the first value go with :a? What if :b is run first?
|
74
|
+
Should it then get the first command line argument.
|
75
|
+
|
76
|
+
Rake 0.8.0 solves this problem by explicitly passing values directly
|
77
|
+
to the tasks that need them. For example, if I had a release task
|
78
|
+
that required a version number, I could say:
|
79
|
+
|
80
|
+
rake release[0.8.4]
|
81
|
+
|
82
|
+
And the string "0.8.4" will be passed to the :release task. Multiple
|
83
|
+
arguments can be passed by separating them with a comma, for example:
|
84
|
+
|
85
|
+
rake name[john,doe]
|
86
|
+
|
87
|
+
Just a few words of caution. The rake task name and its arguments
|
88
|
+
need to be a single command line argument to rake. This generally
|
89
|
+
means no spaces. If spaces are needed, then the entire rake +
|
90
|
+
argument string should be quoted. Something like this:
|
91
|
+
|
92
|
+
rake "name[billy bob, smith]"
|
93
|
+
|
94
|
+
(Quoting rules vary between operating systems and shells, so make sure
|
95
|
+
you consult the proper docs for your OS/shell).
|
96
|
+
|
97
|
+
=== Tasks that Expect Parameters
|
98
|
+
|
99
|
+
Parameters are only given to tasks that are setup to expect them. In
|
100
|
+
order to handle named parameters, the task declaration syntax for
|
101
|
+
tasks has been extended slightly.
|
102
|
+
|
103
|
+
For example, a task that needs a first name and last name might be
|
104
|
+
declared as:
|
105
|
+
|
106
|
+
task :name, :first_name, :last_name
|
107
|
+
|
108
|
+
The first argument is still the name of the task (:name in this case).
|
109
|
+
The next to argumements are the names of the parameters expected by
|
110
|
+
:name (:first_name and :last_name in the example).
|
111
|
+
|
112
|
+
To access the values of the paramters, the block defining the task
|
113
|
+
behaviour can now accept a second parameter:
|
114
|
+
|
115
|
+
task :name, :first_name, :last_name do |t, args|
|
116
|
+
puts "First name is #{args.first_name}"
|
117
|
+
puts "Last name is #{args.last_name}"
|
118
|
+
end
|
119
|
+
|
120
|
+
The first argument of the block "t" is always bound to the current
|
121
|
+
task object. The second argument "args" is an open-struct like object
|
122
|
+
that allows access to the task arguments. Extra command line
|
123
|
+
arguments to a task are ignored. Missing command line arguments are
|
124
|
+
given the nil value.
|
125
|
+
|
126
|
+
== Thanks
|
127
|
+
|
128
|
+
As usual, it was input from users that drove a alot of these changes. The
|
129
|
+
following people either contributed patches, made suggestions or made
|
130
|
+
otherwise helpful comments. Thanks to ...
|
131
|
+
|
132
|
+
* James M. Lawrence/quix
|
133
|
+
* Luis Lavena
|
134
|
+
* Pivotal Labs
|
135
|
+
* Simon Chiang/bahuvrihi
|
136
|
+
|
137
|
+
-- Jim Weirich
|
data/lib/rake.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#--
|
4
4
|
|
5
|
-
# Copyright
|
5
|
+
# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"), to
|
@@ -29,7 +29,7 @@
|
|
29
29
|
# as a library via a require statement, but it can be distributed
|
30
30
|
# independently as an application.
|
31
31
|
|
32
|
-
RAKEVERSION = '0.8.
|
32
|
+
RAKEVERSION = '0.8.4'
|
33
33
|
|
34
34
|
require 'rbconfig'
|
35
35
|
require 'fileutils'
|
@@ -74,7 +74,7 @@ end # module Module
|
|
74
74
|
#
|
75
75
|
class String
|
76
76
|
rake_extension("ext") do
|
77
|
-
# Replace the file extension with +newext+. If there is no
|
77
|
+
# Replace the file extension with +newext+. If there is no extension on
|
78
78
|
# the string, append the new extension to the end. If the new extension
|
79
79
|
# is not given, or is the empty string, remove any existing extension.
|
80
80
|
#
|
@@ -749,9 +749,7 @@ module Rake
|
|
749
749
|
# Is this file task needed? Yes if it doesn't exist, or if its time stamp
|
750
750
|
# is out of date.
|
751
751
|
def needed?
|
752
|
-
|
753
|
-
return true if out_of_date?(timestamp)
|
754
|
-
false
|
752
|
+
! File.exist?(name) || out_of_date?(timestamp)
|
755
753
|
end
|
756
754
|
|
757
755
|
# Time stamp for file task.
|
@@ -972,7 +970,7 @@ module FileUtils
|
|
972
970
|
}
|
973
971
|
end
|
974
972
|
if RakeFileUtils.verbose_flag == :default
|
975
|
-
options[:verbose] =
|
973
|
+
options[:verbose] = true
|
976
974
|
else
|
977
975
|
options[:verbose] ||= RakeFileUtils.verbose_flag
|
978
976
|
end
|
@@ -1463,8 +1461,8 @@ module Rake
|
|
1463
1461
|
collect { |fn| fn.pathmap(spec) }
|
1464
1462
|
end
|
1465
1463
|
|
1466
|
-
# Return a new
|
1467
|
-
# member of the array.
|
1464
|
+
# Return a new file list with <tt>String#ext</tt> method applied
|
1465
|
+
# to each member of the array.
|
1468
1466
|
#
|
1469
1467
|
# This method is a shortcut for:
|
1470
1468
|
#
|
@@ -1650,9 +1648,9 @@ module Rake
|
|
1650
1648
|
@task_manager.lookup(name, @scope)
|
1651
1649
|
end
|
1652
1650
|
|
1653
|
-
# Return the list of tasks defined in this
|
1651
|
+
# Return the list of tasks defined in this and nested namespaces.
|
1654
1652
|
def tasks
|
1655
|
-
@task_manager.
|
1653
|
+
@task_manager.tasks_in_scope(@scope)
|
1656
1654
|
end
|
1657
1655
|
end # NameSpace
|
1658
1656
|
|
@@ -1797,6 +1795,15 @@ module Rake
|
|
1797
1795
|
@tasks.values.sort_by { |t| t.name }
|
1798
1796
|
end
|
1799
1797
|
|
1798
|
+
# List of all the tasks defined in the given scope (and its
|
1799
|
+
# sub-scopes).
|
1800
|
+
def tasks_in_scope(scope)
|
1801
|
+
prefix = scope.join(":")
|
1802
|
+
tasks.select { |t|
|
1803
|
+
/^#{prefix}:/ =~ t.name
|
1804
|
+
}
|
1805
|
+
end
|
1806
|
+
|
1800
1807
|
# Clear all tasks in this application.
|
1801
1808
|
def clear
|
1802
1809
|
@tasks.clear
|
@@ -1975,7 +1982,8 @@ module Rake
|
|
1975
1982
|
def init(app_name='rake')
|
1976
1983
|
standard_exception_handling do
|
1977
1984
|
@name = app_name
|
1978
|
-
|
1985
|
+
handle_options
|
1986
|
+
collect_tasks
|
1979
1987
|
end
|
1980
1988
|
end
|
1981
1989
|
|
@@ -2042,7 +2050,7 @@ module Rake
|
|
2042
2050
|
exit(1)
|
2043
2051
|
rescue Exception => ex
|
2044
2052
|
# Exit with error message
|
2045
|
-
$stderr.puts "
|
2053
|
+
$stderr.puts "#{name} aborted!"
|
2046
2054
|
$stderr.puts ex.message
|
2047
2055
|
if options.trace
|
2048
2056
|
$stderr.puts ex.backtrace.join("\n")
|
@@ -2058,7 +2066,10 @@ module Rake
|
|
2058
2066
|
# If a match is found, it is copied into @rakefile.
|
2059
2067
|
def have_rakefile
|
2060
2068
|
@rakefiles.each do |fn|
|
2061
|
-
if File.exist?(fn)
|
2069
|
+
if File.exist?(fn)
|
2070
|
+
others = Dir.glob(fn, File::FNM_CASEFOLD)
|
2071
|
+
return others.size == 1 ? others.first : fn
|
2072
|
+
elsif fn == ''
|
2062
2073
|
return fn
|
2063
2074
|
end
|
2064
2075
|
end
|
@@ -2081,14 +2092,14 @@ module Rake
|
|
2081
2092
|
tty_output? || ENV['RAKE_COLUMNS']
|
2082
2093
|
end
|
2083
2094
|
|
2084
|
-
# Display the tasks and
|
2095
|
+
# Display the tasks and comments.
|
2085
2096
|
def display_tasks_and_comments
|
2086
2097
|
displayable_tasks = tasks.select { |t|
|
2087
2098
|
t.comment && t.name =~ options.show_task_pattern
|
2088
2099
|
}
|
2089
2100
|
if options.full_description
|
2090
2101
|
displayable_tasks.each do |t|
|
2091
|
-
puts "
|
2102
|
+
puts "#{name} #{t.name_with_args}"
|
2092
2103
|
t.full_comment.split("\n").each do |line|
|
2093
2104
|
puts " #{line}"
|
2094
2105
|
end
|
@@ -2147,7 +2158,7 @@ module Rake
|
|
2147
2158
|
# Display the tasks and prerequisites
|
2148
2159
|
def display_prerequisites
|
2149
2160
|
tasks.each do |t|
|
2150
|
-
puts "
|
2161
|
+
puts "#{name} #{t.name}"
|
2151
2162
|
t.prerequisites.each { |pre| puts " #{pre}" }
|
2152
2163
|
end
|
2153
2164
|
end
|
@@ -2259,7 +2270,7 @@ module Rake
|
|
2259
2270
|
verbose(true)
|
2260
2271
|
}
|
2261
2272
|
],
|
2262
|
-
['--verbose', '-v', "Log message to standard output
|
2273
|
+
['--verbose', '-v', "Log message to standard output.",
|
2263
2274
|
lambda { |value| verbose(true) }
|
2264
2275
|
],
|
2265
2276
|
['--version', '-V', "Display the program version.",
|
@@ -2275,18 +2286,18 @@ module Rake
|
|
2275
2286
|
def handle_options
|
2276
2287
|
options.rakelib = ['rakelib']
|
2277
2288
|
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2289
|
+
OptionParser.new do |opts|
|
2290
|
+
opts.banner = "rake [-f rakefile] {options} targets..."
|
2291
|
+
opts.separator ""
|
2292
|
+
opts.separator "Options are ..."
|
2293
|
+
|
2294
|
+
opts.on_tail("-h", "--help", "-H", "Display this help message.") do
|
2295
|
+
puts opts
|
2296
|
+
exit
|
2297
|
+
end
|
2298
|
+
|
2299
|
+
standard_rake_options.each { |args| opts.on(*args) }
|
2300
|
+
end.parse!
|
2290
2301
|
|
2291
2302
|
# If class namespaces are requested, set the global options
|
2292
2303
|
# according to the values in the options structure.
|
@@ -2297,7 +2308,6 @@ module Rake
|
|
2297
2308
|
$dryrun = options.dryrun
|
2298
2309
|
$silent = options.silent
|
2299
2310
|
end
|
2300
|
-
parsed_argv
|
2301
2311
|
end
|
2302
2312
|
|
2303
2313
|
# Similar to the regular Ruby +require+ command, but will check
|
@@ -2384,9 +2394,9 @@ module Rake
|
|
2384
2394
|
# Collect the list of tasks on the command line. If no tasks are
|
2385
2395
|
# given, return a list containing only the default task.
|
2386
2396
|
# Environmental assignments are processed at this time as well.
|
2387
|
-
def collect_tasks
|
2397
|
+
def collect_tasks
|
2388
2398
|
@top_level_tasks = []
|
2389
|
-
|
2399
|
+
ARGV.each do |arg|
|
2390
2400
|
if arg =~ /^(\w+)=(.*)$/
|
2391
2401
|
ENV[$1] = $2
|
2392
2402
|
else
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Copyright 2003, 2004 by Jim Weirich (jim@weirichhouse.org)
|
3
|
+
# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
|
4
4
|
# All rights reserved.
|
5
5
|
|
6
6
|
# Permission is granted for use, copying, modification, distribution,
|
data/lib/rake/contrib/sys.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright
|
4
|
+
# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|
data/lib/rake/gempackagetask.rb
CHANGED
@@ -9,12 +9,6 @@ require 'rake/packagetask'
|
|
9
9
|
require 'rubygems/user_interaction'
|
10
10
|
require 'rubygems/builder'
|
11
11
|
|
12
|
-
begin
|
13
|
-
Gem.manage_gems
|
14
|
-
rescue NoMethodError => ex
|
15
|
-
# Using rubygems prior to 0.6.1
|
16
|
-
end
|
17
|
-
|
18
12
|
module Rake
|
19
13
|
|
20
14
|
# Create a package based upon a Gem spec. Gem packages, as well as
|
@@ -4,11 +4,13 @@ module Rake
|
|
4
4
|
|
5
5
|
# Makefile loader to be used with the import file loader.
|
6
6
|
class MakefileLoader
|
7
|
+
SPACE_MARK = "__&NBSP;__"
|
7
8
|
|
8
9
|
# Load the makefile dependencies in +fn+.
|
9
10
|
def load(fn)
|
10
11
|
open(fn) do |mf|
|
11
12
|
lines = mf.read
|
13
|
+
lines.gsub!(/\\ /, SPACE_MARK)
|
12
14
|
lines.gsub!(/#[^\n]*\n/m, "")
|
13
15
|
lines.gsub!(/\\\n/, ' ')
|
14
16
|
lines.split("\n").each do |line|
|
@@ -23,11 +25,16 @@ module Rake
|
|
23
25
|
def process_line(line)
|
24
26
|
file_tasks, args = line.split(':')
|
25
27
|
return if args.nil?
|
26
|
-
dependents = args.split
|
28
|
+
dependents = args.split.map { |d| respace(d) }
|
27
29
|
file_tasks.strip.split.each do |file_task|
|
30
|
+
file_task = respace(file_task)
|
28
31
|
file file_task => dependents
|
29
32
|
end
|
30
33
|
end
|
34
|
+
|
35
|
+
def respace(str)
|
36
|
+
str.gsub(/#{SPACE_MARK}/, ' ')
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
# Install the handler
|
data/lib/rake/packagetask.rb
CHANGED
data/lib/rake/rdoctask.rb
CHANGED
@@ -10,7 +10,7 @@ module Rake
|
|
10
10
|
#
|
11
11
|
# The RDocTask will create the following targets:
|
12
12
|
#
|
13
|
-
# [<b
|
13
|
+
# [<b>:<em>rdoc</em></b>]
|
14
14
|
# Main task for this RDOC task.
|
15
15
|
#
|
16
16
|
# [<b>:clobber_<em>rdoc</em></b>]
|
@@ -21,13 +21,18 @@ module Rake
|
|
21
21
|
# Rebuild the rdoc files from scratch, even if they are not out
|
22
22
|
# of date.
|
23
23
|
#
|
24
|
-
# Simple
|
24
|
+
# Simple example:
|
25
25
|
#
|
26
26
|
# Rake::RDocTask.new do |rd|
|
27
27
|
# rd.main = "README.rdoc"
|
28
28
|
# rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
29
29
|
# end
|
30
30
|
#
|
31
|
+
# The +rd+ object passed to the block is an RDocTask object. See the
|
32
|
+
# attributes list for the RDocTask class for available customization options.
|
33
|
+
#
|
34
|
+
# == Specifying different task names
|
35
|
+
#
|
31
36
|
# You may wish to give the task a different name, such as if you are
|
32
37
|
# generating two sets of documentation. For instance, if you want to have a
|
33
38
|
# development set of documentation including private methods:
|
@@ -39,7 +44,17 @@ module Rake
|
|
39
44
|
# end
|
40
45
|
#
|
41
46
|
# The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
|
42
|
-
# :re<em>rdoc_dev</em>.
|
47
|
+
# :re<em>rdoc_dev</em>.
|
48
|
+
#
|
49
|
+
# If you wish to have completely different task names, then pass a Hash as
|
50
|
+
# first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
|
51
|
+
# <tt>:rerdoc</tt> options, you can customize the task names to your liking.
|
52
|
+
# For example:
|
53
|
+
#
|
54
|
+
# Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
|
55
|
+
#
|
56
|
+
# This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
|
57
|
+
# <tt>:rdoc:force</tt>.
|
43
58
|
#
|
44
59
|
class RDocTask < TaskLib
|
45
60
|
# Name of the main, top level task. (default is :rdoc)
|
@@ -48,7 +63,7 @@ module Rake
|
|
48
63
|
# Name of directory to receive the html output files. (default is "html")
|
49
64
|
attr_accessor :rdoc_dir
|
50
65
|
|
51
|
-
# Title of RDoc documentation. (
|
66
|
+
# Title of RDoc documentation. (defaults to rdoc's default)
|
52
67
|
attr_accessor :title
|
53
68
|
|
54
69
|
# Name of file to be used as the main, top level file of the
|
@@ -61,14 +76,24 @@ module Rake
|
|
61
76
|
# List of files to be included in the rdoc generation. (default is [])
|
62
77
|
attr_accessor :rdoc_files
|
63
78
|
|
64
|
-
#
|
79
|
+
# Additional list of options to be passed rdoc. (default is [])
|
65
80
|
attr_accessor :options
|
66
81
|
|
67
|
-
#
|
82
|
+
# Whether to run the rdoc process as an external shell (default is false)
|
68
83
|
attr_accessor :external
|
69
|
-
|
70
|
-
|
71
|
-
|
84
|
+
|
85
|
+
attr_accessor :inline_source
|
86
|
+
|
87
|
+
# Create an RDoc task with the given name. See the RDocTask class overview
|
88
|
+
# for documentation.
|
89
|
+
def initialize(name = :rdoc) # :yield: self
|
90
|
+
if name.is_a?(Hash)
|
91
|
+
invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
|
92
|
+
if !invalid_options.empty?
|
93
|
+
raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
72
97
|
@name = name
|
73
98
|
@rdoc_files = Rake::FileList.new
|
74
99
|
@rdoc_dir = 'html'
|
@@ -76,6 +101,7 @@ module Rake
|
|
76
101
|
@title = nil
|
77
102
|
@template = nil
|
78
103
|
@external = false
|
104
|
+
@inline_source = true
|
79
105
|
@options = []
|
80
106
|
yield self if block_given?
|
81
107
|
define
|
@@ -83,27 +109,28 @@ module Rake
|
|
83
109
|
|
84
110
|
# Create the tasks defined by this task lib.
|
85
111
|
def define
|
86
|
-
if
|
112
|
+
if rdoc_task_name != "rdoc"
|
87
113
|
desc "Build the RDOC HTML Files"
|
114
|
+
else
|
115
|
+
desc "Build the #{rdoc_task_name} HTML Files"
|
88
116
|
end
|
89
|
-
|
90
|
-
desc "Build the #{name} HTML Files"
|
91
|
-
task name
|
117
|
+
task rdoc_task_name
|
92
118
|
|
93
119
|
desc "Force a rebuild of the RDOC files"
|
94
|
-
task
|
120
|
+
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
|
95
121
|
|
96
122
|
desc "Remove rdoc products"
|
97
|
-
task
|
123
|
+
task clobber_task_name do
|
98
124
|
rm_r rdoc_dir rescue nil
|
99
125
|
end
|
100
126
|
|
101
|
-
task :clobber => [
|
127
|
+
task :clobber => [clobber_task_name]
|
102
128
|
|
103
129
|
directory @rdoc_dir
|
104
|
-
task
|
130
|
+
task rdoc_task_name => [rdoc_target]
|
105
131
|
file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
|
106
132
|
rm_r @rdoc_dir rescue nil
|
133
|
+
@before_running_rdoc.call if @before_running_rdoc
|
107
134
|
args = option_list + @rdoc_files
|
108
135
|
if @external
|
109
136
|
argstring = args.join(' ')
|
@@ -122,6 +149,7 @@ module Rake
|
|
122
149
|
result << "--main" << quote(main) if main
|
123
150
|
result << "--title" << quote(title) if title
|
124
151
|
result << "-T" << quote(template) if template
|
152
|
+
result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
|
125
153
|
result
|
126
154
|
end
|
127
155
|
|
@@ -136,12 +164,46 @@ module Rake
|
|
136
164
|
def option_string
|
137
165
|
option_list.join(' ')
|
138
166
|
end
|
167
|
+
|
168
|
+
# The block passed to this method will be called just before running the
|
169
|
+
# RDoc generator. It is allowed to modify RDocTask attributes inside the
|
170
|
+
# block.
|
171
|
+
def before_running_rdoc(&block)
|
172
|
+
@before_running_rdoc = block
|
173
|
+
end
|
139
174
|
|
140
175
|
private
|
141
|
-
|
176
|
+
|
142
177
|
def rdoc_target
|
143
178
|
"#{rdoc_dir}/index.html"
|
144
179
|
end
|
180
|
+
|
181
|
+
def rdoc_task_name
|
182
|
+
case name
|
183
|
+
when Hash
|
184
|
+
(name[:rdoc] || "rdoc").to_s
|
185
|
+
else
|
186
|
+
name.to_s
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def clobber_task_name
|
191
|
+
case name
|
192
|
+
when Hash
|
193
|
+
(name[:clobber_rdoc] || "clobber_rdoc").to_s
|
194
|
+
else
|
195
|
+
"clobber_#{name}"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def rerdoc_task_name
|
200
|
+
case name
|
201
|
+
when Hash
|
202
|
+
(name[:rerdoc] || "rerdoc").to_s
|
203
|
+
else
|
204
|
+
"re#{name}"
|
205
|
+
end
|
206
|
+
end
|
145
207
|
|
146
208
|
end
|
147
209
|
end
|