1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove if/else branch when generating the documentation since we are simply inspecting the load path.

This commit is contained in:
José Valim 2010-03-30 10:00:46 +02:00
parent f9e84a9e5a
commit ebcc4c5e74

View file

@ -1,10 +1,7 @@
namespace :doc do
def gem_path(gem_name)
path = $LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first
if path
yield File.dirname(path)
end
yield File.dirname(path) if path
end
desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
@ -19,68 +16,56 @@ namespace :doc do
rdoc.rdoc_files.include('lib/**/*.rb')
}
desc 'Generate documentation for the Rails framework. Uses gem paths or the RAILS_PATH environment variable.'
path = ENV['RAILS_PATH']
if defined?(Bundler) || (path && File.directory?(path))
desc 'Generate documentation for the Rails framework.'
Rake::RDocTask.new("rails") { |rdoc|
rdoc.rdoc_dir = 'doc/api'
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
rdoc.title = "Rails Framework Documentation"
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
desc 'Generate documentation for the Rails framework.'
Rake::RDocTask.new("rails") { |rdoc|
rdoc.rdoc_dir = 'doc/api'
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
rdoc.title = "Rails Framework Documentation"
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
gem_path('actionmailer') do |actionmailer|
%w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|
rdoc.rdoc_files.include("#{actionmailer}/#{file}")
end
end
gem_path('actionpack') do |actionpack|
%w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{actionpack}/#{file}")
end
end
gem_path('activemodel') do |activemodel|
%w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{activemodel}/#{file}")
end
end
gem_path('activerecord') do |activerecord|
%w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{activerecord}/#{file}")
end
end
gem_path('activeresource') do |activeresource|
%w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
rdoc.rdoc_files.include("#{activeresource}/#{file}")
end
end
gem_path('activesupport') do |activesupport|
%w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{activesupport}/#{file}")
end
end
gem_path('railties') do |railties|
%w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
rdoc.rdoc_files.include("#{railties}/#{file}")
end
end
}
else
task :rails do
if path = ENV['RAILS_PATH']
$stderr.puts "Skipping doc:rails, missing Rails directory at #{path.inspect}"
else
$stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set"
gem_path('actionmailer') do |actionmailer|
%w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|
rdoc.rdoc_files.include("#{actionmailer}/#{file}")
end
end
end
gem_path('actionpack') do |actionpack|
%w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{actionpack}/#{file}")
end
end
gem_path('activemodel') do |activemodel|
%w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{activemodel}/#{file}")
end
end
gem_path('activerecord') do |activerecord|
%w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{activerecord}/#{file}")
end
end
gem_path('activeresource') do |activeresource|
%w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
rdoc.rdoc_files.include("#{activeresource}/#{file}")
end
end
gem_path('activesupport') do |activesupport|
%w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
rdoc.rdoc_files.include("#{activesupport}/#{file}")
end
end
gem_path('railties') do |railties|
%w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
rdoc.rdoc_files.include("#{railties}/#{file}")
end
end
}
plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }