Skip to content

Commit 0c848df

Browse files
feat: remove all deps and use one bundle
1 parent 810e08b commit 0c848df

File tree

8 files changed

+994
-375
lines changed

8 files changed

+994
-375
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,10 +120,10 @@ 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

@@ -129,7 +132,8 @@ var documentation = require('documentation');
129132
var streamArray = require('stream-array');
130133
var vfs = require('vinyl-fs');
131134

132-
documentation.build(['index.js'])
135+
documentation
136+
.build(['index.js'])
133137
.then(documentation.formats.html)
134138
.then(output => {
135139
streamArray(output).pipe(vfs.dest('./output-directory'));
@@ -145,16 +149,17 @@ Formats documentation as
145149

146150
### Parameters
147151

148-
* `comments` **[Array][17]<[Object][19]>** parsed comments
149-
* `args` **[Object][19]** Options that can customize the output
152+
- `comments` **[Array][17]<[Object][19]>** parsed comments
153+
- `args` **[Object][19]** Options that can customize the output
150154

151155
### Examples
152156

153157
```javascript
154158
var documentation = require('documentation');
155159
var fs = require('fs');
156160

157-
documentation.build(['index.js'])
161+
documentation
162+
.build(['index.js'])
158163
.then(documentation.formats.md)
159164
.then(output => {
160165
// output is a string of Markdown data
@@ -170,66 +175,45 @@ Formats documentation as a JSON string.
170175

171176
### Parameters
172177

173-
* `comments` **[Array][17]<[Comment][22]>** parsed comments
178+
- `comments` **[Array][17]<[Comment][22]>** parsed comments
174179

175180
### Examples
176181

177182
```javascript
178183
var documentation = require('documentation');
179184
var fs = require('fs');
180185

181-
documentation.build(['index.js'])
186+
documentation
187+
.build(['index.js'])
182188
.then(documentation.formats.json)
183189
.then(output => {
184190
// output is a string of JSON data
185191
fs.writeFileSync('./output.json', output);
186192
});
187193
```
188194

189-
Returns **[Promise][21]<[string][18]>**
195+
Returns **[Promise][21]<[string][18]>**&#x20;
190196

191197
[1]: #lint
192-
193198
[2]: #parameters
194-
195199
[3]: #examples
196-
197200
[4]: #build
198-
199201
[5]: #parameters-1
200-
201202
[6]: #examples-1
202-
203203
[7]: #formats
204-
205204
[8]: #formatshtml
206-
207205
[9]: #parameters-2
208-
209206
[10]: #examples-2
210-
211207
[11]: #formatsmarkdown
212-
213208
[12]: #parameters-3
214-
215209
[13]: #examples-3
216-
217210
[14]: #formatsjson
218-
219211
[15]: #parameters-4
220-
221212
[16]: #examples-4
222-
223213
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
224-
225214
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
226-
227215
[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
228-
229216
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
230-
231217
[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
232-
233218
[22]: https://developer.mozilla.org/docs/Web/API/Comment/Comment
234-
235219
[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