diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-30 10:00:46 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-30 10:00:46 +0200 |
commit | ebcc4c5e746edcebdb58b27d3d54a51e685dd43a (patch) | |
tree | 6a88480dd5b86e6574ab72961d3f901261cc78a5 /railties/lib/rails | |
parent | f9e84a9e5ad35f8159a2edaffc8edb2535fbac40 (diff) | |
download | rails-ebcc4c5e746edcebdb58b27d3d54a51e685dd43a.tar.gz rails-ebcc4c5e746edcebdb58b27d3d54a51e685dd43a.tar.bz2 rails-ebcc4c5e746edcebdb58b27d3d54a51e685dd43a.zip |
Remove if/else branch when generating the documentation since we are simply inspecting the load path.
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/tasks/documentation.rake | 89 |
1 files changed, 37 insertions, 52 deletions
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index f15efbc30a..f73e333e83 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -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') - - 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 + 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('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 + 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('activemodel') do |activemodel| - %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{activemodel}/#{file}") - 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('activerecord') do |activerecord| - %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{activerecord}/#{file}") - 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('activeresource') do |activeresource| - %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| - rdoc.rdoc_files.include("#{activeresource}/#{file}") - 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('activesupport') do |activesupport| - %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{activesupport}/#{file}") - 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('railties') do |railties| - %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| - rdoc.rdoc_files.include("#{railties}/#{file}") - end + gem_path('activesupport') do |activesupport| + %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activesupport}/#{file}") 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" + 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 - end + } plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } |