Skip to content

Commit c94ed96

Browse files
committed
fixes README example #5
1 parent fb936cd commit c94ed96

File tree

5 files changed

+77
-60
lines changed

5 files changed

+77
-60
lines changed

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,45 @@
88

99
***[Try the jsdoc2md v2 pre-release](https://github.com/jsdoc2md/jsdoc-to-markdown/releases)***
1010

11-
<a name="module_jsdoc-api"></a>
11+
# jsdoc-api
1212

13-
## jsdoc-api
1413
A programmatic interface for [jsdoc3](https://github.com/jsdoc3/jsdoc) with a few features:
1514

1615
- Sync and async (Promise) interfaces on the two main jsdoc operations ('explain' and 'render documentation').
1716
- Input (source code) can supplied as a string or set of file names/globs.
1817
- Optional caching, dramatically speeding up future invocations with the same input.
1918
- Supports html input
2019

21-
**Example**
20+
## Synopsis
21+
2222
```js
2323
> const jsdoc = require('jsdoc-api')
2424

25-
> jsdoc.explainSync({ source: '/** example doclet *∕ \n var example = true' })
26-
25+
> jsdoc.explainSync({ source: '/** example doclet */ \n var example = true' })
2726
[ { comment: '/** example doclet *∕',
28-
meta:
29-
{ range: [ 28, 42 ],
30-
filename: 'nkrf18zlymohia4i29a0zkyt84obt9.js',
31-
lineno: 2,
32-
path: '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T',
33-
code:
34-
{ id: 'astnode100000002',
35-
name: 'example',
36-
type: 'Literal',
37-
value: true } },
38-
description: 'example doclet',
39-
name: 'example',
40-
longname: 'example',
41-
kind: 'member',
42-
scope: 'global' },
43-
{ kind: 'package',
44-
longname: 'package:undefined',
45-
files: [ '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T/nkrf18zlymohia4i29a0zkyt84obt9.js' ] } ]
27+
meta:
28+
{ range: [ 28, 42 ],
29+
filename: 'nkrf18zlymohia4i29a0zkyt84obt9.js',
30+
lineno: 2,
31+
path: '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T',
32+
code:
33+
{ id: 'astnode100000002',
34+
name: 'example',
35+
type: 'Literal',
36+
value: true } },
37+
description: 'example doclet',
38+
name: 'example',
39+
longname: 'example',
40+
kind: 'member',
41+
scope: 'global' },
42+
{ kind: 'package',
43+
longname: 'package:undefined',
44+
files: [ '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T/nkrf18zlymohia4i29a0zkyt84obt9.js' ] } ]
4645
```
4746

47+
# API Reference
48+
49+
4850
* [jsdoc-api](#module_jsdoc-api)
4951
* _static_
5052
* [.cache](#module_jsdoc-api.cache) : <code>[cache-point](https://github.com/75lb/cache-point)</code>
@@ -73,7 +75,7 @@ A programmatic interface for [jsdoc3](https://github.com/jsdoc3/jsdoc) with a fe
7375
<a name="module_jsdoc-api.cache"></a>
7476

7577
### jsdoc.cache : <code>[cache-point](https://github.com/75lb/cache-point)</code>
76-
The [cache-point](https://github.com/75lb/cache-point) instance used when `cache: true` is specified on `.explain()`, `.explainSync()` or `.createExplainStream()`.
78+
The [cache-point](https://github.com/75lb/cache-point) instance used when `cache: true` is specified on `.explain()` or `.explainSync()`.
7779

7880
**Kind**: static property of <code>[jsdoc-api](#module_jsdoc-api)</code>
7981
<a name="module_jsdoc-api.explainSync"></a>
@@ -238,7 +240,6 @@ Enable experimental parsing of `.html` files.
238240

239241
**Kind**: instance property of <code>[JsdocOptions](#module_jsdoc-api..JsdocOptions)</code>
240242

241-
242243
* * *
243244

244245
&copy; 2015-16 Lloyd Brookes \<[email protected]\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

jsdoc2md/README.hbs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,49 @@
88

99
***[Try the jsdoc2md v2 pre-release](https://github.com/jsdoc2md/jsdoc-to-markdown/releases)***
1010

11-
{{#module name="jsdoc-api"}}{{>docs}}{{/module}}
11+
# jsdoc-api
12+
13+
A programmatic interface for [jsdoc3](https://github.com/jsdoc3/jsdoc) with a few features:
14+
15+
- Sync and async (Promise) interfaces on the two main jsdoc operations ('explain' and 'render documentation').
16+
- Input (source code) can supplied as a string or set of file names/globs.
17+
- Optional caching, dramatically speeding up future invocations with the same input.
18+
- Supports html input
19+
20+
## Synopsis
21+
22+
```js
23+
> const jsdoc = require('jsdoc-api')
24+
25+
> jsdoc.explainSync({ source: '/** example doclet */ \n var example = true' })
26+
[ { comment: '/** example doclet *∕',
27+
meta:
28+
{ range: [ 28, 42 ],
29+
filename: 'nkrf18zlymohia4i29a0zkyt84obt9.js',
30+
lineno: 2,
31+
path: '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T',
32+
code:
33+
{ id: 'astnode100000002',
34+
name: 'example',
35+
type: 'Literal',
36+
value: true } },
37+
description: 'example doclet',
38+
name: 'example',
39+
longname: 'example',
40+
kind: 'member',
41+
scope: 'global' },
42+
{ kind: 'package',
43+
longname: 'package:undefined',
44+
files: [ '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T/nkrf18zlymohia4i29a0zkyt84obt9.js' ] } ]
45+
```
46+
47+
# API Reference
48+
49+
{{#module name="jsdoc-api"}}
50+
{{>body~}}
51+
{{>member-index~}}
52+
{{>members~}}
53+
{{/module}}
1254

1355
* * *
1456

lib/jsdoc-api.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,8 @@
11
'use strict'
22

33
/**
4-
* A programmatic interface for [jsdoc3](https://github.com/jsdoc3/jsdoc) with a few features:
5-
*
6-
* - Sync and async (Promise) interfaces on the two main jsdoc operations ('explain' and 'render documentation').
7-
* - Input (source code) can supplied as a string or set of file names/globs.
8-
* - Optional caching, dramatically speeding up future invocations with the same input.
9-
* - Supports html input
10-
*
114
* @module jsdoc-api
125
* @typicalname jsdoc
13-
* @example
14-
* > const jsdoc = require('jsdoc-api')
15-
*
16-
* > jsdoc.explainSync({ source: '/** example doclet *∕ \n var example = true' })
17-
*
18-
* [ { comment: '/** example doclet *∕',
19-
* meta:
20-
* { range: [ 28, 42 ],
21-
* filename: 'nkrf18zlymohia4i29a0zkyt84obt9.js',
22-
* lineno: 2,
23-
* path: '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T',
24-
* code:
25-
* { id: 'astnode100000002',
26-
* name: 'example',
27-
* type: 'Literal',
28-
* value: true } },
29-
* description: 'example doclet',
30-
* name: 'example',
31-
* longname: 'example',
32-
* kind: 'member',
33-
* scope: 'global' },
34-
* { kind: 'package',
35-
* longname: 'package:undefined',
36-
* files: [ '/var/folders/74/tqh7thm11tq72d7sjty9qvdh0000gn/T/nkrf18zlymohia4i29a0zkyt84obt9.js' ] } ]
376
*/
387
exports.explainSync = explainSync
398
exports.explain = explain
@@ -42,7 +11,7 @@ exports.renderSync = renderSync
4211
const path = require('path')
4312
const Cache = require('cache-point')
4413
/**
45-
* The [cache-point](https://github.com/75lb/cache-point) instance used when `cache: true` is specified on `.explain()`, `.explainSync()` or `.createExplainStream()`.
14+
* The [cache-point](https://github.com/75lb/cache-point) instance used when `cache: true` is specified on `.explain()` or `.explainSync()`.
4615
* @type {external:cache-point}
4716
*/
4817
exports.cache = new Cache({ dir: path.join(require('os').tmpdir(), 'jsdoc-api') })

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"coveralls": "^2.11.14",
3131
"jsdoc-to-markdown": "^2.0.0-alpha.8",
3232
"rimraf": "^2.5.4",
33-
"test-runner": "~0.2.3"
33+
"test-runner": "~0.2.4"
3434
},
3535
"dependencies": {
3636
"array-back": "^1.0.3",
@@ -41,7 +41,7 @@
4141
"file-set": "^1.0.2",
4242
"jsdoc-75lb": "^3.5.6",
4343
"object-to-spawn-args": "^1.1.0",
44-
"promise.prototype.finally": "^2.0.0",
44+
"promise.prototype.finally": "^2.0.1",
4545
"temp-path": "^1.0.0",
4646
"then-fs": "^2.0.0",
4747
"walk-back": "^2.0.1"

test/explain-sync.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ if (require('child_process').spawnSync) {
2727
a.deepEqual(output, expectedOutput)
2828
})
2929

30+
runner.test('.explainSync({ source }), defaults', function () {
31+
var output = jsdoc.explainSync({ source: '/** example doclet */ \n var example = true' })
32+
a.strictEqual(output[0].description, 'example doclet')
33+
})
34+
3035
runner.test('.explainSync: no valid files', function () {
3136
a.throws(
3237
function () {

0 commit comments

Comments
 (0)