From f9f85a006f58f9846c18edb37ca110ffd2862e3f Mon Sep 17 00:00:00 2001 From: Jesse McCarthy Date: Tue, 10 May 2016 18:40:31 -0400 Subject: [PATCH] tools: restore change of signatures to opts hashes These signatures were originally converted to opts hashes in #3888. That change was misinterpreted as the intrinsic cause of a test failure and reverted in #6680. PR-URL: https://github.com/nodejs/node/pull/6690 Reviewed-By: Anna Henningsen Reviewed-By: Robert Jefe Lindstaedt --- test/doctool/test-doctool-html.js | 12 +++++++++-- tools/doc/generate.js | 12 +++++++++-- tools/doc/html.js | 36 ++++++++++++++++++------------- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index a8476b7234c9fa..8e16403901a00a 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -61,7 +61,14 @@ testData.forEach(function(item) { fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { assert.ifError(err); - html(input, 'foo', 'doc/template.html', + html( + { + input: input, + filename: 'foo', + template: 'doc/template.html', + nodeVersion: process.version, + }, + common.mustCall(function(err, output) { assert.ifError(err); @@ -69,6 +76,7 @@ testData.forEach(function(item) { // Assert that the input stripped of all whitespace contains the // expected list assert.notEqual(actual.indexOf(expected), -1); - })); + }) + ); })); }); diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 7df987e1cf78f9..077e740432c837 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -48,11 +48,19 @@ function next(er, input) { break; case 'html': - require('./html.js')(input, inputFile, template, nodeVersion, + require('./html.js')( + { + input: input, + filename: inputFile, + template: template, + nodeVersion: nodeVersion, + }, + function(er, html) { if (er) throw er; console.log(html); - }); + } + ); break; default: diff --git a/tools/doc/html.js b/tools/doc/html.js index ef7d78d5b70ab3..de63aefa43b510 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -30,12 +30,12 @@ var gtocPath = path.resolve(path.join( var gtocLoading = null; var gtocData = null; -function toHTML(input, filename, template, nodeVersion, cb) { - if (typeof nodeVersion === 'function') { - cb = nodeVersion; - nodeVersion = null; - } - nodeVersion = nodeVersion || process.version; +/** + * opts: input, filename, template, nodeVersion. + */ +function toHTML(opts, cb) { + var template = opts.template; + var nodeVersion = opts.nodeVersion || process.version; if (gtocData) { return onGtocLoaded(); @@ -57,10 +57,15 @@ function toHTML(input, filename, template, nodeVersion, cb) { } function onGtocLoaded() { - var lexed = marked.lexer(input); + var lexed = marked.lexer(opts.input); fs.readFile(template, 'utf8', function(er, template) { if (er) return cb(er); - render(lexed, filename, template, nodeVersion, cb); + render({ + lexed: lexed, + filename: opts.filename, + template: template, + nodeVersion: nodeVersion, + }, cb); }); } } @@ -87,13 +92,14 @@ function toID(filename) { .replace(/-+/g, '-'); } -function render(lexed, filename, template, nodeVersion, cb) { - if (typeof nodeVersion === 'function') { - cb = nodeVersion; - nodeVersion = null; - } - - nodeVersion = nodeVersion || process.version; +/** + * opts: lexed, filename, template, nodeVersion. + */ +function render(opts, cb) { + var lexed = opts.lexed; + var filename = opts.filename; + var template = opts.template; + var nodeVersion = opts.nodeVersion || process.version; // get the section var section = getSection(lexed);