2012-02-27 08:09:58 -05:00
require 'rdoc/task'
2010-04-26 03:36:13 -04:00
2010-06-09 17:14:47 -04:00
# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
2011-05-24 14:39:49 -04:00
class RDocTaskWithoutDescriptions < RDoc :: Task
2012-05-31 06:18:56 -04:00
include :: Rake :: DSL
2011-08-08 12:47:24 -04:00
2010-06-09 17:14:47 -04:00
def define
task rdoc_task_name
2010-08-14 01:13:00 -04:00
2010-06-09 17:14:47 -04:00
task rerdoc_task_name = > [ clobber_task_name , rdoc_task_name ]
2010-08-14 01:13:00 -04:00
2010-06-09 17:14:47 -04:00
task clobber_task_name do
rm_r rdoc_dir rescue nil
end
2010-08-14 01:13:00 -04:00
2010-06-09 17:14:47 -04:00
task :clobber = > [ clobber_task_name ]
2010-08-14 01:13:00 -04:00
2010-06-09 17:14:47 -04:00
directory @rdoc_dir
task rdoc_task_name = > [ rdoc_target ]
file rdoc_target = > @rdoc_files + [ Rake . application . rakefile ] do
rm_r @rdoc_dir rescue nil
@before_running_rdoc . call if @before_running_rdoc
args = option_list + @rdoc_files
if @external
argstring = args . join ( ' ' )
sh %{ ruby -Ivendor vendor/rd #{ argstring } }
else
require 'rdoc/rdoc'
RDoc :: RDoc . new . document ( args )
end
end
self
end
end
2006-02-26 23:38:39 -05:00
namespace :doc do
2010-03-10 12:44:27 -05:00
def gem_path ( gem_name )
2010-03-30 04:55:06 -04:00
path = $LOAD_PATH . grep ( / #{ gem_name } [ \ w.-]* \/ lib$ / ) . first
2010-03-30 04:00:46 -04:00
yield File . dirname ( path ) if path
2010-03-10 12:44:27 -05:00
end
2010-06-09 17:14:47 -04:00
RDocTaskWithoutDescriptions . new ( " app " ) { | rdoc |
2006-02-26 23:38:39 -05:00
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 "
2011-07-21 16:49:36 -04:00
rdoc . options << '--line-numbers'
2007-09-22 13:55:57 -04:00
rdoc . options << '--charset' << 'utf-8'
2013-01-07 18:16:19 -05:00
rdoc . rdoc_files . include ( 'README.rdoc' )
2006-02-26 23:38:39 -05:00
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
}
2012-01-02 15:49:18 -05:00
Rake :: Task [ 'doc:app' ] . comment = " Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE= \" Custom Title \" ) "
2005-09-03 11:13:06 -04:00
2010-06-09 17:14:47 -04:00
# desc 'Generate documentation for the Rails framework.'
RDocTaskWithoutDescriptions . new ( " rails " ) { | rdoc |
2010-03-30 04:00:46 -04:00
rdoc . rdoc_dir = 'doc/api'
rdoc . template = " #{ ENV [ 'template' ] } .rb " if ENV [ 'template' ]
rdoc . title = " Rails Framework Documentation "
2011-07-21 16:49:36 -04:00
rdoc . options << '--line-numbers'
2013-01-07 18:16:19 -05:00
gem_path ( 'rails' ) do | rails |
rdoc . options << '-m' << " #{ rails } /README.rdoc "
end
2010-01-24 03:59:36 -05:00
2010-03-30 04:00:46 -04:00
gem_path ( 'actionmailer' ) do | actionmailer |
2011-11-08 02:26:51 -05:00
%w( README.rdoc CHANGELOG.md MIT-LICENSE lib/action_mailer/base.rb ) . each do | file |
2010-03-30 04:00:46 -04:00
rdoc . rdoc_files . include ( " #{ actionmailer } / #{ file } " )
2010-03-29 19:25:52 -04:00
end
2010-03-30 04:00:46 -04:00
end
2010-01-24 03:59:36 -05:00
2010-03-30 04:00:46 -04:00
gem_path ( 'actionpack' ) do | actionpack |
2011-11-08 02:26:51 -05:00
%w( README.rdoc CHANGELOG.md MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb ) . each do | file |
2010-03-30 04:00:46 -04:00
rdoc . rdoc_files . include ( " #{ actionpack } / #{ file } " )
2010-03-29 19:25:52 -04:00
end
2010-03-30 04:00:46 -04:00
end
2010-01-24 03:59:36 -05:00
2010-03-30 04:00:46 -04:00
gem_path ( 'activemodel' ) do | activemodel |
2011-11-08 02:26:51 -05:00
%w( README.rdoc CHANGELOG.md MIT-LICENSE lib/active_model/**/*.rb ) . each do | file |
2010-03-30 04:00:46 -04:00
rdoc . rdoc_files . include ( " #{ activemodel } / #{ file } " )
2010-03-29 19:25:52 -04:00
end
2010-03-30 04:00:46 -04:00
end
2010-01-24 03:59:36 -05:00
2010-03-30 04:00:46 -04:00
gem_path ( 'activerecord' ) do | activerecord |
2011-11-08 02:26:51 -05:00
%w( README.rdoc CHANGELOG.md lib/active_record/**/*.rb ) . each do | file |
2010-03-30 04:00:46 -04:00
rdoc . rdoc_files . include ( " #{ activerecord } / #{ file } " )
2010-03-29 19:25:52 -04:00
end
2010-03-30 04:00:46 -04:00
end
2010-03-07 15:39:53 -05:00
2010-03-30 04:00:46 -04:00
gem_path ( 'activesupport' ) do | activesupport |
2011-11-08 23:29:17 -05:00
%w( README.rdoc CHANGELOG.md lib/active_support/**/*.rb ) . each do | file |
2010-03-30 04:00:46 -04:00
rdoc . rdoc_files . include ( " #{ activesupport } / #{ file } " )
2010-03-29 19:25:52 -04:00
end
2010-03-30 04:00:46 -04:00
end
2010-03-29 19:25:52 -04:00
2010-03-30 04:00:46 -04:00
gem_path ( 'railties' ) do | railties |
2011-11-08 23:29:17 -05:00
%w( README.rdoc CHANGELOG.md lib/{*.rb,commands/*.rb,generators/*.rb} ) . each do | file |
2010-03-30 04:00:46 -04:00
rdoc . rdoc_files . include ( " #{ railties } / #{ file } " )
2010-03-29 21:31:16 -04:00
end
end
2010-03-30 04:00:46 -04:00
}
2005-10-29 11:52:07 -04:00
2010-06-09 17:14:47 -04:00
# desc "Generate Rails Guides"
2008-10-21 13:33:40 -04:00
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
2007-09-22 13:55:57 -04:00
end