aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2013-03-29 23:40:48 +0100
committerXavier Noria <fxn@hashref.com>2013-03-30 00:10:52 +0100
commit84c0ac3b56e1e3d8dd6401e5cf49a4019acc1b32 (patch)
treeebd993854fdf71c1ac339a2071bd87029e56b487 /railties/lib/rails
parent323553703072b31a0c0139dc5fc4207279093cd5 (diff)
downloadrails-84c0ac3b56e1e3d8dd6401e5cf49a4019acc1b32.tar.gz
rails-84c0ac3b56e1e3d8dd6401e5cf49a4019acc1b32.tar.bz2
rails-84c0ac3b56e1e3d8dd6401e5cf49a4019acc1b32.zip
unifies API generation
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/api/task.rb39
-rw-r--r--railties/lib/rails/tasks/documentation.rake48
2 files changed, 34 insertions, 53 deletions
diff --git a/railties/lib/rails/api/task.rb b/railties/lib/rails/api/task.rb
index f5aa56806b..ed0e38eca3 100644
--- a/railties/lib/rails/api/task.rb
+++ b/railties/lib/rails/api/task.rb
@@ -71,7 +71,6 @@ module Rails
options << '-e' << 'UTF-8'
options << '-f' << 'sdoc'
options << '-T' << 'rails'
- options << '-g' # link to GitHub, SDoc flag
configure_rdoc_files
@@ -101,21 +100,47 @@ module Rails
end
end
+ def setup_horo_variables
+ ENV['HORO_PROJECT_NAME'] = 'Ruby on Rails'
+ ENV['HORO_PROJECT_VERSION'] = rails_version
+ end
+
def api_main
- 'railties/RDOC_MAIN.rdoc'
+ component_root_dir('railties') + '/RDOC_MAIN.rdoc'
end
+ end
- def api_dir
- 'doc/rdoc'
+ class RepoTask < Task
+ def initialize(name)
+ super
+
+ options << '-g' # link to GitHub, SDoc flag
end
def component_root_dir(component)
component
end
- def setup_horo_variables
- ENV['HORO_PROJECT_NAME'] = 'Ruby on Rails'
- ENV['HORO_PROJECT_VERSION'] = "master@#{`git rev-parse HEAD`[0, 7]}"
+ def api_dir
+ 'doc/rdoc'
+ end
+
+ def rails_version
+ "master@#{`git rev-parse HEAD`[0, 7]}"
+ end
+ end
+
+ class AppTask < Task
+ def component_root_dir(gem_name)
+ $:.grep(%r{#{gem_name}[\w.-]*/lib\z}).first[0..-5]
+ end
+
+ def api_dir
+ 'doc/api'
+ end
+
+ def rails_version
+ Rails::VERSION::STRING
end
end
end
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake
index 0057b0f887..1c3426028d 100644
--- a/railties/lib/rails/tasks/documentation.rake
+++ b/railties/lib/rails/tasks/documentation.rake
@@ -1,4 +1,5 @@
require 'rdoc/task'
+require 'rails/api/task'
# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
class RDocTaskWithoutDescriptions < RDoc::Task
@@ -52,52 +53,7 @@ namespace :doc do
Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")"
# desc 'Generate documentation for the Rails framework.'
- RDocTaskWithoutDescriptions.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'
-
- gem_path('rails') do |rails|
- rdoc.options << '-m' << "#{rails}/README.rdoc"
- end
-
- gem_path('actionmailer') do |actionmailer|
- %w(README.rdoc CHANGELOG.md 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.rdoc CHANGELOG.md 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.rdoc CHANGELOG.md MIT-LICENSE lib/active_model/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{activemodel}/#{file}")
- end
- end
-
- gem_path('activerecord') do |activerecord|
- %w(README.rdoc CHANGELOG.md lib/active_record/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{activerecord}/#{file}")
- end
- end
-
- gem_path('activesupport') do |activesupport|
- %w(README.rdoc CHANGELOG.md lib/active_support/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{activesupport}/#{file}")
- end
- end
-
- gem_path('railties') do |railties|
- %w(README.rdoc CHANGELOG.md lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
- rdoc.rdoc_files.include("#{railties}/#{file}")
- end
- end
- }
+ Rails::API::AppTask.new('rails')
# desc "Generate Rails Guides"
task :guides do