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 <anna@addaleax.net>
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
This commit is contained in:
Jesse McCarthy 2016-05-10 18:40:31 -04:00 committed by Robert Jefe Lindstaedt
parent 9cac8c894e
commit c1ffb9ff9b
3 changed files with 41 additions and 19 deletions

View File

@ -61,7 +61,14 @@ testData.forEach(function(item) {
fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) {
assert.ifError(err); 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) { common.mustCall(function(err, output) {
assert.ifError(err); assert.ifError(err);
@ -69,6 +76,7 @@ testData.forEach(function(item) {
// Assert that the input stripped of all whitespace contains the // Assert that the input stripped of all whitespace contains the
// expected list // expected list
assert.notEqual(actual.indexOf(expected), -1); assert.notEqual(actual.indexOf(expected), -1);
})); })
);
})); }));
}); });

View File

@ -48,11 +48,19 @@ function next(er, input) {
break; break;
case 'html': case 'html':
require('./html.js')(input, inputFile, template, nodeVersion, require('./html.js')(
{
input: input,
filename: inputFile,
template: template,
nodeVersion: nodeVersion,
},
function(er, html) { function(er, html) {
if (er) throw er; if (er) throw er;
console.log(html); console.log(html);
}); }
);
break; break;
default: default:

View File

@ -30,12 +30,12 @@ var gtocPath = path.resolve(path.join(
var gtocLoading = null; var gtocLoading = null;
var gtocData = null; var gtocData = null;
function toHTML(input, filename, template, nodeVersion, cb) { /**
if (typeof nodeVersion === 'function') { * opts: input, filename, template, nodeVersion.
cb = nodeVersion; */
nodeVersion = null; function toHTML(opts, cb) {
} var template = opts.template;
nodeVersion = nodeVersion || process.version; var nodeVersion = opts.nodeVersion || process.version;
if (gtocData) { if (gtocData) {
return onGtocLoaded(); return onGtocLoaded();
@ -57,10 +57,15 @@ function toHTML(input, filename, template, nodeVersion, cb) {
} }
function onGtocLoaded() { function onGtocLoaded() {
var lexed = marked.lexer(input); var lexed = marked.lexer(opts.input);
fs.readFile(template, 'utf8', function(er, template) { fs.readFile(template, 'utf8', function(er, template) {
if (er) return cb(er); 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, '-'); .replace(/-+/g, '-');
} }
function render(lexed, filename, template, nodeVersion, cb) { /**
if (typeof nodeVersion === 'function') { * opts: lexed, filename, template, nodeVersion.
cb = nodeVersion; */
nodeVersion = null; function render(opts, cb) {
} var lexed = opts.lexed;
var filename = opts.filename;
nodeVersion = nodeVersion || process.version; var template = opts.template;
var nodeVersion = opts.nodeVersion || process.version;
// get the section // get the section
var section = getSection(lexed); var section = getSection(lexed);