From de2b0147d04d5460e576cc21afbb062eb012ea7e Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Wed, 10 Mar 2010 21:14:27 +0330 Subject: Reapply Rizwan's patch, but memoize Bundler.load.specs in an ivar. [#3697 state:resolved] Signed-off-by: wycats --- railties/lib/rails/tasks/documentation.rake | 75 +++++++++++++---------------- 1 file changed, 34 insertions(+), 41 deletions(-) (limited to 'railties/lib/rails/tasks/documentation.rake') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index f2fee45594..1c5db25952 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,4 +1,9 @@ namespace :doc do + def gem_path(gem_name) + @specs ||= Bundler.load.specs + @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' @@ -11,54 +16,42 @@ namespace :doc do rdoc.rdoc_files.include('lib/**/*.rb') } - 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 + 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}") 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 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/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}") + end - %w(README CHANGELOG lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{path}/activemodel#{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_record/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{path}/activerecord#{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_resource.rb lib/active_resource/*).each do |file| - rdoc.rdoc_files.include("#{path}/activeresource#{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_support/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{path}/activesupport#{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 MIT-LICENSE lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| - rdoc.rdoc_files.include("#{path}/railties#{version}/#{file}") - end - } - end + %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| + rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") + end + } plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } -- cgit v1.2.3 From af8852d1ad904b6b8925dd2ac7d6cece11f7bbba Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 29 Mar 2010 16:25:52 -0700 Subject: Work without bundler --- railties/lib/rails/tasks/documentation.rake | 77 +++++++++++++++++------------ 1 file changed, 46 insertions(+), 31 deletions(-) (limited to 'railties/lib/rails/tasks/documentation.rake') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index 1c5db25952..ff66b71dad 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,7 +1,11 @@ namespace :doc do def gem_path(gem_name) - @specs ||= Bundler.load.specs - @specs.find{|s| s.name == gem_name}.full_gem_path + if defined? Bundler + @specs ||= Bundler.load.specs + @specs.find{|s| s.name == gem_name}.full_gem_path + else + "#{ENV['RAILS_PATH']}/#{gem_name}" + end end desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" @@ -16,42 +20,53 @@ 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. Uses gem paths or the RAILS_PATH environment variable.' + path = ENV['RAILS_PATH'] + unless defined?(Bundler) || (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 + else + 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}") + 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 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 MIT-LICENSE lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{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_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("#{gem_path('activerecord')}/#{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("#{gem_path('activeresource')}/#{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("#{gem_path('activesupport')}/#{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 lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| + rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") + end + } + end plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } -- cgit v1.2.3 From 331327d3919a633679dd3f434d13173fa8df010f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 30 Mar 2010 01:33:51 +0200 Subject: Just inspect load paths to generate the documentation. --- railties/lib/rails/tasks/documentation.rake | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'railties/lib/rails/tasks/documentation.rake') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index ff66b71dad..eadf7afc52 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,11 +1,6 @@ namespace :doc do def gem_path(gem_name) - if defined? Bundler - @specs ||= Bundler.load.specs - @specs.find{|s| s.name == gem_name}.full_gem_path - else - "#{ENV['RAILS_PATH']}/#{gem_name}" - end + File.dirname($LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first) end desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" -- cgit v1.2.3 From bc298152f8cc507549a9df9363e8da1900578932 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Tue, 30 Mar 2010 14:31:16 +1300 Subject: Fix syntax error and avoid the use of unless/else. --- railties/lib/rails/tasks/documentation.rake | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'railties/lib/rails/tasks/documentation.rake') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index eadf7afc52..1b44f9a46c 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -17,14 +17,7 @@ namespace :doc do desc 'Generate documentation for the Rails framework. Uses gem paths or the RAILS_PATH environment variable.' path = ENV['RAILS_PATH'] - unless defined?(Bundler) || (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 - else + if defined?(Bundler) || (path && File.directory?(path)) desc 'Generate documentation for the Rails framework.' Rake::RDocTask.new("rails") { |rdoc| rdoc.rdoc_dir = 'doc/api' @@ -61,6 +54,14 @@ namespace :doc do rdoc.rdoc_files.include("#{gem_path('railties')}/#{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 + end end plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } -- cgit v1.2.3 From f9e84a9e5ad35f8159a2edaffc8edb2535fbac40 Mon Sep 17 00:00:00 2001 From: postmodern Date: Mon, 29 Mar 2010 23:42:52 -0700 Subject: Changed gem_path to yield the path found in $LOAD_PATH to a block. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * This allows gems not found in $LOAD_PATH to be safely ignored by the rails documentation task. Signed-off-by: José Valim --- railties/lib/rails/tasks/documentation.rake | 48 ++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'railties/lib/rails/tasks/documentation.rake') 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 -- cgit v1.2.3 From ebcc4c5e746edcebdb58b27d3d54a51e685dd43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 30 Mar 2010 10:00:46 +0200 Subject: Remove if/else branch when generating the documentation since we are simply inspecting the load path. --- railties/lib/rails/tasks/documentation.rake | 89 ++++++++++++----------------- 1 file changed, 37 insertions(+), 52 deletions(-) (limited to 'railties/lib/rails/tasks/documentation.rake') 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) } -- cgit v1.2.3 From ce3864aa36e1afa1492bc2fd37fa96948f745861 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 30 Mar 2010 01:55:06 -0700 Subject: periods are not metacharacters within character classes --- railties/lib/rails/tasks/documentation.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails/tasks/documentation.rake') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index f73e333e83..957c375f6a 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,6 +1,6 @@ namespace :doc do def gem_path(gem_name) - path = $LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first + path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first yield File.dirname(path) if path end -- cgit v1.2.3