Skip to content

Commit 2b36cd5

Browse files
committed
tools: make doc tool a bit more readable
PR-URL: nodejs#17125 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5ef8f6d commit 2b36cd5

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

tools/doc/generate.js

+12-21
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const fs = require('fs');
99
const args = process.argv.slice(2);
1010
let format = 'json';
1111
let template = null;
12-
let inputFile = null;
12+
let filename = null;
1313
let nodeVersion = null;
1414
let analytics = null;
1515

1616
args.forEach(function(arg) {
1717
if (!arg.startsWith('--')) {
18-
inputFile = arg;
18+
filename = arg;
1919
} else if (arg.startsWith('--format=')) {
2020
format = arg.replace(/^--format=/, '');
2121
} else if (arg.startsWith('--template=')) {
@@ -29,42 +29,33 @@ args.forEach(function(arg) {
2929

3030
nodeVersion = nodeVersion || process.version;
3131

32-
if (!inputFile) {
32+
if (!filename) {
3333
throw new Error('No input file specified');
3434
}
3535

36-
console.error('Input file = %s', inputFile);
37-
fs.readFile(inputFile, 'utf8', function(er, input) {
36+
console.error('Input file = %s', filename);
37+
fs.readFile(filename, 'utf8', (er, input) => {
3838
if (er) throw er;
3939
// process the input for @include lines
40-
processIncludes(inputFile, input, next);
40+
processIncludes(filename, input, next);
4141
});
4242

4343
function next(er, input) {
4444
if (er) throw er;
4545
switch (format) {
4646
case 'json':
47-
require('./json.js')(input, inputFile, function(er, obj) {
47+
require('./json.js')(input, filename, (er, obj) => {
4848
console.log(JSON.stringify(obj, null, 2));
4949
if (er) throw er;
5050
});
5151
break;
5252

5353
case 'html':
54-
require('./html.js')(
55-
{
56-
input: input,
57-
filename: inputFile,
58-
template: template,
59-
nodeVersion: nodeVersion,
60-
analytics: analytics,
61-
},
62-
63-
function(er, html) {
64-
if (er) throw er;
65-
console.log(html);
66-
}
67-
);
54+
require('./html')({ input, filename, template, nodeVersion, analytics },
55+
(err, html) => {
56+
if (err) throw err;
57+
console.log(html);
58+
});
6859
break;
6960

7061
default:

tools/doc/html.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ function toID(filename) {
103103
* opts: lexed, filename, template, nodeVersion.
104104
*/
105105
function render(opts, cb) {
106-
var lexed = opts.lexed;
107-
var filename = opts.filename;
108-
var template = opts.template;
106+
var { lexed, filename, template } = opts;
109107
var nodeVersion = opts.nodeVersion || process.version;
110108

111109
// get the section

0 commit comments

Comments
 (0)