2006-02-26 23:38:39 -05:00
|
|
|
namespace :doc do
|
2010-03-10 12:44:27 -05:00
|
|
|
def gem_path(gem_name)
|
|
|
|
@specs ||= Bundler.load.specs
|
|
|
|
@specs.find{|s| s.name == gem_name}.full_gem_path
|
|
|
|
end
|
|
|
|
|
2008-08-29 23:36:16 -04:00
|
|
|
desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
|
2006-02-26 23:38:39 -05:00
|
|
|
Rake::RDocTask.new("app") { |rdoc|
|
|
|
|
rdoc.rdoc_dir = 'doc/app'
|
2007-09-22 14:33:39 -04:00
|
|
|
rdoc.template = ENV['template'] if ENV['template']
|
2008-08-29 23:36:16 -04:00
|
|
|
rdoc.title = ENV['title'] || "Rails Application Documentation"
|
2006-02-26 23:38:39 -05:00
|
|
|
rdoc.options << '--line-numbers' << '--inline-source'
|
2007-09-22 13:55:57 -04:00
|
|
|
rdoc.options << '--charset' << 'utf-8'
|
2006-02-26 23:38:39 -05:00
|
|
|
rdoc.rdoc_files.include('doc/README_FOR_APP')
|
|
|
|
rdoc.rdoc_files.include('app/**/*.rb')
|
2006-05-28 19:05:08 -04:00
|
|
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
2006-02-26 23:38:39 -05:00
|
|
|
}
|
2005-09-03 11:13:06 -04:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
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')
|
2010-01-24 03:59:36 -05:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
%w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|
|
|
|
|
rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}")
|
|
|
|
end
|
2010-01-24 03:59:36 -05:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
%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
|
2010-01-24 03:59:36 -05:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
%w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file|
|
|
|
|
rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}")
|
|
|
|
end
|
2010-01-24 03:59:36 -05:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
%w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
|
|
|
|
rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}")
|
|
|
|
end
|
2010-01-24 03:59:36 -05:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
%w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
|
|
|
|
rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}")
|
|
|
|
end
|
2010-03-07 15:39:53 -05:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
%w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
|
|
|
|
rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}")
|
|
|
|
end
|
2010-03-11 16:23:58 -05:00
|
|
|
|
2010-03-10 12:44:27 -05:00
|
|
|
%w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
|
|
|
|
rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}")
|
|
|
|
end
|
|
|
|
}
|
2005-10-29 11:52:07 -04:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }
|
2005-10-29 11:52:07 -04:00
|
|
|
|
2007-06-23 13:35:42 -04:00
|
|
|
desc "Generate documentation for all installed plugins"
|
2006-02-26 23:38:39 -05:00
|
|
|
task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" }
|
2005-10-29 11:52:07 -04:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
desc "Remove plugin documentation"
|
2010-03-20 13:34:21 -04:00
|
|
|
task :clobber_plugins do
|
2006-02-26 23:38:39 -05:00
|
|
|
rm_rf 'doc/plugins' rescue nil
|
2005-10-29 11:52:07 -04:00
|
|
|
end
|
|
|
|
|
2008-10-21 13:33:40 -04:00
|
|
|
desc "Generate Rails guides"
|
|
|
|
task :guides do
|
2010-03-20 13:34:21 -04:00
|
|
|
# FIXME: Reaching outside lib directory is a bad idea
|
|
|
|
require File.expand_path('../../../../guides/rails_guides', __FILE__)
|
2010-01-16 13:18:24 -05:00
|
|
|
RailsGuides::Generator.new(Rails.root.join("doc/guides")).generate
|
2008-10-21 13:33:40 -04:00
|
|
|
end
|
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
namespace :plugins do
|
|
|
|
# Define doc tasks for each plugin
|
|
|
|
plugins.each do |plugin|
|
2008-10-05 17:16:26 -04:00
|
|
|
desc "Generate documentation for the #{plugin} plugin"
|
2006-02-26 23:38:39 -05:00
|
|
|
task(plugin => :environment) do
|
|
|
|
plugin_base = "vendor/plugins/#{plugin}"
|
|
|
|
options = []
|
|
|
|
files = Rake::FileList.new
|
|
|
|
options << "-o doc/plugins/#{plugin}"
|
|
|
|
options << "--title '#{plugin.titlecase} Plugin Documentation'"
|
|
|
|
options << '--line-numbers' << '--inline-source'
|
2008-08-06 21:00:18 -04:00
|
|
|
options << '--charset' << 'utf-8'
|
2006-02-26 23:38:39 -05:00
|
|
|
options << '-T html'
|
|
|
|
|
|
|
|
files.include("#{plugin_base}/lib/**/*.rb")
|
2007-12-17 13:54:55 -05:00
|
|
|
if File.exist?("#{plugin_base}/README")
|
2010-03-20 13:34:21 -04:00
|
|
|
files.include("#{plugin_base}/README")
|
2006-02-26 23:38:39 -05:00
|
|
|
options << "--main '#{plugin_base}/README'"
|
|
|
|
end
|
2007-12-17 13:54:55 -05:00
|
|
|
files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG")
|
2005-10-29 11:52:07 -04:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
options << files.to_s
|
2005-10-29 11:52:07 -04:00
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
sh %(rdoc #{options * ' '})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2007-09-22 13:55:57 -04:00
|
|
|
end
|