forked from jsdoc2md/jsdoc-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
170 lines (148 loc) · 4.38 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
'use strict'
/**
* @module jsdoc-api
* @typicalname jsdoc
*/
exports.explainSync = explainSync
exports.explain = explain
exports.renderSync = renderSync
const path = require('path')
const Cache = require('cache-point')
/**
* The [cache-point](https://github.com/75lb/cache-point) instance used when `cache: true` is specified on `.explain()` or `.explainSync()`.
* @type {external:cache-point}
*/
exports.cache = new Cache({ dir: path.join(require('os').tmpdir(), 'jsdoc-api') })
/**
* Returns jsdoc explain output.
*
* @param [options] {module:jsdoc-api~JsdocOptions}
* @returns {object[]}
* @static
* @prerequisite Requires node v0.12 or above
*/
function explainSync (options) {
options = new JsdocOptions(options)
const ExplainSync = require('./lib/explain-sync')
const command = new ExplainSync(options, exports.cache)
return command.execute()
}
/**
* Returns a promise for the jsdoc explain output.
*
* @param [options] {module:jsdoc-api~JsdocOptions}
* @fulfil {object[]} - jsdoc explain output
* @returns {Promise}
* @static
*/
function explain (options) {
options = new JsdocOptions(options)
const Explain = require('./lib/explain')
const command = new Explain(options, exports.cache)
return command.execute()
}
/**
* Render jsdoc documentation.
*
* @param [options] {module:jsdoc-api~JsdocOptions}
* @prerequisite Requires node v0.12 or above
* @static
* @example
* jsdoc.renderSync({ files: 'lib/*', destination: 'api-docs' })
*/
function renderSync (options) {
options = new JsdocOptions(options)
const RenderSync = require('./lib/render-sync')
const command = new RenderSync(options)
return command.execute()
}
/**
* The jsdoc options, common for all operations.
* @typicalname options
*/
class JsdocOptions {
constructor (options) {
options = options || {}
const arrayify = require('array-back')
/**
* One or more filenames to process. Either this or `source` must be supplied.
* @type {string|string[]}
*/
this.files = arrayify(options.files)
/**
* A string containing source code to process. Either this or `source` must be supplied.
* @type {string}
*/
this.source = options.source
/**
* Set to `true` to cache the output - future invocations with the same input will return immediately.
* @type {boolean}
* @default
*/
this.cache = options.cache
/**
* Only display symbols with the given access: "public", "protected", "private" or "undefined", or "all" for all access levels. Default: all except "private".
* @type {string}
*/
this.access = options.access
/**
* The path to the configuration file. Default: path/to/jsdoc/conf.json.
* @type {string}
*/
this.configure = options.configure
/**
* The path to the output folder. Use "console" to dump data to the console. Default: ./out/.
* @type {string}
*/
this.destination = options.destination
/**
* Assume this encoding when reading all source files. Default: utf8.
* @type {string}
*/
this.encoding = options.encoding
/**
* Display symbols marked with the @private tag. Equivalent to "--access all". Default: false.
* @type {boolean}
*/
this.private = options.private
/**
* The path to the project's package file. Default: path/to/sourcefiles/package.json
* @type {string}
*/
this.package = options.package
/**
* Treat errors as fatal errors, and treat warnings as errors. Default: false.
* @type {boolean}
*/
this.pedantic = options.pedantic
/**
* A query string to parse and store in jsdoc.env.opts.query. Example: foo=bar&baz=true.
* @type {string}
*/
this.query = options.query
/**
* Recurse into subdirectories when scanning for source files and tutorials.
* @type {boolean}
*/
this.recurse = options.recurse
/**
* The path to the project's README file. Default: path/to/sourcefiles/README.md.
* @type {string}
*/
this.readme = options.readme
/**
* The path to the template to use. Default: path/to/jsdoc/templates/default.
* @type {string}
*/
this.template = options.template
/**
* Directory in which JSDoc should search for tutorials.
* @type {string}
*/
this.tutorials = options.tutorials
}
}
/**
* @external cache-point
* @see https://github.com/75lb/cache-point
*/