Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Automatically generate API documentation from RSpec
JavaScript Ruby Shell
branch: new_dsl

This branch is even with zipmark:new_dsl

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
features
gemfiles
lib
script
spec
templates/rspec_api_documentation
.gitignore
.rspec
.travis.yml
Gemfile
Gemfile.lock
LICENSE.md
README.md
Rakefile
dsl2.rb
rspec_api_documentation.gemspec

README.md

Travis status Gemnasium status

RSpec API Doc Generator

Generate pretty API docs for your Rails APIs.

Changes

Please see the wiki for latest changes.

Installation

Add rspec_api_documentation to your Gemfile

gem 'rspec_api_documentation'

Bundle it!

$> bundle install

See the wiki for additional setup. Setting up RSpec API Documentation

Sample App

See the example folder for a sample Rails app that has been documented.

Configuration options

  • app - Set the application that Rack::Test uses, defaults to Rails.application
  • docs_dir - Output folder
  • format - Output format
  • template_path - Location of templates
  • filter - Filter by example document type
  • exclusion_filter - Filter by example document type
  • url_prefix - Add before all links on the index page, useful if docs are located in public/docs
  • keep_source_order - By default examples and resources are ordered by description. Set to true keep the source order.

Example Configuration

spec/spec_helper.rb

RspecApiDocumentation.configure do |config|
  config.docs_dir = Rails.root.join("app", "views", "pages")

  config.define_group :public do |config|
    config.docs_dir = Rails.root.join("public", "docs")
    config.url_prefix = "docs/"
  end
end

Usage

resource "Account" do
  get "/accounts" do
    example "Get a list of all accounts" do
      do_request
      status.should be_ok
    end
  end

  get "/accounts/:id" do
    parameter :id, "Account ID"

    let(:account) { Factory(:account) }
    let(:id) { account.id }

    example "Get an account", :document => :public do
      do_request
      status.should be_ok
    end
  end
end
Something went wrong with that request. Please try again.