Docster
API documentation generation on the fly for your rails app.
<img src=“https://secure.travis-ci.org/sulf/docster.png” />
Installation
You can use the latest Rails 3 gem with the latest Docster gem. Add it to your Gemfile
gem 'docster-rails', :require => 'docster'
Configure your routes to enable docster. Open your ‘config/routes.rb` file and add:
api_docs
This will add a route docs/api to your application.
Configuring Docster
Add a custom initializer such as config/initializers/docster.rb
Docster.setup do |config|
config.application_name = "My awesome app"
end
Using docster
Docster markup is added directly to your code as comments. A markup block starts with the ‘# – doc –` tag and ends with the `# – /doc –` tag.
In your controllers or routes.rb file, add an object tag to start defining api calls for this object.
Example:
# -- doc --
# @object[picture] Picture related calls
# -- /doc --
To define an api call you can add the following docster markup.
# -- doc --
# @route /albums/:album_id/pictures.json
# @method GET
# @description Listing pictures of a given album
# @params[page] (optional) Pagination
# @params[per_page] (optional) How many pictures per page
# @returns {
collection: [PICTURE_OBJECT,...],
meta: { current_page: INT, num_pages: INT }
}
# @notes When the album owner is not a pro user, this request only returns the last X pictures
# @example curl https://wwww.me-today.com/albums/1/pictures.json
# {
# pictures: [...]
# }
# -- /doc --
License
MIT License. Copyright 2012 Pingpin, Inc