Skip to content

Commit

Permalink
fix(cli): Fix error reporting in the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Dec 29, 2016
1 parent dd9c03a commit 88c8f9a
Show file tree
Hide file tree
Showing 60 changed files with 13 additions and 4,592 deletions.
8 changes: 7 additions & 1 deletion bin/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ var argv = yargs
.command(commands.lint)
.command(commands.readme)
.fail(function (msg, error) {
throw error;
if (error) {
throw error;
} else {
yargs.showHelp('error');
console.error(msg);
return yargs.exit(1);
}
})
.version(function () {
return require('../package').version;
Expand Down
6 changes: 4 additions & 2 deletions lib/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ module.exports.builder = extend({},
* just a thin wrapper around this one.
*/
module.exports.handler = function build(argv, callback) {
console.log(argv);
argv._handled = true;
argv = sharedOptions.expandInputs(argv);
if (argv.f === 'html' && argv.o === 'stdout') {
throw new Error('The HTML output mode requires a destination directory set with -o');
}

var generator = documentation.build
.bind(null, argv.input, argv, onDocumented); function onDocumented(err, comments) { if (err) {
.bind(null, argv.input, argv, onDocumented);

function onDocumented(err, comments) {
if (err) {
if (typeof callback === 'function') {
return callback(err);
}
Expand Down
4 changes: 0 additions & 4 deletions test/fixture/auto_lang_hljs/multilanguage.output.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [multilanguage.input](#multilanguageinput)

## multilanguage.input

**Extends Foo, Bar**
Expand Down
47 changes: 0 additions & 47 deletions test/fixture/boolean-literal-type.output.md.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,6 @@
"type": "html",
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
},
{
"depth": 3,
"type": "heading",
"children": [
{
"type": "text",
"value": "Table of Contents"
}
],
"data": {
"id": "table-of-contents",
"htmlAttributes": {
"id": "table-of-contents"
},
"hProperties": {
"id": "table-of-contents"
}
}
},
{
"type": "list",
"ordered": false,
"children": [
{
"type": "listItem",
"loose": false,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "#f",
"children": [
{
"type": "text",
"value": "f"
}
]
}
]
}
]
}
]
},
{
"depth": 2,
"type": "heading",
Expand Down
7 changes: 0 additions & 7 deletions test/fixture/class.config.output.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [MyClass](#myclass)
- [getFoo](#getfoo)
- [getUndefined](#getundefined)
- [Hello](#hello)

## MyClass

This is my class, a demo thing.
Expand Down
97 changes: 0 additions & 97 deletions test/fixture/class.output.md.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,6 @@
"type": "html",
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
},
{
"depth": 3,
"type": "heading",
"children": [
{
"type": "text",
"value": "Table of Contents"
}
],
"data": {
"id": "table-of-contents",
"htmlAttributes": {
"id": "table-of-contents"
},
"hProperties": {
"id": "table-of-contents"
}
}
},
{
"type": "list",
"ordered": false,
"children": [
{
"type": "listItem",
"loose": false,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "#myclass",
"children": [
{
"type": "text",
"value": "MyClass"
}
]
}
]
},
{
"type": "list",
"ordered": false,
"children": [
{
"type": "listItem",
"loose": false,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "#getfoo",
"children": [
{
"type": "text",
"value": "getFoo"
}
]
}
]
}
]
},
{
"type": "listItem",
"loose": false,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "#getundefined",
"children": [
{
"type": "text",
"value": "getUndefined"
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"depth": 2,
"type": "heading",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,6 @@
"type": "html",
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
},
{
"depth": 3,
"type": "heading",
"children": [
{
"type": "text",
"value": "Table of Contents"
}
],
"data": {
"id": "table-of-contents",
"htmlAttributes": {
"id": "table-of-contents"
},
"hProperties": {
"id": "table-of-contents"
}
}
},
{
"type": "list",
"ordered": false,
"children": [
{
"type": "listItem",
"loose": false,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "#document-exported-export-default-objectinput",
"children": [
{
"type": "text",
"value": "document-exported-export-default-object.input"
}
]
}
]
}
]
},
{
"type": "listItem",
"loose": false,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "#x",
"children": [
{
"type": "text",
"value": "x"
}
]
}
]
}
]
}
]
},
{
"depth": 2,
"type": "heading",
Expand Down
47 changes: 0 additions & 47 deletions test/fixture/document-exported-export-default-value.output.md.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,6 @@
"type": "html",
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
},
{
"depth": 3,
"type": "heading",
"children": [
{
"type": "text",
"value": "Table of Contents"
}
],
"data": {
"id": "table-of-contents",
"htmlAttributes": {
"id": "table-of-contents"
},
"hProperties": {
"id": "table-of-contents"
}
}
},
{
"type": "list",
"ordered": false,
"children": [
{
"type": "listItem",
"loose": false,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "#document-exported-export-default-valueinput",
"children": [
{
"type": "text",
"value": "document-exported-export-default-value.input"
}
]
}
]
}
]
}
]
},
{
"depth": 2,
"type": "heading",
Expand Down
Loading

0 comments on commit 88c8f9a

Please sign in to comment.