Code Monkey home page Code Monkey logo

yard-restful's Introduction

Yardoc RESTful Web Service Plugin

A plugin for Yardoc that generates documentation for RESTful web services.

Previous authors: vWorkApp, rknLA, lsegal, spape, DerNalia

Main features

Plugin provides custom tags to describe resources (controllers) and resulting objects (models).

If you use an object name in description of resource parameters, it will be linked to the object description.

Install

Bundler will reduce your headaches:

gem 'yard-restful' # in your gemfile

You may need to include the following dependencies as well:

gem 'redcarpet'
gem 'yard'

It also requires the Jeweler gem if you plan to use the rake build tasks.

You'll probably want to add these to your .gitignore as well

.yardoc
public/api

So you'll have to re-genenarte your API on every machine. This should encourage more up to dateness

Execution

It is recommended that you use a .yardopts file

--title "My API Documentation"
--plugin restful
--readme API_README
--output-dir ./public/api
app/models/**/*.rb
app/controllers/**/*.rb

So that way, whenever you want to generate your API docs, you simply need to run only

bundle exec yardoc

Samples

Full rails 3 application with documentation

Example documentation, also with frames

Sample controller and sample model

Writing Comments

The following tags are provided:

  • @restful_api version

    Specifies the resource (controller) or object (model). This tag is compulsory, only classes and methods that include this in their comments are included in the API documentation.

  • @url url

    Specifies the URL which someone should use to access that resource.

  • @action action

    Specifies the http action (GET, POST, PUT etc.).

  • @required [type] name description

    Specifies an argument that must be passed to the service. You can specify as many of these as you need.

  • @optional [type] name description

    Specifies an optional argument that may be passed to the service. You can specify as many of these as you need.

  • @response [type] description

    Specifies type of the response. Usually just a link to an object.

  • @response_field [type] name description

    Further specifies the fields that are returned within the response.

  • @property [type] name description

    A property (attribute) of an object.

Examples

Examples should always be together in the following order: example_request, example_request_description, example_response, example_response_description (as soon as you write an example_request you need a following example_response and the other way around).

Markdown rendering for the text is activated if a tags text contains a newline (see example).

  • @example_request

    An example of the request that is send to the service.

  • @example_request_description

    The description text for the example request.

  • @example_response

    An example of the response that is returned from the service.

  • @example_response_description

    The description text for the example response.

  • @example

    Example of an object.

Ignored Documentation

This plugin only documents classes and methods with @restful_api tag. It does not support module documentation.

Development

As always, you can see what tasks are available by running:

rake -T

You can run the template locally over the included sample code by using the following rake tasks:

rake example:generate
rake example:clean

yard-restful's People

Contributors

arronmabrey avatar dwaynemac avatar kraft001 avatar maxigs avatar squeedee avatar swistaczek avatar ur5us avatar

Watchers

 avatar  avatar  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.