Skip to content

Commit 88c8f9a

Browse files
committed
fix(cli): Fix error reporting in the CLI
1 parent dd9c03a commit 88c8f9a

File tree

60 files changed

+13
-4592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+13
-4592
lines changed

bin/documentation.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ var argv = yargs
1313
.command(commands.lint)
1414
.command(commands.readme)
1515
.fail(function (msg, error) {
16-
throw error;
16+
if (error) {
17+
throw error;
18+
} else {
19+
yargs.showHelp('error');
20+
console.error(msg);
21+
return yargs.exit(1);
22+
}
1723
})
1824
.version(function () {
1925
return require('../package').version;

lib/commands/build.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ module.exports.builder = extend({},
4949
* just a thin wrapper around this one.
5050
*/
5151
module.exports.handler = function build(argv, callback) {
52-
console.log(argv);
5352
argv._handled = true;
5453
argv = sharedOptions.expandInputs(argv);
5554
if (argv.f === 'html' && argv.o === 'stdout') {
5655
throw new Error('The HTML output mode requires a destination directory set with -o');
5756
}
5857

5958
var generator = documentation.build
60-
.bind(null, argv.input, argv, onDocumented); function onDocumented(err, comments) { if (err) {
59+
.bind(null, argv.input, argv, onDocumented);
60+
61+
function onDocumented(err, comments) {
62+
if (err) {
6163
if (typeof callback === 'function') {
6264
return callback(err);
6365
}

test/fixture/auto_lang_hljs/multilanguage.output.md

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
22

3-
### Table of Contents
4-
5-
- [multilanguage.input](#multilanguageinput)
6-
73
## multilanguage.input
84

95
**Extends Foo, Bar**

test/fixture/boolean-literal-type.output.md.json

-47
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,6 @@
55
"type": "html",
66
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
77
},
8-
{
9-
"depth": 3,
10-
"type": "heading",
11-
"children": [
12-
{
13-
"type": "text",
14-
"value": "Table of Contents"
15-
}
16-
],
17-
"data": {
18-
"id": "table-of-contents",
19-
"htmlAttributes": {
20-
"id": "table-of-contents"
21-
},
22-
"hProperties": {
23-
"id": "table-of-contents"
24-
}
25-
}
26-
},
27-
{
28-
"type": "list",
29-
"ordered": false,
30-
"children": [
31-
{
32-
"type": "listItem",
33-
"loose": false,
34-
"children": [
35-
{
36-
"type": "paragraph",
37-
"children": [
38-
{
39-
"type": "link",
40-
"title": null,
41-
"url": "#f",
42-
"children": [
43-
{
44-
"type": "text",
45-
"value": "f"
46-
}
47-
]
48-
}
49-
]
50-
}
51-
]
52-
}
53-
]
54-
},
558
{
569
"depth": 2,
5710
"type": "heading",

test/fixture/class.config.output.md

-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
22

3-
### Table of Contents
4-
5-
- [MyClass](#myclass)
6-
- [getFoo](#getfoo)
7-
- [getUndefined](#getundefined)
8-
- [Hello](#hello)
9-
103
## MyClass
114

125
This is my class, a demo thing.

test/fixture/class.output.md.json

-97
Original file line numberDiff line numberDiff line change
@@ -5,103 +5,6 @@
55
"type": "html",
66
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
77
},
8-
{
9-
"depth": 3,
10-
"type": "heading",
11-
"children": [
12-
{
13-
"type": "text",
14-
"value": "Table of Contents"
15-
}
16-
],
17-
"data": {
18-
"id": "table-of-contents",
19-
"htmlAttributes": {
20-
"id": "table-of-contents"
21-
},
22-
"hProperties": {
23-
"id": "table-of-contents"
24-
}
25-
}
26-
},
27-
{
28-
"type": "list",
29-
"ordered": false,
30-
"children": [
31-
{
32-
"type": "listItem",
33-
"loose": false,
34-
"children": [
35-
{
36-
"type": "paragraph",
37-
"children": [
38-
{
39-
"type": "link",
40-
"title": null,
41-
"url": "#myclass",
42-
"children": [
43-
{
44-
"type": "text",
45-
"value": "MyClass"
46-
}
47-
]
48-
}
49-
]
50-
},
51-
{
52-
"type": "list",
53-
"ordered": false,
54-
"children": [
55-
{
56-
"type": "listItem",
57-
"loose": false,
58-
"children": [
59-
{
60-
"type": "paragraph",
61-
"children": [
62-
{
63-
"type": "link",
64-
"title": null,
65-
"url": "#getfoo",
66-
"children": [
67-
{
68-
"type": "text",
69-
"value": "getFoo"
70-
}
71-
]
72-
}
73-
]
74-
}
75-
]
76-
},
77-
{
78-
"type": "listItem",
79-
"loose": false,
80-
"children": [
81-
{
82-
"type": "paragraph",
83-
"children": [
84-
{
85-
"type": "link",
86-
"title": null,
87-
"url": "#getundefined",
88-
"children": [
89-
{
90-
"type": "text",
91-
"value": "getUndefined"
92-
}
93-
]
94-
}
95-
]
96-
}
97-
]
98-
}
99-
]
100-
}
101-
]
102-
}
103-
]
104-
},
1058
{
1069
"depth": 2,
10710
"type": "heading",

test/fixture/document-exported-export-default-object.output.md.json

-69
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,6 @@
55
"type": "html",
66
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
77
},
8-
{
9-
"depth": 3,
10-
"type": "heading",
11-
"children": [
12-
{
13-
"type": "text",
14-
"value": "Table of Contents"
15-
}
16-
],
17-
"data": {
18-
"id": "table-of-contents",
19-
"htmlAttributes": {
20-
"id": "table-of-contents"
21-
},
22-
"hProperties": {
23-
"id": "table-of-contents"
24-
}
25-
}
26-
},
27-
{
28-
"type": "list",
29-
"ordered": false,
30-
"children": [
31-
{
32-
"type": "listItem",
33-
"loose": false,
34-
"children": [
35-
{
36-
"type": "paragraph",
37-
"children": [
38-
{
39-
"type": "link",
40-
"title": null,
41-
"url": "#document-exported-export-default-objectinput",
42-
"children": [
43-
{
44-
"type": "text",
45-
"value": "document-exported-export-default-object.input"
46-
}
47-
]
48-
}
49-
]
50-
}
51-
]
52-
},
53-
{
54-
"type": "listItem",
55-
"loose": false,
56-
"children": [
57-
{
58-
"type": "paragraph",
59-
"children": [
60-
{
61-
"type": "link",
62-
"title": null,
63-
"url": "#x",
64-
"children": [
65-
{
66-
"type": "text",
67-
"value": "x"
68-
}
69-
]
70-
}
71-
]
72-
}
73-
]
74-
}
75-
]
76-
},
778
{
789
"depth": 2,
7910
"type": "heading",

test/fixture/document-exported-export-default-value.output.md.json

-47
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,6 @@
55
"type": "html",
66
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
77
},
8-
{
9-
"depth": 3,
10-
"type": "heading",
11-
"children": [
12-
{
13-
"type": "text",
14-
"value": "Table of Contents"
15-
}
16-
],
17-
"data": {
18-
"id": "table-of-contents",
19-
"htmlAttributes": {
20-
"id": "table-of-contents"
21-
},
22-
"hProperties": {
23-
"id": "table-of-contents"
24-
}
25-
}
26-
},
27-
{
28-
"type": "list",
29-
"ordered": false,
30-
"children": [
31-
{
32-
"type": "listItem",
33-
"loose": false,
34-
"children": [
35-
{
36-
"type": "paragraph",
37-
"children": [
38-
{
39-
"type": "link",
40-
"title": null,
41-
"url": "#document-exported-export-default-valueinput",
42-
"children": [
43-
{
44-
"type": "text",
45-
"value": "document-exported-export-default-value.input"
46-
}
47-
]
48-
}
49-
]
50-
}
51-
]
52-
}
53-
]
54-
},
558
{
569
"depth": 2,
5710
"type": "heading",

0 commit comments

Comments
 (0)