Pages

Sponsorship

40% off your First Order with GoDaddy.com!

Jan 16, 2010

Rails: How to use a custom RDoc template from a rake task


I just need to do that, use a custom rdoc template to generate a documentation for a Rails project.

My main concern, regarding the different solutions I found on the web, was I didn’t want to have a template in the ruby installation directory but one that resides in a subdirectory of my rails application.

In fact it’s not a problem … when you find the good command. Here’s my rake task to generate the documentation (I put the Jamis Buck customized template in RAILS_ROOT/doc/rdoc_template/jamis.rb)

namespace :doc do
desc "Generate documentation for the application"
Rake::RDocTask.new("app_jamis") { |rdoc|
rdoc.rdoc_dir = 'doc/app_jamis'
rdoc.title = "My Website Documentation"
rdoc.template = "doc/rdoc_template/jamis.rb"
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('doc/README_FOR_APP')
rdoc.rdoc_files.include('app/**/*.rb')
rdoc.rdoc_files.include('lib/**/*.rb')
}
end
view raw jamis.rb hosted with ❤ by GitHub

The important part is :
rdoc.template = "doc/rdoc_template/jamis.rb"

I tried to use the—template= and -T options in rdoc.options but it didn’t work… then I found that the RDocTask appends its template variable to the options passed to RDoc bypassing mine.

No comments:

Post a Comment