UNPKG

3.11 kBMarkdownView Raw
1# helper-apidocs [![NPM version](https://badge.fury.io/js/helper-apidocs.svg)](http://badge.fury.io/js/helper-apidocs) [![Build Status](https://travis-ci.org/.svg)](https://travis-ci.org/)
2
3> Template helper for automatically generating API docs from code comments. The sync version works with handlebars, lo-dash, or any template engine that supports helper functions. The async version is compatible with Verb, Assemble, or any application based on Template.
4
5## Install with [npm](npmjs.org)
6
7```bash
8npm i helper-apidocs --save
9```
10
11## Example usage
12
13With Lo-Dash or Underscore:
14
15```js
16<%= apidocs("index.js") %>
17```
18
19With Handlebars:
20
21```handlebars
22{{apidocs "index.js"}}
23```
24
25With Verb (lo-dash, with special delimiters to avoid delimiter collision in markdown docs):
26
27```js
28{%= apidocs('index.js') %}
29```
30
31
32## Running tests
33Install dev dependencies:
34
35```bash
36npm i -d && npm test
37```
38
39
40See [the tests](./test.js) for actual usage examples.
41
42
43## Register the helper
44
45> This should work with any engine, here are a few examples
46
47### [template]
48
49Register the helper for use with any template engine
50
51```js
52template.helper('apidocs', require('helper-apidocs'));
53```
54
55### [assemble]
56
57To register the helper for use with [assemble] v0.6.x:
58
59```js
60assemble.helper('apidocs', require('helper-apidocs'));
61```
62
63### [verb]
64
65Register the helper for use with [verb]:
66
67```js
68var verb = require('verb');
69verb.helper('apidocs', require('helper-apidocs'));
70
71verb.task('default', function() {
72 verb.src('.verb*.md')
73 .pipe(verb.dest('./'));
74});
75```
76
77### [handlebars]
78
79```js
80var handlebars = require('handlebars');
81handlebars.registerHelper('apidocs', require('helper-apidocs'));
82```
83
84### [Lo-Dash] or [underscore]
85
86```js
87// as a mixin
88_.mixin({apidocs: apidocsHelper});
89_.template('<%= _.apidocs("fixtures/*.js") %>', {});
90
91// passed on the context
92_.template('<%= apidocs("fixtures/*.js") %>', {apidocs: apidocsHelper});
93
94// as an import
95var settings = {imports: {apidocs: apidocsHelper}};
96_.template('<%= apidocs("fixtures/*.js") %>', {}, settings);
97```
98
99## Contributing
100Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/helper-apidocs/issues). To request or contribute a helper to the [github.com/helpers][helpers] org, please read [this contributing guide][guide] to get started.
101
102## Author
103
104**Jon Schlinkert**
105
106
107## License
108Copyright (c) 2014-2015 Jon Schlinkert
109Released under the MIT license
110
111***
112
113_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on February 27, 2015._
114
115[assemble]: https://github.com/assemble/assemble
116[generator-verb]: https://github.com/assemble/generator-verb
117[handlebars-helpers]: https://github.com/assemble/handlebars-helpers/
118[handlebars]: https://github.com/wycats/handlebars.js/
119[helpers]: https://github.com/helpers
120[Lo-Dash]: https://lodash.com/
121[template]: https://github.com/jonschlinkert/template
122[underscore]: https://github.com/jashkenas/underscore
123[verb]: https://github.com/assemble/verb
124[guide]: https://github.com/helpers/requests
125
126<!-- deps:helper-resolve -->