UNPKG

2.44 kBMarkdownView Raw
1jsdoctest
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
12implementation, meant as a proof-of-concept. I'm just putting it online to be on
13SVC and push the implementation forward.*
14
15![demo](/jsdoctest-demo.gif)
16
17Parses [`jsdoc`](http://usejsdoc.org/) `@example` tags from annotated functions
18and runs them as if they were doctests.
19
20Inspired by the [doctest](https://docs.python.org/2/library/doctest.html) python
21library, as well as its [doctestjs](http://doctestjs.org) javascript
22implementation.
23
24## Set-up
25Here's a two line set-up you can use:
26```bash
27$ npm i -g jsdoctest && jsdoctest --init
28Adding `jsdoctest` script to your package.json...
29Installing `mocha` and `jsdoctest` with npm:
30# ... npm doing some work...
31You can now run doctests with `npm run jsdoctest` or `npm test`
32```
33This will add sensible defaults to your `package.json` which you can then edit.
34
35## Usage
36The recommended way of using jsdoctest is to use it
37[`mocha`](https://github.com/mochajs/mocha). That is made possible with:
38```bash
39npm i mocha jsdoctest
40mocha --require jsdoctest <module-name>
41```
42
43There's also a rudimentary command-line interface, which can be ran with:
44```bash
45npm i jsdoctest
46jsdoctest <module-name>
47```
48
49## Disabling
50To disable running jsdoctests, while still requiring it with `mocha` (I don't
51know why, but you may) you can set the `JSDOCTEST_DISABLE` environment variable
52to anything (`JSDOCTEST_DISABLE=true mocha --requre...`).
53
54## License
55This code is licensed under the MIT license for Pedro Tacla Yamada. For more
56information, please refer to the [LICENSE](/LICENSE) file.