documentation/bin/documentation.js
Hugo Josefson 7e0127819a Fix args regression: readme --shallow --format (Invalid second argument) (#968)
* Add shared_options to readme command.

This makes --shallow and --format work again.

* Update yarn.lock based on package.json.

* Move readme example to where it works,

remove superfluous usage string.

yargs@>=7 throws exceptions on incorrectly structured builder objects.

* Update expected readme test fixture.

* Update bin-readme snapshot.

* s/_.assign/Object.assign/g thanks to node@>=4.

* Update yarn.lock based on package.json (lint-staged@6)

* Override flow error message.
2017-12-10 15:04:32 +03:00

65 lines
1.5 KiB
JavaScript
Executable File

#!/usr/bin/env node
/* eslint no-console: 0 */
var yargs = require('yargs');
var commands = require('../lib/commands');
var 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;
if (argv.private) {
console.error(
'--private is deprecated, please use the --access (or -a) option instead'
);
console.error('for example: -a public -a private -a protected -a undefined');
}
if (!argv._handled) {
yargs.showHelp('error');
process.exit(1);
}