tools: fix regression in doctool
101dd1e introduced a regression in the doctool. This commit reverts the changes that were made to the function signature of the various doctool functions while maintaining support for passing in specific node versions. Refs: https://github.com/nodejs/node/commit/101dd1e PR-URL: https://github.com/nodejs/node/pull/6680 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com>
This commit is contained in:
parent
0912b88320
commit
572e28efa2
@ -24,6 +24,8 @@ args.forEach(function(arg) {
|
||||
}
|
||||
});
|
||||
|
||||
nodeVersion = nodeVersion || process.version;
|
||||
|
||||
if (!inputFile) {
|
||||
throw new Error('No input file specified');
|
||||
}
|
||||
@ -46,15 +48,11 @@ function next(er, input) {
|
||||
break;
|
||||
|
||||
case 'html':
|
||||
require('./html.js')({
|
||||
input: input,
|
||||
filename: inputFile,
|
||||
template: template,
|
||||
nodeVersion: nodeVersion,
|
||||
}, function(er, html) {
|
||||
if (er) throw er;
|
||||
console.log(html);
|
||||
});
|
||||
require('./html.js')(input, inputFile, template, nodeVersion,
|
||||
function(er, html) {
|
||||
if (er) throw er;
|
||||
console.log(html);
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -30,11 +30,12 @@ var gtocPath = path.resolve(path.join(
|
||||
var gtocLoading = null;
|
||||
var gtocData = null;
|
||||
|
||||
/**
|
||||
* opts: input, filename, template, nodeVersion.
|
||||
*/
|
||||
function toHTML(opts, cb) {
|
||||
var template = opts.template;
|
||||
function toHTML(input, filename, template, nodeVersion, cb) {
|
||||
if (typeof nodeVersion === 'function') {
|
||||
cb = nodeVersion;
|
||||
nodeVersion = null;
|
||||
}
|
||||
nodeVersion = nodeVersion || process.version;
|
||||
|
||||
if (gtocData) {
|
||||
return onGtocLoaded();
|
||||
@ -56,15 +57,10 @@ function toHTML(opts, cb) {
|
||||
}
|
||||
|
||||
function onGtocLoaded() {
|
||||
var lexed = marked.lexer(opts.input);
|
||||
var lexed = marked.lexer(input);
|
||||
fs.readFile(template, 'utf8', function(er, template) {
|
||||
if (er) return cb(er);
|
||||
render({
|
||||
lexed: lexed,
|
||||
filename: opts.filename,
|
||||
template: template,
|
||||
nodeVersion: opts.nodeVersion,
|
||||
}, cb);
|
||||
render(lexed, filename, template, nodeVersion, cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -91,13 +87,13 @@ function toID(filename) {
|
||||
.replace(/-+/g, '-');
|
||||
}
|
||||
|
||||
/**
|
||||
* opts: lexed, filename, template, nodeVersion.
|
||||
*/
|
||||
function render(opts, cb) {
|
||||
var lexed = opts.lexed;
|
||||
var filename = opts.filename;
|
||||
var template = opts.template;
|
||||
function render(lexed, filename, template, nodeVersion, cb) {
|
||||
if (typeof nodeVersion === 'function') {
|
||||
cb = nodeVersion;
|
||||
nodeVersion = null;
|
||||
}
|
||||
|
||||
nodeVersion = nodeVersion || process.version;
|
||||
|
||||
// get the section
|
||||
var section = getSection(lexed);
|
||||
@ -117,7 +113,7 @@ function render(opts, cb) {
|
||||
template = template.replace(/__ID__/g, id);
|
||||
template = template.replace(/__FILENAME__/g, filename);
|
||||
template = template.replace(/__SECTION__/g, section);
|
||||
template = template.replace(/__VERSION__/g, opts.nodeVersion);
|
||||
template = template.replace(/__VERSION__/g, nodeVersion);
|
||||
template = template.replace(/__TOC__/g, toc);
|
||||
template = template.replace(
|
||||
/__GTOC__/g,
|
||||
|
Loading…
x
Reference in New Issue
Block a user