summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2017-11-18 21:04:05 +0100
committerTobias Nießen <tniessen@tnie.de>2017-11-21 10:07:05 +0100
commit2ba93f6ed7c96684ed7aeaa32db59ae8e5885f03 (patch)
tree4a9640c8ca50e479fe0fb2f7b251501dff283b4b /tools
parente515a0eced1d3d9a91d760fd8e538e0e7d3fbd04 (diff)
downloadandroid-node-v8-2ba93f6ed7c96684ed7aeaa32db59ae8e5885f03.tar.gz
android-node-v8-2ba93f6ed7c96684ed7aeaa32db59ae8e5885f03.tar.bz2
android-node-v8-2ba93f6ed7c96684ed7aeaa32db59ae8e5885f03.zip
tools: make doc tool a bit more readable
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'tools')
-rw-r--r--tools/doc/generate.js31
-rw-r--r--tools/doc/html.js4
2 files changed, 12 insertions, 23 deletions
diff --git a/tools/doc/generate.js b/tools/doc/generate.js
index 906aa96219..f369427a8a 100644
--- a/tools/doc/generate.js
+++ b/tools/doc/generate.js
@@ -30,13 +30,13 @@ const fs = require('fs');
const args = process.argv.slice(2);
let format = 'json';
let template = null;
-let inputFile = null;
+let filename = null;
let nodeVersion = null;
let analytics = null;
args.forEach(function(arg) {
if (!arg.startsWith('--')) {
- inputFile = arg;
+ filename = arg;
} else if (arg.startsWith('--format=')) {
format = arg.replace(/^--format=/, '');
} else if (arg.startsWith('--template=')) {
@@ -50,41 +50,32 @@ args.forEach(function(arg) {
nodeVersion = nodeVersion || process.version;
-if (!inputFile) {
+if (!filename) {
throw new Error('No input file specified');
}
-fs.readFile(inputFile, 'utf8', function(er, input) {
+fs.readFile(filename, 'utf8', (er, input) => {
if (er) throw er;
// process the input for @include lines
- processIncludes(inputFile, input, next);
+ processIncludes(filename, input, next);
});
function next(er, input) {
if (er) throw er;
switch (format) {
case 'json':
- require('./json.js')(input, inputFile, function(er, obj) {
+ require('./json.js')(input, filename, (er, obj) => {
console.log(JSON.stringify(obj, null, 2));
if (er) throw er;
});
break;
case 'html':
- require('./html.js')(
- {
- input: input,
- filename: inputFile,
- template: template,
- nodeVersion: nodeVersion,
- analytics: analytics,
- },
-
- function(er, html) {
- if (er) throw er;
- console.log(html);
- }
- );
+ require('./html')({ input, filename, template, nodeVersion, analytics },
+ (err, html) => {
+ if (err) throw err;
+ console.log(html);
+ });
break;
default:
diff --git a/tools/doc/html.js b/tools/doc/html.js
index e251925995..1c44c5f7d3 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -125,9 +125,7 @@ function toID(filename) {
* opts: lexed, filename, template, nodeVersion.
*/
function render(opts, cb) {
- var lexed = opts.lexed;
- var filename = opts.filename;
- var template = opts.template;
+ var { lexed, filename, template } = opts;
const nodeVersion = opts.nodeVersion || process.version;
// get the section