creating Rdoc for a rails app
Asked Answered
P

2

8

I would like to generate a documentation to my rails (2.3.8) project. When I tried

rake doc:rails
rake doc:rerails

It creates documentation for all the classes including standard ruby classes and all the ruby files in vendor directory (plugins etc..)

How can I create rdoc documentation only for ruby classes, files in following directories

  1. app folder (all the models, controllers and views)
  2. config folder
  3. lib folder
Pharyngoscope answered 2/9, 2011 at 6:32 Comment(0)
O
12

I added this to my Rakefile;

RDoc::Task.new :rdoc do |rdoc|
  rdoc.main = "README.rdoc"

  rdoc.rdoc_files.include("README.rdoc", "doc/*.rdoc", "app/**/*.rb", "lib/*.rb", "config/**/*.rb")
  #change above to fit needs

  rdoc.title = "App Documentation"
  rdoc.options << "--all" 
end

Then run;

rake rdoc

Check out the RDoc::Task docs for more http://rdoc.rubyforge.org/RDoc/Task.html

Admittedly I am on a rails 3 app, but I think this works the same.

Overslaugh answered 28/11, 2011 at 13:50 Comment(1)
This didn't work for me (not surprising for a 7+ year-old answer!) but this other answer did.Salish
G
4

You can use rake doc:app to generate documentation for the app.

Quoting from section 2.4 of Rails guides:

The doc: namespace has the tools to generate documentation for your app, API documentation, guides. Documentation can also be stripped which is mainly useful for slimming your codebase, like if you're writing a Rails application for an embedded platform.

rake doc:app generates documentation for your application in doc/app. rake doc:guides generates Rails guides in doc/guides. rake doc:rails generates API documentation for Rails in doc/api.

Granthem answered 24/9, 2015 at 11:46 Comment(2)
When I tried this command it had no effect. The quoted section also seems to have been removed from the linked page.Salish
It looks like this answer is what works today.Salish

© 2022 - 2024 — McMap. All rights reserved.