2013-03-29 16:16:12 -04:00
|
|
|
require 'rdoc/task'
|
|
|
|
|
|
|
|
module Rails
|
|
|
|
module API
|
|
|
|
class Task < RDoc::Task
|
|
|
|
RDOC_FILES = {
|
|
|
|
'activesupport' => {
|
|
|
|
:include => %w(
|
|
|
|
README.rdoc
|
|
|
|
lib/active_support/**/*.rb
|
|
|
|
),
|
|
|
|
:exclude => 'lib/active_support/vendor/*'
|
|
|
|
},
|
|
|
|
|
|
|
|
'activerecord' => {
|
|
|
|
:include => %w(
|
|
|
|
README.rdoc
|
|
|
|
lib/active_record/**/*.rb
|
2013-09-09 11:04:04 -04:00
|
|
|
)
|
2013-03-29 16:16:12 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
'activemodel' => {
|
|
|
|
:include => %w(
|
|
|
|
README.rdoc
|
|
|
|
lib/active_model/**/*.rb
|
|
|
|
)
|
|
|
|
},
|
|
|
|
|
|
|
|
'actionpack' => {
|
|
|
|
:include => %w(
|
|
|
|
README.rdoc
|
|
|
|
lib/abstract_controller/**/*.rb
|
|
|
|
lib/action_controller/**/*.rb
|
|
|
|
lib/action_dispatch/**/*.rb
|
2013-09-09 11:04:04 -04:00
|
|
|
)
|
2013-03-29 16:16:12 -04:00
|
|
|
},
|
|
|
|
|
2013-07-14 03:43:01 -04:00
|
|
|
'actionview' => {
|
|
|
|
:include => %w(
|
|
|
|
README.rdoc
|
|
|
|
lib/action_view/**/*.rb
|
2013-09-09 11:04:04 -04:00
|
|
|
),
|
|
|
|
:exclude => 'lib/action_view/vendor/*'
|
2013-07-14 03:43:01 -04:00
|
|
|
},
|
|
|
|
|
2013-03-29 16:16:12 -04:00
|
|
|
'actionmailer' => {
|
|
|
|
:include => %w(
|
|
|
|
README.rdoc
|
|
|
|
lib/action_mailer/**/*.rb
|
2013-09-09 11:04:04 -04:00
|
|
|
)
|
2013-03-29 16:16:12 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
'railties' => {
|
|
|
|
:include => %w(
|
|
|
|
README.rdoc
|
|
|
|
lib/**/*.rb
|
2013-04-04 18:28:44 -04:00
|
|
|
),
|
|
|
|
:exclude => 'lib/rails/generators/rails/**/templates/**/*.rb'
|
2013-03-29 16:16:12 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def initialize(name)
|
|
|
|
super
|
|
|
|
|
2013-03-30 06:27:53 -04:00
|
|
|
# Every time rake runs this task is instantiated as all the rest.
|
|
|
|
# Be lazy computing stuff to have as light impact as possible to
|
|
|
|
# the rest of tasks.
|
2013-03-29 16:16:12 -04:00
|
|
|
before_running_rdoc do
|
2013-03-30 06:22:40 -04:00
|
|
|
load_and_configure_sdoc
|
2013-03-30 06:27:53 -04:00
|
|
|
configure_rdoc_files
|
2013-03-29 16:16:12 -04:00
|
|
|
setup_horo_variables
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Hack, ignore the desc calls performed by the original initializer.
|
|
|
|
def desc(description)
|
|
|
|
# no-op
|
|
|
|
end
|
|
|
|
|
2013-03-30 06:22:40 -04:00
|
|
|
def load_and_configure_sdoc
|
|
|
|
require 'sdoc'
|
2013-03-30 06:27:53 -04:00
|
|
|
|
|
|
|
self.title = 'Ruby on Rails API'
|
|
|
|
self.rdoc_dir = api_dir
|
|
|
|
|
|
|
|
options << '-m' << api_main
|
|
|
|
options << '-e' << 'UTF-8'
|
|
|
|
|
2013-03-30 06:22:40 -04:00
|
|
|
options << '-f' << 'sdoc'
|
|
|
|
options << '-T' << 'rails'
|
|
|
|
rescue LoadError
|
|
|
|
$stderr.puts %(Unable to load SDoc, please add\n\n gem 'sdoc', require: false\n\nto the Gemfile.)
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2013-03-29 16:16:12 -04:00
|
|
|
def configure_rdoc_files
|
|
|
|
rdoc_files.include(api_main)
|
|
|
|
|
|
|
|
RDOC_FILES.each do |component, cfg|
|
|
|
|
cdr = component_root_dir(component)
|
|
|
|
|
|
|
|
Array(cfg[:include]).each do |pattern|
|
|
|
|
rdoc_files.include("#{cdr}/#{pattern}")
|
|
|
|
end
|
|
|
|
|
|
|
|
Array(cfg[:exclude]).each do |pattern|
|
|
|
|
rdoc_files.exclude("#{cdr}/#{pattern}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-29 18:40:48 -04:00
|
|
|
def setup_horo_variables
|
|
|
|
ENV['HORO_PROJECT_NAME'] = 'Ruby on Rails'
|
|
|
|
ENV['HORO_PROJECT_VERSION'] = rails_version
|
|
|
|
end
|
|
|
|
|
2013-03-29 16:16:12 -04:00
|
|
|
def api_main
|
2013-03-29 18:40:48 -04:00
|
|
|
component_root_dir('railties') + '/RDOC_MAIN.rdoc'
|
2013-03-29 16:16:12 -04:00
|
|
|
end
|
2013-03-29 18:40:48 -04:00
|
|
|
end
|
2013-03-29 16:16:12 -04:00
|
|
|
|
2013-03-29 18:40:48 -04:00
|
|
|
class RepoTask < Task
|
2013-03-30 06:22:40 -04:00
|
|
|
def load_and_configure_sdoc
|
2013-03-29 18:40:48 -04:00
|
|
|
super
|
|
|
|
options << '-g' # link to GitHub, SDoc flag
|
2013-03-29 16:16:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def component_root_dir(component)
|
|
|
|
component
|
|
|
|
end
|
|
|
|
|
2013-03-29 18:40:48 -04:00
|
|
|
def api_dir
|
|
|
|
'doc/rdoc'
|
|
|
|
end
|
2013-07-06 16:40:02 -04:00
|
|
|
end
|
2013-03-29 18:40:48 -04:00
|
|
|
|
2013-07-06 16:40:02 -04:00
|
|
|
class EdgeTask < RepoTask
|
2013-03-29 18:40:48 -04:00
|
|
|
def rails_version
|
|
|
|
"master@#{`git rev-parse HEAD`[0, 7]}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-06 16:40:02 -04:00
|
|
|
class StableTask < RepoTask
|
|
|
|
def rails_version
|
|
|
|
File.read('RAILS_VERSION').strip
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-29 18:40:48 -04:00
|
|
|
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
|
2013-03-29 16:16:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|