Skip to content

Commit f2134dc

Browse files
committed
tidy comments
1 parent 3ff857e commit f2134dc

3 files changed

Lines changed: 97 additions & 77 deletions

File tree

File renamed without changes.

lib/jsdoc-parse.js

Lines changed: 79 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -12,74 +12,76 @@ const cliOptions = require('./cli-options')
1212
const os = require('os')
1313

1414
/**
15-
Exports a single function to parse jsdoc data.
16-
@module jsdoc-parse
17-
@example
18-
```js
19-
var parse = require("jsdoc-parse")
20-
```
21-
*/
15+
* Exports a single function to parse jsdoc data.
16+
* @module jsdoc-parse
17+
* @example
18+
* ```js
19+
* var parse = require("jsdoc-parse")
20+
* ```
21+
*/
2222
module.exports = jsdocParse
23+
jsdocParse.cliOptions = cliOptions.definitions
2324

2425
/**
25-
@class
26-
@classdesc All options for jsdoc-parse, including defaults
27-
*/
28-
function ParseOptions () {
29-
/**
30-
* A list of javascript source files (or glob expressions) to parse for documentation. If this option is not set jsdoc-parse will wait for source code on stdin (i.e. `cat *.js | jsdoc-parse <options>`).
31-
* @type {string | string[]}
32-
* @example
33-
* var parse = require("jsdoc-parse")
34-
* var fs = require("fs")
35-
*
36-
* // either supply one or more file names
37-
* parse({ src: "example.js" }).pipe(process.stdout)
38-
*
39-
* // or pipe in source code
40-
* fs.createReadStream("example.js").parse().pipe(process.stdout)
41-
*/
42-
this.src = null
26+
* All options for jsdoc-parse, including defaults
27+
*/
28+
class ParseOptions {
29+
constructor () {
30+
/**
31+
* A list of javascript source files (or glob expressions) to parse for documentation. If this option is not set jsdoc-parse will wait for source code on stdin (i.e. `cat *.js | jsdoc-parse <options>`).
32+
* @type {string | string[]}
33+
* @example
34+
* var parse = require("jsdoc-parse")
35+
* var fs = require("fs")
36+
*
37+
* // either supply one or more file names
38+
* parse({ src: "example.js" }).pipe(process.stdout)
39+
*
40+
* // or pipe in source code
41+
* fs.createReadStream("example.js").parse().pipe(process.stdout)
42+
*/
43+
this.src = null
4344

44-
/**
45-
Include identifier documentation marked as `@private` in the output
46-
@type {boolean}
47-
@default
48-
*/
49-
this.private = false
45+
/**
46+
* Include identifier documentation marked as `@private` in the output
47+
* @type {boolean}
48+
* @default
49+
*/
50+
this.private = false
5051

51-
/**
52-
Print a few stats about the doclets parsed
53-
@type {boolean}
54-
*/
55-
this.stats
52+
/**
53+
* Print a few stats about the doclets parsed
54+
* @type {boolean}
55+
*/
56+
this.stats
5657

57-
/**
58-
Enable experimental parsing of .html files.
59-
@type {boolean}
60-
@default
61-
*/
62-
this.html = false
58+
/**
59+
* Enable experimental parsing of .html files.
60+
* @type {boolean}
61+
* @default
62+
*/
63+
this.html = false
6364

64-
/**
65-
Sort by one of more fields, e.g. `--sort-by kind category`. Pass the special value `none` to remove the default sort order.
66-
@member module:jsdoc-parse~ParseOptions#sort-by
67-
@type {array}
68-
@default
69-
*/
70-
this['sort-by'] = [ 'scope', 'category', 'kind', 'order' ]
65+
/**
66+
* Sort by one of more fields, e.g. `--sort-by kind category`. Pass the special value `none` to * remove the default sort order.
67+
* @member module:jsdoc-parse~ParseOptions#sort-by
68+
* @type {array}
69+
* @default
70+
*/
71+
this['sort-by'] = [ 'scope', 'category', 'kind', 'order' ]
72+
}
7173
}
7274

7375
/**
74-
Documented javascript source in, documentation JSON out.
75-
@alias module:jsdoc-parse
76-
@param [options] {module:jsdoc-parse~ParseOptions} - parse options
77-
@returns {external:TransformStream}
78-
@example
79-
```js
80-
parse({ src:"lib/jsdoc-parse.js" }).pipe(process.stdout)
81-
```
82-
*/
76+
* Documented javascript source in, documentation JSON out.
77+
* @alias module:jsdoc-parse
78+
* @param [options] {module:jsdoc-parse~ParseOptions} - parse options
79+
* @returns {external:TransformStream}
80+
* @example
81+
* ```js
82+
* parse({ src:"lib/jsdoc-parse.js" }).pipe(process.stdout)
83+
* ```
84+
*/
8385
function jsdocParse (options) {
8486
options = o.extend(new ParseOptions(), options)
8587
var src = options.src
@@ -162,10 +164,10 @@ function OutputTransform (options) {
162164
util.inherits(OutputTransform, Transform)
163165

164166
/*
165-
Cross-platform. Spawns the command:
166-
`$ ../node_modules/jsdoc-75lb/jsdoc.js --pedantic -t . -c ../conf.json`
167-
Uses `publish.js` as a template and the [`plugins/parseHtml`](https://github.com/arodic/jsdoc/commit/0650ac14f2048f7e6c5968630b58dc4b007498aa) plugin.
168-
*/
167+
* Cross-platform. Spawns the command:
168+
* `$ ../node_modules/jsdoc-75lb/jsdoc.js --pedantic -t . -c ../conf.json`
169+
* Uses `publish.js` as a template and the [`plugins/parseHtml`](https://github.com/arodic/jsdoc/commit/0650ac14f2048f7e6c5968630b58dc4b007498aa) plugin.
170+
*/
169171
function getJsdocOutput (src, options, done) {
170172
var jsdocTemplatePath = path.resolve(__dirname, '..', 'lib')
171173
var jsdocPath = path.resolve(__dirname, '../node_modules/.bin/jsdoc')
@@ -177,7 +179,7 @@ function getJsdocOutput (src, options, done) {
177179
if (options.html) {
178180
args = args.concat([
179181
'-c',
180-
path.resolve(__dirname, 'conf.json')
182+
path.resolve(__dirname, 'default-conf.json')
181183
])
182184
} else if (options.conf) {
183185
args = args.concat([
@@ -208,14 +210,14 @@ function getJsdocOutput (src, options, done) {
208210
})
209211
}
210212

211-
jsdocParse.cliOptions = cliOptions.definitions
213+
212214

213215
/**
214-
@param {string} - input json string
215-
@param {object} - jsdoc-parse options
216-
@returns {string} - output json string to be streamed out
217-
@private
218-
*/
216+
* @param {string} - input json string
217+
* @param {object} - jsdoc-parse options
218+
* @returns {string} - output json string to be streamed out
219+
* @private
220+
*/
219221
function applyOptions (data, options) {
220222
data = JSON.parse(data.toString())
221223
if (options.stats) {
@@ -237,11 +239,11 @@ function applyOptions (data, options) {
237239
}
238240

239241
/**
240-
return some stats about the parsed data
241-
@param {object} - jsdoc-parse data
242-
@returns {object}
243-
@private
244-
*/
242+
* return some stats about the parsed data
243+
* @param {object} - jsdoc-parse data
244+
* @returns {object}
245+
* @private
246+
*/
245247
function getStats (data) {
246248
var stats = {
247249
identifiers: {}
@@ -272,6 +274,6 @@ function sort (array, sortBy) {
272274
}
273275

274276
/**
275-
@external TransformStream
276-
@see http://nodejs.org/api/stream.html#stream_class_stream_transform
277-
*/
277+
* @external TransformStream
278+
* @see http://nodejs.org/api/stream.html#stream_class_stream_transform
279+
*/

test/buggy/class-instance.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* class instance property docs not output if `@module` specified */
2+
3+
/**
4+
* @module something
5+
*/
6+
7+
/**
8+
* create something
9+
*/
10+
class Something {
11+
constructor () {
12+
/**
13+
* a value
14+
* @type {number}
15+
*/
16+
this.whatever = 1
17+
}
18+
}

0 commit comments

Comments
 (0)