Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove all deps and use one bundle #1409

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ src/default_theme/*
coverage/*
lib/*
declarations/*
documentation.js
bin/*
1 change: 1 addition & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm run test-ci
40 changes: 1 addition & 39 deletions bin/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,4 @@

/* eslint no-console: 0 */

import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import commands from '../src/commands/index.js';

yargs(hideBin(process.argv))
.strict()
.command(commands.build)
.command(commands.lint)
.command(commands.readme)
.example('documentation build foo.js -f md > API.md')
.example('documentation readme index.js -s "API Docs" --github')
.version()
.usage(
`Usage:

# generate markdown docs for index.js and files it references
$0 build index.js -f md

# generate html docs for all files in src
$0 build src/** -f html -o docs

# document index.js, ignoring any files it requires or imports
$0 build index.js -f md --shallow

# build, serve, and live-update html docs for app.js
$0 serve app.js

# validate JSDoc syntax in util.js
$0 lint util.js

# update the API section of README.md with docs from index.js
$0 readme index.js --section=API

# build docs for all values exported by index.js
$0 build --document-exported index.js
`
)
.recommendCommands()
.help().argv;
import argv from '../documentation.js';
168 changes: 76 additions & 92 deletions docs/NODE_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

### Table of Contents

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

## lint

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

### Parameters

* `indexes` **([Array][17]<[string][18]> | [string][18])** files to process
* `args` **[Object][19]** args

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

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

### Examples

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

### Parameters

* `indexes` **([Array][17]<[string][18]> | [string][18])** files to process
* `args` **[Object][19]** args

* `args.external` **[Array][17]<[string][18]>** a string regex / glob match pattern
that defines what external modules will be whitelisted and included in the
generated documentation.
* `args.shallow` **[boolean][20]** whether to avoid dependency parsing
even in JavaScript code. (optional, default `false`)
* `args.order` **[Array][17]<([string][18] | [Object][19])>** optional array that
defines sorting order of documentation (optional, default `[]`)
* `args.access` **[Array][17]<[string][18]>** an array of access levels
to output in documentation (optional, default `[]`)
* `args.hljs` **[Object][19]?** hljs optional args

* `args.hljs.highlightAuto` **[boolean][20]** hljs automatically detect language (optional, default `false`)
* `args.hljs.languages` **[Array][17]?** languages for hljs to choose from
* `args.inferPrivate` **[string][18]?** a valid regular expression string
to infer whether a code element should be private, given its naming structure.
For instance, you can specify `inferPrivate: '^_'` to automatically treat
methods named like `_myMethod` as private.
* `args.extension` **([string][18] | [Array][17]<[string][18]>)?** treat additional file extensions
as JavaScript, extending the default set of `js`, `es6`, and `jsx`.
- `indexes` **([Array][17]<[string][18]> | [string][18])** files to process
- `args` **[Object][19]** args

- `args.external` **[Array][17]<[string][18]>** a string regex / glob match pattern
that defines what external modules will be whitelisted and included in the
generated documentation.
- `args.shallow` **[boolean][20]** whether to avoid dependency parsing
even in JavaScript code.&#x20;(optional, default `false`)
- `args.order` **[Array][17]<([string][18] | [Object][19])>** optional array that
defines sorting order of documentation&#x20;(optional, default `[]`)
- `args.access` **[Array][17]<[string][18]>** an array of access levels
to output in documentation&#x20;(optional, default `[]`)
- `args.hljs` **[Object][19]?** hljs optional args

- `args.hljs.highlightAuto` **[boolean][20]** hljs automatically detect language&#x20;(optional, default `false`)
- `args.hljs.languages` **[Array][17]?** languages for hljs to choose from

- `args.inferPrivate` **[string][18]?** a valid regular expression string
to infer whether a code element should be private, given its naming structure.
For instance, you can specify `inferPrivate: '^_'` to automatically treat
methods named like `_myMethod` as private.
- `args.extension` **([string][18] | [Array][17]<[string][18]>)?** treat additional file extensions
as JavaScript, extending the default set of `js`, `es6`, and `jsx`.

### Examples

```javascript
var documentation = require('documentation');

documentation.build(['index.js'], {
// only output comments with an explicit @public tag
access: ['public']
}).then(res => {
// res is an array of parsed comments with inferred properties
// and more: everything you need to build documentation or
// any other kind of code data.
});
documentation
.build(['index.js'], {
// only output comments with an explicit @public tag
access: ['public']
})
.then(res => {
// res is an array of parsed comments with inferred properties
// and more: everything you need to build documentation or
// any other kind of code data.
});
```

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

### Parameters

* `comments` **[Array][17]<[Comment][22]>** parsed comments
* `config` **[Object][19]** Options that can customize the output
- `comments` **[Array][17]<[Comment][22]>** parsed comments
- `config` **[Object][19]** Options that can customize the output

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

### Examples

```javascript
var documentation = require('documentation');

documentation.build(['index.js'])
documentation
.build(['index.js'])
.then(documentation.formats.html);
```

Expand All @@ -140,16 +144,17 @@ Formats documentation as

### Parameters

* `comments` **[Array][17]<[Object][19]>** parsed comments
* `args` **[Object][19]** Options that can customize the output
- `comments` **[Array][17]<[Object][19]>** parsed comments
- `args` **[Object][19]** Options that can customize the output

### Examples

```javascript
var documentation = require('documentation');
var fs = require('fs');

documentation.build(['index.js'])
documentation
.build(['index.js'])
.then(documentation.formats.md)
.then(output => {
// output is a string of Markdown data
Expand All @@ -165,66 +170,45 @@ Formats documentation as a JSON string.

### Parameters

* `comments` **[Array][17]<[Comment][22]>** parsed comments
- `comments` **[Array][17]<[Comment][22]>** parsed comments

### Examples

```javascript
var documentation = require('documentation');
var fs = require('fs');

documentation.build(['index.js'])
documentation
.build(['index.js'])
.then(documentation.formats.json)
.then(output => {
// output is a string of JSON data
fs.writeFileSync('./output.json', output);
});
```

Returns **[Promise][21]<[string][18]>**
Returns **[Promise][21]<[string][18]>**&#x20;

[1]: #lint

[2]: #parameters

[3]: #examples

[4]: #build

[5]: #parameters-1

[6]: #examples-1

[7]: #formats

[8]: #formatshtml

[9]: #parameters-2

[10]: #examples-2

[11]: #formatsmarkdown

[12]: #parameters-3

[13]: #examples-3

[14]: #formatsjson

[15]: #parameters-4

[16]: #examples-4

[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise

[22]: https://developer.mozilla.org/docs/Web/API/Comment/Comment

[23]: https://daringfireball.net/projects/markdown/
38 changes: 38 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint no-console: 0 */

import yargs from 'yargs';
import commands from './src/commands/index.js';
import { hideBin } from 'yargs/helpers';

export default yargs(hideBin(process.argv))
.strict()
.command(commands.build)
.command(commands.lint)
.command(commands.readme)
.example('documentation build foo.js -f md > API.md')
.example('documentation readme index.js -s "API Docs" --github')
.version()
.usage(
`Usage:

# generate markdown docs for index.js and files it references
$0 build index.js -f md

# generate html docs for all files in src
$0 build src/** -f html -o docs

# document index.js, ignoring any files it requires or imports
$0 build index.js -f md --shallow

# validate JSDoc syntax in util.js
$0 lint util.js

# update the API section of README.md with docs from index.js
$0 readme index.js --section=API

# build docs for all values exported by index.js
$0 build --document-exported index.js
`
)
.recommendCommands()
.help().argv;
Loading