Skip to content

Commit c5cd4f0

Browse files
tniessengibfahn
authored andcommitted
tools: make doc tool a bit more readable
PR-URL: #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 13b97e7 commit c5cd4f0

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

tools/doc/generate.js

+11-20
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ const fs = require('fs');
3030
const args = process.argv.slice(2);
3131
let format = 'json';
3232
let template = null;
33-
let inputFile = null;
33+
let filename = null;
3434
let nodeVersion = null;
3535
let analytics = null;
3636

3737
args.forEach(function(arg) {
3838
if (!arg.startsWith('--')) {
39-
inputFile = arg;
39+
filename = arg;
4040
} else if (arg.startsWith('--format=')) {
4141
format = arg.replace(/^--format=/, '');
4242
} else if (arg.startsWith('--template=')) {
@@ -50,41 +50,32 @@ args.forEach(function(arg) {
5050

5151
nodeVersion = nodeVersion || process.version;
5252

53-
if (!inputFile) {
53+
if (!filename) {
5454
throw new Error('No input file specified');
5555
}
5656

57-
fs.readFile(inputFile, 'utf8', function(er, input) {
57+
fs.readFile(filename, 'utf8', (er, input) => {
5858
if (er) throw er;
5959
// process the input for @include lines
60-
processIncludes(inputFile, input, next);
60+
processIncludes(filename, input, next);
6161
});
6262

6363
function next(er, input) {
6464
if (er) throw er;
6565
switch (format) {
6666
case 'json':
67-
require('./json.js')(input, inputFile, function(er, obj) {
67+
require('./json.js')(input, filename, (er, obj) => {
6868
console.log(JSON.stringify(obj, null, 2));
6969
if (er) throw er;
7070
});
7171
break;
7272

7373
case 'html':
74-
require('./html.js')(
75-
{
76-
input: input,
77-
filename: inputFile,
78-
template: template,
79-
nodeVersion: nodeVersion,
80-
analytics: analytics,
81-
},
82-
83-
function(er, html) {
84-
if (er) throw er;
85-
console.log(html);
86-
}
87-
);
74+
require('./html')({ input, filename, template, nodeVersion, analytics },
75+
(err, html) => {
76+
if (err) throw err;
77+
console.log(html);
78+
});
8879
break;
8980

9081
default:

tools/doc/html.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ function toID(filename) {
125125
* opts: lexed, filename, template, nodeVersion.
126126
*/
127127
function render(opts, cb) {
128-
var lexed = opts.lexed;
129-
var filename = opts.filename;
130-
var template = opts.template;
128+
var { lexed, filename, template } = opts;
131129
const nodeVersion = opts.nodeVersion || process.version;
132130

133131
// get the section

0 commit comments

Comments
 (0)