take / autodoc

Generate documentation from your rack application & request-spec.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autodoc

Generate documentation from your rack application & request-spec.

Installation

gem "autodoc", group: :test

Usage

Run rspec with AUTODOC=1 to generate documents for your request-specs tagged with :autodoc.
example: doc/recipes.md, doc/toc.md

# shell-command
AUTODOC=1 rspec

Example for any Rack application with rack-test

# spec/requests/entries_spec.rb
describe "Entries" do
  include Rack::Test::Methods

  let(:app) do
    MyRackApplication
  end

  describe "GET /entries", autodoc: true do
    get "/entries"
    last_response.status.should == 200
  end
end

Example for Rails application with rspec-rails

# spec/requests/recipes_spec.rb
describe "Recipes" do
  describe "POST /recipes", autodoc: true do
    it "creates a new recipe" do
      post "/recipes", name: "alice", type: 1
      response.status.should == 201
    end
  end
end

Configuration

You can configure Autodoc.configuration to change its behavior:

  • path - [String] location to put files (default: ./doc)
  • suppressed_request_header - [Strings] filtered request header keys
  • suppressed_response_header - [Strings] filtered response header keys
  • template - [String] ERB template for each document (default: document.md.erb)
  • toc_template - [String] ERB template for ToC (default: toc.md.erb)
  • toc - [Boolean] whether to generate toc.md (default: false)
# example
Autodoc.configuration.path = "doc/api"
Autodoc.configuration.toc = true

About

Generate documentation from your rack application & request-spec.

License:MIT License


Languages

Language:Ruby 95.8%Language:JavaScript 2.3%Language:CSS 1.9%