Git Product home page Git Product logo

double_doc's Introduction

DoubleDoc 2.0

Build Status

Write documentation with your code, to keep them in sync, ideal for public API docs.

This document was generated using DoubleDoc from doc/readme.md, and the source of this project is a great source for how to use DoubleDoc.

Documentation Format

Write documentation in markdown right in source code files by double commenting it:

class User < ActiveRecord::Base
  ## ```js
  ## {
  ##   "id":   1,
  ##   "name": "Mick Staugaard"
  ## }
  ## ```
  def as_json
    # this comment will not be included in the documentation
    # as it only has a single # character
    super(only: [:id, :name])
  end
end

class UsersController < ApplicationController
  ## ### Getting a User
  ## `GET /users/{id}.json`
  ##
  ## #### Format
  ## @import app/models/user.rb
  def show
    render json: User.find(params[:id])
  end
end

Then write a markdown document about User API:

## Users
Access users by using our REST API, blah blah blah...

@import app/controllers/users_controller.rb

And DoubleDoc will generate this markdown document:

## Users
Access users in by using our REST API, blah blah blah...

### Getting a User
`GET /users/{id}.json`

#### Format
```js
{
  "id":   1,
  "name": "Mick Staugaard"
}
```

Rake Task

Generate documentation by telling DoubleDoc what the input files are, and where the output should go. In the example, double_doc is picked to avoid conflicts with the doc rake task in rails.

require 'double_doc'

DoubleDoc::Task.new(
  :double_doc,
  sources:          'doc/source/*.md',
  md_destination:   'doc/generated',
  html_destination: 'site'
)

The available options are:

name Description
sources Required. Documentation source directory (string or array of strings).
md_destination Required. Directory where the generated markdown files should go.
html_destination Where a pretty HTML version of the documentation should go.
html_template Custom ERB template for HTML rendering, see default template for inspiration (templates/default.html.erb).
html_renderer Custom html rendered, defaults to DoubleDoc::HtmlRenderer.
html_css Custom CSS document path.
title Title for generated HTML, defaults to "Documentation".
To generate a README.md for github, write documentation in doc/README.md and put this in the Rakefile:
require 'double_doc'

DoubleDoc::Task.new(:double_doc, sources: 'doc/README.md', md_destination: '.')

Then run rake double_doc, which will generate a readme.md in the root of the project.

If a gh-pages branch exists, run rake doc:publish to generate html documentation and push it to your github pages.

Notes

  • Tested on ruby 2.0+
  • Does not work on jruby because of its dependency on redcarpet.

TODO

  • Support for directory structures
  • Documentation for the Guard
  • Add support for extracting documentation from JavaScript files

License

The MIT License

Copyright © 2012 Mick Staugaard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

double_doc's People

Contributors

dylan-zendesk avatar grosser avatar mwerner avatar pelletier avatar pschambacher avatar sandlerr avatar staugaard avatar steved avatar xjlu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.