Skip to content

Commit efcbafa

Browse files
Myles Borinsevanlucas
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 <fishrock123@rocketmail.com> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com>
1 parent 6032dc2 commit efcbafa

2 files changed

Lines changed: 23 additions & 29 deletions

File tree

‎tools/doc/generate.js‎

Lines changed: 7 additions & 9 deletions
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
thrownewError('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)thrower;
56-
console.log(html);
57-
});
51+
require('./html.js')(input,inputFile,template,nodeVersion,
52+
function(er,html){
53+
if(er)thrower;
54+
console.log(html);
55+
});
5856
break;
5957

6058
default:

‎tools/doc/html.js‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ var gtocPath = path.resolve(path.join(
3030
vargtocLoading=null;
3131
vargtocData=null;
3232

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

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

5859
functiononGtocLoaded(){
59-
varlexed=marked.lexer(opts.input);
60+
varlexed=marked.lexer(input);
6061
fs.readFile(template,'utf8',function(er,template){
6162
if(er)returncb(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-
functionrender(opts,cb){
98-
varlexed=opts.lexed;
99-
varfilename=opts.filename;
100-
vartemplate=opts.template;
90+
functionrender(lexed,filename,template,nodeVersion,cb){
91+
if(typeofnodeVersion==='function'){
92+
cb=nodeVersion;
93+
nodeVersion=null;
94+
}
95+
96+
nodeVersion=nodeVersion||process.version;
10197

10298
// get the section
10399
varsection=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)