UNPKG

3.08 kBMarkdownView Raw
1# helper-apidocs [![NPM version](https://badge.fury.io/js/helper-apidocs.svg)](http://badge.fury.io/js/helper-apidocs)
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## Run tests
33
34```bash
35npm test
36```
37See [the tests](./test.js) for actual usage examples.
38
39
40
41## Register the helper
42
43> This should work with any engine, here are a few examples
44
45### [template]
46
47Register the helper for use with any template engine
48
49```js
50template.helper('apidocs', require('helper-apidocs'));
51```
52
53### [assemble]
54
55To register the helper for use with [assemble] v0.6.x:
56
57```js
58assemble.helper('apidocs', require('helper-apidocs'));
59```
60
61### [verb]
62
63Register the helper for use with [verb]:
64
65```js
66var verb = require('verb');
67verb.helper('apidocs', require('helper-apidocs'));
68
69verb.task('default', function() {
70 verb.src('.verb*.md')
71 .pipe(verb.dest('./'));
72});
73```
74
75### [handlebars]
76
77```js
78var handlebars = require('handlebars');
79handlebars.registerHelper('apidocs', require('helper-apidocs'));
80```
81
82### [Lo-Dash] or [underscore]
83
84```js
85// as a mixin
86_.mixin({apidocs: apidocsHelper});
87_.template('<%= _.apidocs("fixtures/*.js") %>', {});
88
89// passed on the context
90_.template('<%= apidocs("fixtures/*.js") %>', {apidocs: apidocsHelper});
91
92// as an import
93var settings = {imports: {apidocs: apidocsHelper}};
94_.template('<%= apidocs("fixtures/*.js") %>', {}, settings);
95```
96
97## Contributing
98Pull 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.
99
100## Author
101
102**Jon Schlinkert**
103
104+ [github/jonschlinkert](https://github.com/jonschlinkert)
105+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
106
107## License
108Copyright (c) 2014-2015 Jon Schlinkert
109Released under the MIT license
110
111***
112
113_This file was generated by [verb](https://github.com/assemble/verb) on February 13, 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
\No newline at end of file