helper-codelinks
Version:
Generate a list of links that take you to the first line of code for each method in a given directory.
99 lines (69 loc) • 2.99 kB
Markdown
> Generate a list of links that take you to the first line of code for each method in a given directory.
```bash
npm i helper-codelinks --save
```
Add a `verbfile.js` to your project with the following:
```js
var verb = require('verb');
// register the helper
verb.helper('codelinks', require('helper-codelinks'));
// add a task to build your docs
verb.task('default', function () {
return verb.src('my-documentation.md')
.pipe(verb.dest('docs/'));
});
```
In your `.verb.md` file:
```markdown
{%= codelinks('lib/', {filter: '!**/foo.js'}) %}
```
Results in markdown like this:
```markdown
+ **[one](fixtures/one.js)**
- [.a](fixtures/one.js
- [.b](fixtures/one.js
- [.c](fixtures/one.js
+ **[two](fixtures/two.js)**
- [.c](fixtures/two.js
- [.d](fixtures/two.js
- [.e](fixtures/two.js
_(Code links generated by [verb] using the [api-toc] helper)_
```
Which renders to a list of links that looks like this:
+ **[one](fixtures/one.js)**
- [.a](fixtures/one.js
- [.b](fixtures/one.js
- [.c](fixtures/one.js
+ **[two](fixtures/two.js)**
- [.c](fixtures/two.js
- [.d](fixtures/two.js
- [.e](fixtures/two.js
_(Code links generated by [verb] using the [api-toc] helper)_
See the [example verbfile.js](./verbfile.js).
* [template-helpers](https://github.com/jonschlinkert/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.
* [verb](https://github.com/assemble/verb): Verb makes it dead simple to generate markdown documentation, using simple templates, with zero configuration required. A project without documentation is like a project that doesn't exist.
* [api-toc](https://github.com/jonschlinkert/api-toc): Pass a dirname, get a markdown-formatted Table of Contents for your API.
Install dev dependencies:
```bash
npm i -d && npm test
```
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/helpers/helper-codelinks/issues)
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 19, 2015._
<!-- reflinks generated by verb-reflinks plugin -->
[]: https://github.com/jonschlinkert/api-toc
[]: https://github.com/assemble/verb
[]: https://github.com/jonschlinkert/template