UNPKG

helper-apidocs

Version:

Template helper for automatically generating API docs from code comments. Should work with any template engine.

115 lines (74 loc) 2.76 kB
# helper-apidocs [![NPM version](https://img.shields.io/npm/v/helper-apidocs.svg)](https://www.npmjs.com/package/helper-apidocs) [![Build Status](https://img.shields.io/travis/jonschlinkert/helper-apidocs.svg)](https://travis-ci.org/jonschlinkert/helper-apidocs) > Template helper for automatically generating API docs from code comments. Should work with any template engine. ## Install Install with [npm](https://www.npmjs.com/) ```sh $ npm i helper-apidocs --save ``` ## Example usage With Lo-Dash or Underscore: ```js <%= apidocs("index.js") %> ``` With Handlebars: ```handlebars {{apidocs "index.js"}} ``` With Verb (lo-dash, with special delimiters to avoid delimiter collision in markdown docs): ```js {%= apidocs('index.js') %}; ``` ## Register the helper > This should work with any engine, here are a few examples ### [template](https://github.com/jonschlinkert/template) Register the helper for use with any template engine ```js template.helper('apidocs', require('helper-apidocs')); ``` ### [assemble](https://github.com/assemble/assemble) To register the helper for use with [assemble](https://github.com/assemble/assemble)v0.6.x: ```js assemble.helper('apidocs', require('helper-apidocs')); ``` ### [verb](https://github.com/assemble/verb) Register the helper for use with [verb](https://github.com/assemble/verb): ```js var verb = require('verb'); verb.helper('apidocs', require('helper-apidocs')); verb.task('default', function() { verb.src('.verb*.md') .pipe(verb.dest('./')); }); ``` ### [handlebars](https://github.com/wycats/handlebars.js/) ```js var handlebars = require('handlebars'); handlebars.registerHelper('apidocs', require('helper-apidocs')); ``` ### [Lo-Dash](https://lodash.com/) or [underscore](https://github.com/jashkenas/underscore) ```js // as a mixin _.mixin({apidocs: apidocsHelper}); _.template('<%= _.apidocs("fixtures/*.js") %>', {}); // passed on the context _.template('<%= apidocs("fixtures/*.js") %>', {apidocs: apidocsHelper}); // as an import var settings = {imports: {apidocs: apidocsHelper}}; _.template('<%= apidocs("fixtures/*.js") %>', {}, settings); ``` ## Running tests Install dev dependencies: ```sh $ npm i -d && npm test ``` ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/helper-apidocs/issues/new). ## Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ## License Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert) Released under the MIT license. *** _This file was generated by [verb](https://github.com/verbose/verb) on December 14, 2015._