Permalink
Browse files

Revert "Rake task for generating Rails documentation updated to suppo…

…rt Bundler."

Incredibly slow. Fix gem_path to not load the bundle fresh each call.

This reverts commit 58796dc.
  • Loading branch information...
1 parent 8b4dca1 commit d56e8be22d50e439b75f13d8b581e24177cd76b7 @jeremy jeremy committed Mar 11, 2010
Showing with 41 additions and 33 deletions.
  1. +41 −33 railties/lib/rails/tasks/documentation.rake
@@ -1,8 +1,4 @@
namespace :doc do
- def gem_path(gem_name)
- Bundler.load.specs.find{|s| s.name == gem_name}.full_gem_path
- end
-
desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
Rake::RDocTask.new("app") { |rdoc|
rdoc.rdoc_dir = 'doc/app'
@@ -15,42 +11,54 @@ namespace :doc do
rdoc.rdoc_files.include('lib/**/*.rb')
}
- 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')
-
- %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|
- rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}")
+ desc 'Generate documentation for the Rails framework. Specify path with RAILS_PATH="/path/to/rails"'
+ path = ENV['RAILS_PATH']
+ unless path && File.directory?(path)
+ task :rails do
+ if path
+ $stderr.puts "Skipping doc:rails, missing Rails directory at #{path}"
+ else
+ $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set"
+ end
end
+ else
+ Rake::RDocTask.new("rails") { |rdoc|
+ version = "-#{Rails::VERSION::STRING}" unless ENV['RAILS_PATH']
+ 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')
+
+ %w(README CHANGELOG lib/action_mailer/base.rb).each do |file|
+ rdoc.rdoc_files.include("#{path}/actionmailer#{version}/#{file}")
+ 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}")
- end
+ %w(README CHANGELOG lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
+ rdoc.rdoc_files.include("#{path}/actionpack#{version}/#{file}")
+ end
- %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}")
- end
+ %w(README CHANGELOG lib/active_model/**/*.rb).each do |file|
+ rdoc.rdoc_files.include("#{path}/activemodel#{version}/#{file}")
+ end
- %w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}")
- end
+ %w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
+ rdoc.rdoc_files.include("#{path}/activerecord#{version}/#{file}")
+ end
- %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
- rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}")
- end
+ %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
+ rdoc.rdoc_files.include("#{path}/activeresource#{version}/#{file}")
+ end
- %w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}")
- end
+ %w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
+ rdoc.rdoc_files.include("#{path}/activesupport#{version}/#{file}")
+ end
- %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
- rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}")
- end
- }
+ %w(README CHANGELOG MIT-LICENSE lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
+ rdoc.rdoc_files.include("#{path}/railties#{version}/#{file}")
+ end
+ }
+ end
plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }

4 comments on commit d56e8be

Contributor

rizwanreza replied Mar 13, 2010

Any ideas on how to make this faster? I did load the path into an instance variable at first but we need it each time because of the different gems.

Let me know.

Cache specs = Bundler.load.specs once. For each group, first cache group_gem_path = specs.find{|s| s.name == gem_name}.full_gem_path before the each block. Within the each block in each group, use the cached group_gem_path rather than path or calling gem_path('railties').

Contributor

rizwanreza replied Mar 13, 2010

Any ideas on how to make this faster? I did load the path into an instance variable at first but we need it each time because of the different gems.

Let me know.

Contributor

rizwanreza replied Mar 13, 2010

That seems nice, thanks yfeldblum. I'll try that out.

Please sign in to comment.