Skip to content

Commit 0113e56

Browse files
feat: remove all deps and use one bundle
1 parent 66ae8ad commit 0113e56

File tree

12 files changed

+917
-372
lines changed

12 files changed

+917
-372
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ src/default_theme/*
33
coverage/*
44
lib/*
55
declarations/*
6+
documentation.js
7+
bin/*

.github/workflows/node.js.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ jobs:
2727
node-version: ${{ matrix.node-version }}
2828
cache: 'npm'
2929
- run: npm ci
30+
- run: npm run build
3031
- run: npm run test-ci

bin/documentation.js

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,4 @@
22

33
/* eslint no-console: 0 */
44

5-
import yargs from 'yargs';
6-
import { hideBin } from 'yargs/helpers';
7-
import commands from '../src/commands/index.js';
8-
9-
yargs(hideBin(process.argv))
10-
.strict()
11-
.command(commands.build)
12-
.command(commands.lint)
13-
.command(commands.readme)
14-
.example('documentation build foo.js -f md > API.md')
15-
.example('documentation readme index.js -s "API Docs" --github')
16-
.version()
17-
.usage(
18-
`Usage:
19-
20-
# generate markdown docs for index.js and files it references
21-
$0 build index.js -f md
22-
23-
# generate html docs for all files in src
24-
$0 build src/** -f html -o docs
25-
26-
# document index.js, ignoring any files it requires or imports
27-
$0 build index.js -f md --shallow
28-
29-
# build, serve, and live-update html docs for app.js
30-
$0 serve app.js
31-
32-
# validate JSDoc syntax in util.js
33-
$0 lint util.js
34-
35-
# update the API section of README.md with docs from index.js
36-
$0 readme index.js --section=API
37-
38-
# build docs for all values exported by index.js
39-
$0 build --document-exported index.js
40-
`
41-
)
42-
.recommendCommands()
43-
.help().argv;
5+
import argv from '../documentation.js';

docs/NODE_API.md

Lines changed: 76 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
### Table of Contents
44

5-
* [lint][1]
6-
* [Parameters][2]
7-
* [Examples][3]
8-
* [build][4]
9-
* [Parameters][5]
10-
* [Examples][6]
11-
* [formats][7]
12-
* [formats.html][8]
13-
* [Parameters][9]
14-
* [Examples][10]
15-
* [formats.markdown][11]
16-
* [Parameters][12]
17-
* [Examples][13]
18-
* [formats.json][14]
19-
* [Parameters][15]
20-
* [Examples][16]
5+
- [lint][1]
6+
- [Parameters][2]
7+
- [Examples][3]
8+
- [build][4]
9+
- [Parameters][5]
10+
- [Examples][6]
11+
- [formats][7]
12+
- [formats.html][8]
13+
- [Parameters][9]
14+
- [Examples][10]
15+
- [formats.markdown][11]
16+
- [Parameters][12]
17+
- [Examples][13]
18+
- [formats.json][14]
19+
- [Parameters][15]
20+
- [Examples][16]
2121

2222
## lint
2323

@@ -27,20 +27,20 @@ of lint information intended for human-readable output.
2727

2828
### Parameters
2929

30-
* `indexes` **([Array][17]<[string][18]> | [string][18])** files to process
31-
* `args` **[Object][19]** args
32-
33-
* `args.external` **[Array][17]<[string][18]>** a string regex / glob match pattern
34-
that defines what external modules will be whitelisted and included in the
35-
generated documentation.
36-
* `args.shallow` **[boolean][20]** whether to avoid dependency parsing
37-
even in JavaScript code. (optional, default `false`)
38-
* `args.inferPrivate` **[string][18]?** a valid regular expression string
39-
to infer whether a code element should be private, given its naming structure.
40-
For instance, you can specify `inferPrivate: '^_'` to automatically treat
41-
methods named like `_myMethod` as private.
42-
* `args.extension` **([string][18] | [Array][17]<[string][18]>)?** treat additional file extensions
43-
as JavaScript, extending the default set of `js`, `es6`, and `jsx`.
30+
- `indexes` **([Array][17]<[string][18]> | [string][18])** files to process
31+
- `args` **[Object][19]** args
32+
33+
- `args.external` **[Array][17]<[string][18]>** a string regex / glob match pattern
34+
that defines what external modules will be whitelisted and included in the
35+
generated documentation.
36+
- `args.shallow` **[boolean][20]** whether to avoid dependency parsing
37+
even in JavaScript code.&#x20;(optional, default `false`)
38+
- `args.inferPrivate` **[string][18]?** a valid regular expression string
39+
to infer whether a code element should be private, given its naming structure.
40+
For instance, you can specify `inferPrivate: '^_'` to automatically treat
41+
methods named like `_myMethod` as private.
42+
- `args.extension` **([string][18] | [Array][17]<[string][18]>)?** treat additional file extensions
43+
as JavaScript, extending the default set of `js`, `es6`, and `jsx`.
4444

