digitalbazaar/bedrock-docs

Name: bedrock-docs

Owner: Digital Bazaar, Inc.

Description: Bedrock documentation

Created: 2015-01-13 23:46:41.0

Updated: 2016-01-26 05:45:17.0

Pushed: 2018-01-13 05:47:17.0

Homepage: null

Size: 93

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

bedrock-docs

A bedrock module that adds custom documentation and REST API documentation support to a site. Documentation is hosted at /docs. API documentation can be generated with RAML and raml2html by using the documentation API to annotate REST endpoints.

Requirements
Quick Examples
install bedrock-docs
s
brDocs = require('bedrock-docs');

ock.events.on('bedrock-express.configure.routes', addRoutes);

tion addRoutes(app) {
p.get('/my/resource', function(req, res, next) {
// ...
;
Docs.annotate.get('/my/resource', {
displayName: 'My Resource',
description: 'Get My Resource.',
responses: {
  200: {
    'application/ld+json': {
      'example': 'examples/my-resource.jsonld'
    }
  }
}
;

Configuration

For documentation on configuration, see config.js.

API
getRaml(method, path, indent, callback(err, ramlSnippet))

Retrieve a RAML annotation for a particular method and path. The indentation level must be provided. Use '{' and '}' for path variables (“/my/{id}“). The result RAML string can be injected into a master RAML file.

loadFile(section, paths, vars, callback)

Loads a documentation file from disk, making the appropriate template replacements.

document(method, path, doc)

Documents a particular method and path of the system. Prefix path variables with ':' (“/my/:id”). The doc object is in RAML format.

annotate.METHOD(path, docs)

Aliases for document(METHOD, path, doc) for get, post, put, patch, and delete.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.