25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/utilrb/doc/rake.rb', line 25
def self.doc(target = 'docs', options = Hash.new)
if target.kind_of?(Hash)
target, options = 'docs', target
end
options = Kernel.validate_options options,
:include => [File.join('lib', '**', '*.rb'), File.join('ext', '**', '*.cc')],
:exclude => [],
:target_dir => 'doc',
:title => '',
:plugins => [],
:files => []
case DOC_MODE
when 'yard'
task = YARD::Rake::YardocTask.new(target)
task.files.concat(options[:include])
task.options << '--title' << options[:title] << '--output-dir' << options[:target_dir]
if !options[:files].empty?
task.options << "--files" << options[:files].join(",")
end
options[:plugins].each do |plugin_name|
require "#{plugin_name}/yard"
end
task_clobber = ::Rake::Task.define_task "clobber_#{target}" do
FileUtils.rm_rf options[:target_dir]
end
task_clobber.add_description "Remove #{target} products"
name = ::Rake.application.current_scope.dup
if name.respond_to?(:path)
name = name.map(&:to_s).reverse
end
name << task.name
task_re = ::Rake::Task.define_task "re#{target}" do
FileUtils.rm_rf options[:target_dir]
::Rake::Task[name.join(":")].invoke
end
task_re.add_description "Force a rebuild of #{target}"
when "rdoc"
task = RDoc::Task.new(target)
task.rdoc_files.include(*options[:include])
task.rdoc_files.exclude(*options[:exclude])
task.title = options[:title]
task.rdoc_dir = File.expand_path(options[:target_dir])
else
[target, "re#{target}"].each do |task_name|
t = ::Rake::Task.define_task(task_name) do
STDERR.puts "Documentation generation is disabled: install either the yard or rdoc gems"
end
t.add_description "Disabled on this installation as neither yard nor rdoc are available"
end
end
end
|