4545
### Examples
4646

@@ -64,42 +64,45 @@ comments, given a root file as a path.
6464

6565
### Parameters
6666

67-
* `indexes` **([Array][17]<[string][18]> | [string][18])** files to process
68-
* `args` **[Object][19]** args
69-
70-
* `args.external` **[Array][17]<[string][18]>** a string regex / glob match pattern
71-
that defines what external modules will be whitelisted and included in the
72-
generated documentation.
73-
* `args.shallow` **[boolean][20]** whether to avoid dependency parsing
74-
even in JavaScript code. (optional, default `false`)
75-
* `args.order` **[Array][17]<([string][18] | [Object][19])>** optional array that
76-
defines sorting order of documentation (optional, default `[]`)
77-
* `args.access` **[Array][17]<[string][18]>** an array of access levels
78-
to output in documentation (optional, default `[]`)
79-
* `args.hljs` **[Object][19]?** hljs optional args
80-
81-
* `args.hljs.highlightAuto` **[boolean][20]** hljs automatically detect language (optional, default `false`)
82-
* `args.hljs.languages` **[Array][17]?** languages for hljs to choose from
83-
* `args.inferPrivate` **[string][18]?** a valid regular expression string
84-
to infer whether a code element should be private, given its naming structure.
85-
For instance, you can specify `inferPrivate: '^_'` to automatically treat
86-
methods named like `_myMethod` as private.
87-
* `args.extension` **([string][18] | [Array][17]<[string][18]>)?** treat additional file extensions
88-
as JavaScript, extending the default set of `js`, `es6`, and `jsx`.
67+
- `indexes` **([Array][17]<[string][18]> | [string][18])** files to process
68+
- `args` **[Object][19]** args
69+
70+
- `args.external` **[Array][17]<[string][18]>** a string regex / glob match pattern
71+
that defines what external modules will be whitelisted and included in the
72+
generated documentation.
73+
- `args.shallow` **[boolean][20]** whether to avoid dependency parsing
74+
even in JavaScript code.&#x20;(optional, default `false`)
75+
- `args.order` **[Array][17]<([string][18] | [Object][19])>** optional array that
76+
defines sorting order of documentation&#x20;(optional, default `[]`)
77+
- `args.access` **[Array][17]<[string][18]>** an array of access levels
78+
to output in documentation&#x20;(optional, default `[]`)
79+
- `args.hljs` **[Object][19]?** hljs optional args
80+
81+
- `args.hljs.highlightAuto` **[boolean][20]** hljs automatically detect language&#x20;(optional, default `false`)
82+
- `args.hljs.languages` **[Array][17]?** languages for hljs to choose from
83+
84+
- `args.inferPrivate` **[string][18]?** a valid regular expression string
85+
to infer whether a code element should be private, given its naming structure.
86+
For instance, you can specify `inferPrivate: '^_'` to automatically treat
87+
methods named like `_myMethod` as private.
88+
- `args.extension` **([string][18] | [Array][17]<[string][18]>)?** treat additional file extensions
89+
as JavaScript, extending the default set of `js`, `es6`, and `jsx`.
8990

9091
### Examples
9192

9293
```javascript
9394
var documentation = require('documentation');
9495

95-
documentation.build(['index.js'], {
96-
// only output comments with an explicit @public tag
97-
access: ['public']
98-
}).then(res => {
99-
// res is an array of parsed comments with inferred properties
100-
// and more: everything you need to build documentation or
101-
// any other kind of code data.
102-
});
96+
documentation
97+
.build(['index.js'], {
98+
// only output comments with an explicit @public tag
99+
access: ['public']
100+
})
101+
.then(res => {
102+
// res is an array of parsed comments with inferred properties
103+
// and more: everything you need to build documentation or
104+
// any other kind of code data.
105+
});
103106
```
104107

105108
Returns **[Promise][21]** results
@@ -117,17 +120,18 @@ Formats documentation as HTML.
117120

