1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 | const yargs = require('yargs');
|
6 | const commands = require('../src/commands');
|
7 |
|
8 | const argv = yargs
|
9 | .strict()
|
10 | .command(commands.serve)
|
11 | .command(commands.build)
|
12 | .command(commands.lint)
|
13 | .command(commands.readme)
|
14 | .fail(function(msg, error) {
|
15 | if (error) {
|
16 | throw error;
|
17 | } else {
|
18 | yargs.showHelp('error');
|
19 | console.error(msg);
|
20 | return yargs.exit(1);
|
21 | }
|
22 | })
|
23 | .example('documentation build foo.js -f md > API.md')
|
24 | .example('documentation readme index.js -s "API Docs" --github')
|
25 | .version()
|
26 | .usage(
|
27 | `Usage:
|
28 |
|
29 | # generate markdown docs for index.js and files it references
|
30 | $0 build index.js -f md
|
31 |
|
32 | # generate html docs for all files in src
|
33 | $0 build src/** -f html -o docs
|
34 |
|
35 | # document index.js, ignoring any files it requires or imports
|
36 | $0 build index.js -f md --shallow
|
37 |
|
38 | # build, serve, and live-update html docs for app.js
|
39 | $0 serve app.js
|
40 |
|
41 | # validate JSDoc syntax in util.js
|
42 | $0 lint util.js
|
43 |
|
44 | # update the API section of README.md with docs from index.js
|
45 | $0 readme index.js --section=API
|
46 |
|
47 | # build docs for all values exported by index.js
|
48 | $0 build --document-exported index.js
|
49 | `
|
50 | )
|
51 | .recommendCommands()
|
52 | .help().argv;
|
53 |
|
54 | if (argv.private) {
|
55 | console.error(
|
56 | '--private is deprecated, please use the --access (or -a) option instead'
|
57 | );
|
58 | console.error('for example: -a public -a private -a protected -a undefined');
|
59 | }
|
60 |
|
61 | if (!argv._handled) {
|
62 | yargs.showHelp('error');
|
63 | process.exit(1);
|
64 | }
|