Search code examples
ruby-on-railsrdoc

How make contents of README_FOR_APP appear in doc/app/index.html


I'd like the contents of doc/README_FOR_APP appear in doc/app/index.html, when I do rake doc:app.

Currently, the content is:

This is the API documentation for Rails Application Documentation.

To see README_FOR_APP, I have to click on README_FOR_APP in the pages list on the left.

I've looked at How to Rename or Move Rails's README_FOR_APP but the OP asserts that he's already seeing the behaviour I want.

I'm using rails 3.1.3.


Solution

  • Firstly, create a new rake file (e.g lib/tasks/documentation.rake) in your project. Then redefine the rake task:

    Rake::Task["doc:app"].clear
    Rake::Task["doc/app"].clear
    Rake::Task["doc/app/index.html"].clear
    
    namespace :doc do
        Rake::RDocTask.new('app') do |rdoc|
            rdoc.rdoc_dir = 'doc/app'
            rdoc.title    = 'YOUR_TITLE'
            rdoc.main     = 'doc/README_FOR_APP' # define README_FOR_APP as index
    
            rdoc.options << '--charset' << 'utf-8'
    
            rdoc.rdoc_files.include('app/**/*.rb')
            rdoc.rdoc_files.include('lib/**/*.rb')
            rdoc.rdoc_files.include('doc/README_FOR_APP')
    
        end
    end