Skip to content

Commit

Permalink
feat: remove all deps and use one bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-redFox committed Oct 21, 2021
1 parent e4d8a7c commit df3d4f8
Show file tree
Hide file tree
Showing 9 changed files with 1,110 additions and 513 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
command: npm ci
- run:
name: Test
command: npm run test-ci
command: npm run build && npm run test-ci
- save_cache:
name: Save npm Package Cache
key: npm-packages-{{ .Branch }}-{{ checksum "package-lock.json" }}
Expand Down
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
49 changes: 1 addition & 48 deletions bin/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,7 @@

/* eslint no-console: 0 */

import yargs from 'yargs';
import commands from '../src/commands/index.js';

const argv = yargs
.strict()
.command(commands.serve)
.command(commands.build)
.command(commands.lint)
.command(commands.readme)
.fail(function (msg, error) {
if (error) {
throw error;
} else {
yargs.showHelp('error');
console.error(msg);
return yargs.exit(1);
}
})
.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';

if (argv.private) {
console.error(
Expand Down
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,10 +120,10 @@ 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

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

documentation.build(['index.js'])
documentation
.build(['index.js'])
.then(documentation.formats.html)
.then(output => {
streamArray(output).pipe(vfs.dest('./output-directory'));
Expand All @@ -145,16 +149,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 @@ -170,66 +175,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/
50 changes: 50 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* eslint no-console: 0 */

import yargs from 'yargs';
import commands from './src/commands/index.js';

export default yargs
.strict()
.command(commands.serve)
.command(commands.build)
.command(commands.lint)
.command(commands.readme)
.fail(function (msg, error) {
if (error) {
throw error;
} else {
yargs.showHelp('error');
console.error(msg);
return yargs.exit(1);
}
})
.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;

0 comments on commit df3d4f8

Please sign in to comment.