diff options
author | postmodern <postmodern.mod3@gmail.com> | 2010-03-29 23:42:52 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-30 09:58:39 +0200 |
commit | f9e84a9e5ad35f8159a2edaffc8edb2535fbac40 (patch) | |
tree | f947bd6bdd7c57e671233a8f064ce8c1a9ffea6f /railties/lib/rails/tasks | |
parent | bc298152f8cc507549a9df9363e8da1900578932 (diff) | |
download | rails-f9e84a9e5ad35f8159a2edaffc8edb2535fbac40.tar.gz rails-f9e84a9e5ad35f8159a2edaffc8edb2535fbac40.tar.bz2 rails-f9e84a9e5ad35f8159a2edaffc8edb2535fbac40.zip |
Changed gem_path to yield the path found in $LOAD_PATH to a block.
* This allows gems not found in $LOAD_PATH to be safely ignored by the
rails documentation task.
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/lib/rails/tasks')
-rw-r--r-- | railties/lib/rails/tasks/documentation.rake | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index 1b44f9a46c..f15efbc30a 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,6 +1,10 @@ namespace :doc do def gem_path(gem_name) - File.dirname($LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first) + path = $LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first + + if path + yield File.dirname(path) + end end desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" @@ -26,32 +30,46 @@ namespace :doc do rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_files.include('README') - %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}") + 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 - %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}") + 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 - %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}") + 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 - %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}") + gem_path('activerecord') do |activerecord| + %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activerecord}/#{file}") + end end - %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| - rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}") + 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 - %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}") + gem_path('activesupport') do |activesupport| + %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activesupport}/#{file}") + end end - %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| - rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") + 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 |