Skip to content

Commit efcbafa

Browse files
Myles Borinsevanlucas
Myles Borins
authored andcommitted
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: 101dd1e PR-URL: #6680 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Robert Lindstaedt <[email protected]>
1 parent 6032dc2 commit efcbafa

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

tools/doc/generate.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ args.forEach(function(arg) {
2424
}
2525
});
2626

27+
nodeVersion = nodeVersion || process.version;
28+
2729
if (!inputFile) {
2830
throw new Error('No input file specified');
2931
}
@@ -46,15 +48,11 @@ function next(er, input) {
4648
break;
4749

4850
case 'html':
49-
require('./html.js')({
50-
input: input,
51-
filename: inputFile,
52-
template: template,
53-
nodeVersion: nodeVersion,
54-
}, function(er, html) {
55-
if (er) throw er;
56-
console.log(html);
57-
});
51+
require('./html.js')(input, inputFile, template, nodeVersion,
52+
function(er, html) {
53+
if (er) throw er;
54+
console.log(html);
55+
});
5856
break;
5957

6058
default:

tools/doc/html.js

+16-20
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ var gtocPath = path.resolve(path.join(
3030
var gtocLoading = null;
3131
var gtocData = null;
3232

33-
/**
34-
* opts: input, filename, template, nodeVersion.
35-
*/
36-
function toHTML(opts, cb) {
37-
var template = opts.template;
33+
function toHTML(input, filename, template, nodeVersion, cb) {
34+
if (typeof nodeVersion === 'function') {
35+
cb = nodeVersion;
36+
nodeVersion = null;
37+
}
38+
nodeVersion = nodeVersion || process.version;
3839

3940
if (gtocData) {
4041
return onGtocLoaded();
@@ -56,15 +57,10 @@ function toHTML(opts, cb) {
5657
}
5758

5859
function onGtocLoaded() {
59-
var lexed = marked.lexer(opts.input);
60+
var lexed = marked.lexer(input);
6061
fs.readFile(template, 'utf8', function(er, template) {
6162
if (er) return cb(er);
62-
render({
63-
lexed: lexed,
64-
filename: opts.filename,
65-
template: template,
66-
nodeVersion: opts.nodeVersion,
67-
}, cb);
63+
render(lexed, filename, template, nodeVersion, cb);
6864
});
6965
}
7066
}
@@ -91,13 +87,13 @@ function toID(filename) {
9187
.replace(/-+/g, '-');
9288
}
9389

94-
/**
95-
* opts: lexed, filename, template, nodeVersion.
96-
*/
97-
function render(opts, cb) {
98-
var lexed = opts.lexed;
99-
var filename = opts.filename;
100-
var template = opts.template;
90+
function render(lexed, filename, template, nodeVersion, cb) {
91+
if (typeof nodeVersion === 'function') {
92+
cb = nodeVersion;
93+
nodeVersion = null;
94+
}
95+
96+
nodeVersion = nodeVersion || process.version;
10197

10298
// get the section
10399
var section = getSection(lexed);
@@ -117,7 +113,7 @@ function render(opts, cb) {
117113
template = template.replace(/__ID__/g, id);
118114
template = template.replace(/__FILENAME__/g, filename);
119115
template = template.replace(/__SECTION__/g, section);
120-
template = template.replace(/__VERSION__/g, opts.nodeVersion);
116+
template = template.replace(/__VERSION__/g, nodeVersion);
121117
template = template.replace(/__TOC__/g, toc);
122118
template = template.replace(
123119
/__GTOC__/g,

0 commit comments

Comments
 (0)