1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/api/task.rb
Xavier Noria cd7cc5254b Remove documentation tasks
This patch removes the tasks doc:app, doc:rails, and doc:guides.

In our experience applications do not generate APIs using doc:app.
Methods may be certainly documented for maintainers, annotated
with YARD tags, etc. but that is intended to be read with the
source code, not in a separate website. Then, teams also have
typically selected topics written down in Markdown files, or in
a GitHub wiki... that kind of thing.

If a team absolutely needs to generate application documentation
for internal purposes, they can still easily write their own task.

Regarding doc:rails and doc:guides, we live in 2015. We are used
to go to online docs all the time. If you really want access to the
API offline RubyGems generates it for every Rails component unless
you tell it not to, and you can checkout the Rails source code to
read the guides as Markdown, or download them for a Kindle reader.

All in all, maintaining this code does not seem to be worthwhile
anymore.

As a consequence of this, guides (+3 MB uncompressed) won't be
distributed with the rails gem anymore. Of course, guides and API
are going to be still part of releases, since documentation is
maintained alongside code and tests.

Also, time permitting, this will allow us to experiment with novel
ways to generate documentation in the Rails docs server, since
right now we were constrained by being able to generate them in
the user's environment.
2015-02-06 21:04:54 +01:00

156 lines
3.5 KiB
Ruby

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
)
},
'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
)
},
'actionview' => {
:include => %w(
README.rdoc
lib/action_view/**/*.rb
),
:exclude => 'lib/action_view/vendor/*'
},
'actionmailer' => {
:include => %w(
README.rdoc
lib/action_mailer/**/*.rb
)
},
'activejob' => {
:include => %w(
README.md
lib/active_job/**/*.rb
)
},
'railties' => {
:include => %w(
README.rdoc
lib/**/*.rb
),
:exclude => 'lib/rails/generators/rails/**/templates/**/*.rb'
}
}
def initialize(name)
super
# 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.
before_running_rdoc do
load_and_configure_sdoc
configure_rdoc_files
setup_horo_variables
end
end
# Hack, ignore the desc calls performed by the original initializer.
def desc(description)
# no-op
end
def load_and_configure_sdoc
require 'sdoc'
self.title = 'Ruby on Rails API'
self.rdoc_dir = api_dir
options << '-m' << api_main
options << '-e' << 'UTF-8'
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
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
def setup_horo_variables
ENV['HORO_PROJECT_NAME'] = 'Ruby on Rails'
ENV['HORO_PROJECT_VERSION'] = rails_version
end
def api_main
component_root_dir('railties') + '/RDOC_MAIN.rdoc'
end
end
class RepoTask < Task
def load_and_configure_sdoc
super
options << '-g' # link to GitHub, SDoc flag
end
def component_root_dir(component)
component
end
def api_dir
'doc/rdoc'
end
end
class EdgeTask < RepoTask
def rails_version
"master@#{`git rev-parse HEAD`[0, 7]}"
end
end
class StableTask < RepoTask
def rails_version
File.read('RAILS_VERSION').strip
end
end
end
end