1 | jsdoctest
|
2 | =========
|
3 | [![Build Status](https://travis-ci.org/yamadapc/jsdoctest.svg)](https://travis-ci.org/yamadapc/jsdoctest)
|
4 | [![Coverage Status](https://coveralls.io/repos/yamadapc/jsdoctest/badge.png)](https://coveralls.io/r/yamadapc/jsdoctest)
|
5 | [![Stories in Ready](https://badge.waffle.io/yamadapc/jsdoctest.svg?label=ready&title=Ready)](http://waffle.io/yamadapc/jsdoctest)
|
6 | [![Dependency Status](https://david-dm.org/yamadapc/jsdoctest.svg)](https://david-dm.org/yamadapc/jsdoctest)
|
7 | [![devDependency Status](https://david-dm.org/yamadapc/jsdoctest/dev-status.svg)](https://david-dm.org/yamadapc/jsdoctest#info=devDependencies)
|
8 | [![npm downloads](http://img.shields.io/npm/dm/jsdoctest.svg)](https://www.npmjs.org/package/jsdoctest)
|
9 | [![npm version](http://img.shields.io/npm/v/jsdoctest.svg)](https://www.npmjs.org/package/jsdoctest)
|
10 | - - -
|
11 | *Though this is an initial working version, it's a really hacky and bad
|
12 | implementation, meant as a proof-of-concept. I'm just putting it online to be on
|
13 | SVC and push the implementation forward.*
|
14 |
|
15 | ![demo](/jsdoctest-demo.gif)
|
16 |
|
17 | Parses [`jsdoc`](http://usejsdoc.org/) `@example` tags from annotated functions
|
18 | and runs them as if they were doctests.
|
19 |
|
20 | Inspired by the [doctest](https://docs.python.org/2/library/doctest.html) python
|
21 | library, as well as its [doctestjs](http://doctestjs.org) javascript
|
22 | implementation.
|
23 |
|
24 | ## Set-up
|
25 | Here's a two line set-up you can use:
|
26 | ```bash
|
27 | $ npm i -g jsdoctest && jsdoctest --init
|
28 | Adding `jsdoctest` script to your package.json...
|
29 | Installing `mocha` and `jsdoctest` with npm:
|
30 | # ... npm doing some work...
|
31 | You can now run doctests with `npm run jsdoctest` or `npm test`
|
32 | ```
|
33 | This will add sensible defaults to your `package.json` which you can then edit.
|
34 |
|
35 | ## Usage
|
36 | The recommended way of using jsdoctest is to use it
|
37 | [`mocha`](https://github.com/mochajs/mocha). That is made possible with:
|
38 | ```bash
|
39 | npm i mocha jsdoctest
|
40 | mocha --require jsdoctest <module-name>
|
41 | ```
|
42 |
|
43 | There's also a rudimentary command-line interface, which can be ran with:
|
44 | ```bash
|
45 | npm i jsdoctest
|
46 | jsdoctest <module-name>
|
47 | ```
|
48 |
|
49 | ## Disabling
|
50 | To disable running jsdoctests, while still requiring it with `mocha` (I don't
|
51 | know why, but you may) you can set the `JSDOCTEST_DISABLE` environment variable
|
52 | to anything (`JSDOCTEST_DISABLE=true mocha --requre...`).
|
53 |
|
54 | ## License
|
55 | This code is licensed under the MIT license for Pedro Tacla Yamada. For more
|
56 | information, please refer to the [LICENSE](/LICENSE) file.
|