Kelly sikkema 172068

Documentation in Rails with sdoc

Jan 23, 2018 by ohiodn8




In Gemfile =>

gem 'sdoc'

Then run (via cmd) =>

sdoc -o doc/rails_app

Just that is fine, and you can check your generated documentation file at /doc/rails_app/index.html, but we want our documentation to look a bit organized (and without the test folder).

Use the task generator to create a new namespace:

rails g task rdoc

Open /lib/tasks/rdoc.rake. In there, you'll find => 

namespace :rdoc do

end

Replace that with the code below:

require 'sdoc'
require 'rdoc/task'

RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.generator = 'sdoc'
rdoc.template = 'rails'
rdoc.rdoc_files.include('Gemfile', 'README.md', 'app/', 'db/', 'lib/')
end

You can run (in cmd) rails rdoc, and open doc/rdoc/index.html in your browser . . . to update the documentation, run rails rerdoc


Sdoc Documentation Page

Image by =>

unsplash-lo Kelly Sikkema



About ohiodn8

Ruby on Rails developer, AWS Engineer, anything fun, music, a little bit of mobile game. . .

Comments