118121
### Parameters
119122

120-
* `comments` **[Array][17]<[Comment][22]>** parsed comments
121-
* `config` **[Object][19]** Options that can customize the output
123+
- `comments` **[Array][17]<[Comment][22]>** parsed comments
124+
- `config` **[Object][19]** Options that can customize the output
122125

123-
* `config.theme` **[string][18]** Name of a module used for an HTML theme. (optional, default `'default_theme'`)
126+
- `config.theme` **[string][18]** Name of a module used for an HTML theme.&#x20;(optional, default `'default_theme'`)
124127

125128
### Examples
126129

127130
```javascript
128131
var documentation = require('documentation');
129132

130-
documentation.build(['index.js'])
133+
documentation
134+
.build(['index.js'])
131135
.then(documentation.formats.html);
132136
```
133137

@@ -140,16 +144,17 @@ Formats documentation as
140144

141145
### Parameters
142146

143-
* `comments` **[Array][17]<[Object][19]>** parsed comments
144-
* `args` **[Object][19]** Options that can customize the output
147+
- `comments` **[Array][17]<[Object][19]>** parsed comments
148+
- `args` **[Object][19]** Options that can customize the output
145149

146150
### Examples
147151

148152
```javascript
149153
var documentation = require('documentation');
150154
var fs = require('fs');
151155

152-
documentation.build(['index.js'])
156+
documentation
157+
.build(['index.js'])
153158
.then(documentation.formats.md)
154159
.then(output => {
155160
// output is a string of Markdown data
@@ -165,66 +170,45 @@ Formats documentation as a JSON string.
165170

166171
### Parameters
167172

168-
* `comments` **[Array][17]<[Comment][22]>** parsed comments
173+
- `comments` **[Array][17]<[Comment][22]>** parsed comments
169174

170175
### Examples
171176

172177
```javascript
173178
var documentation = require('documentation');
174179
var fs = require('fs');
175180

176-
documentation.build(['index.js'])
181+
documentation
182+
.build(['index.js'])
177183
.then(documentation.formats.json)
178184
.then(output => {
179185
// output is a string of JSON data
180186
fs.writeFileSync('./output.json', output);
181187
});
182188
```
183189

184-
Returns **[Promise][21]<[string][18]>**
190+
Returns **[Promise][21]<[string][18]>**&#x20;
185191

186192
[1]: #lint
187-
188193
[2]: #parameters
189-
190194
[3]: #examples
191-
192195
[4]: #build
193-
194196
[5]: #parameters-1
195-
196197
[6]: #examples-1
197-
198198
[7]: #formats
199-
200199
[8]: #formatshtml
201-
202200
[9]: #parameters-2
203-
204201
[10]: #examples-2
205-
206202
[11]: #formatsmarkdown
207-
208203
[12]: #parameters-3
209-
210204
[13]: #examples-3
211-
212205
[14]: #formatsjson
213-
214206
[15]: #parameters-4
215-
216207
[16]: #examples-4
217-
218208
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
219-
220209
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
221-
222210
[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
223-
224211
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
225-
226212
[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
227-
228213
[22]: https://developer.mozilla.org/docs/Web/API/Comment/Comment
229-
230214
[23]: https://daringfireball.net/projects/markdown/

index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint no-console: 0 */
2+
3+
import yargs from 'yargs';
4+
import commands from './src/commands/index.js';
5+
import { hideBin } from 'yargs/helpers';
6+
7+
export default yargs(hideBin(process.argv))
8+
.strict()
9+
.command(commands.build)
10+
.command(commands.lint)
11+
.command(commands.readme)
12+
.example('documentation build foo.js -f md > API.md')
13+
.example('documentation readme index.js -s "API Docs" --github')
14+
.version()
15+
.usage(
16+
`Usage:
17+
18+
# generate markdown docs for index.js and files it references
19+
$0 build index.js -f md
20+
21+
# generate html docs for all files in src
22+
$0 build src/** -f html -o docs
23+
24+
# document index.js, ignoring any files it requires or imports
25+
$0 build index.js -f md --shallow
26+
27+
# validate JSDoc syntax in util.js
28+
$0 lint util.js
29+
30+
# update the API section of README.md with docs from index.js
31+
$0 readme index.js --section=API
32+
33+
# build docs for all values exported by index.js
34+
$0 build --document-exported index.js
35+
`
36+
)
37+
.recommendCommands()
38+
.help().argv;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy