Skip to content

Commit

Permalink
tools: restore change of signatures to opts hashes
Browse files Browse the repository at this point in the history
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: #6690
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
  • Loading branch information
jmm authored and rvagg committed Jun 2, 2016
1 parent 21e3135 commit bf3afce
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
12 changes: 10 additions & 2 deletions test/doctool/test-doctool-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,22 @@ 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);

const actual = output.replace(/\s/g, '');
// Assert that the input stripped of all whitespace contains the
// expected list
assert.notEqual(actual.indexOf(expected), -1);
}));
})
);
}));
});
12 changes: 10 additions & 2 deletions tools/doc/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 21 additions & 15 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
});
}
}
Expand All @@ -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);
Expand Down

0 comments on commit bf3afce

Please sign in to comment.