Browse Source

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>
v6.x
Jesse McCarthy 9 years ago
committed by Rod Vagg
parent
commit
bf3afce668
  1. 12
      test/doctool/test-doctool-html.js
  2. 12
      tools/doc/generate.js
  3. 36
      tools/doc/html.js

12
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);
}));
})
);
}));
});

12
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:

36
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);

Loading…
Cancel
Save