Skip to content

Commit f9f85a0

Browse files
jmmMyles Borins
authored andcommitted
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: #6690 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
1 parent 3681b9b commit f9f85a0

File tree

3 files changed

+41
-19
lines changed

3 files changed

+41
-19
lines changed

‎test/doctool/test-doctool-html.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,22 @@ testData.forEach(function(item){
6161

6262
fs.readFile(item.file,'utf8',common.mustCall(function(err,input){
6363
assert.ifError(err);
64-
html(input,'foo','doc/template.html',
64+
html(
65+
{
66+
input: input,
67+
filename: 'foo',
68+
template: 'doc/template.html',
69+
nodeVersion: process.version,
70+
},
71+
6572
common.mustCall(function(err,output){
6673
assert.ifError(err);
6774

6875
constactual=output.replace(/\s/g,'');
6976
// Assert that the input stripped of all whitespace contains the
7077
// expected list
7178
assert.notEqual(actual.indexOf(expected),-1);
72-
}));
79+
})
80+
);
7381
}));
7482
});

‎tools/doc/generate.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,19 @@ function next(er, input){
4848
break;
4949

5050
case'html':
51-
require('./html.js')(input,inputFile,template,nodeVersion,
51+
require('./html.js')(
52+
{
53+
input: input,
54+
filename: inputFile,
55+
template: template,
56+
nodeVersion: nodeVersion,
57+
},
58+
5259
function(er,html){
5360
if(er)thrower;
5461
console.log(html);
55-
});
62+
}
63+
);
5664
break;
5765

5866
default:

‎tools/doc/html.js‎

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

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

4040
if(gtocData){
4141
returnonGtocLoaded();
@@ -57,10 +57,15 @@ function toHTML(input, filename, template, nodeVersion, cb){
5757
}
5858

5959
functiononGtocLoaded(){
60-
varlexed=marked.lexer(input);
60+
varlexed=marked.lexer(opts.input);
6161
fs.readFile(template,'utf8',function(er,template){
6262
if(er)returncb(er);
63-
render(lexed,filename,template,nodeVersion,cb);
63+
render({
64+
lexed: lexed,
65+
filename: opts.filename,
66+
template: template,
67+
nodeVersion: nodeVersion,
68+
},cb);
6469
});
6570
}
6671
}
@@ -87,13 +92,14 @@ function toID(filename){
8792
.replace(/-+/g,'-');
8893
}
8994

90-
functionrender(lexed,filename,template,nodeVersion,cb){
91-
if(typeofnodeVersion==='function'){
92-
cb=nodeVersion;
93-
nodeVersion=null;
94-
}
95-
96-
nodeVersion=nodeVersion||process.version;
95+
/**
96+
* opts: lexed, filename, template, nodeVersion.
97+
*/
98+
functionrender(opts,cb){
99+
varlexed=opts.lexed;
100+
varfilename=opts.filename;
101+
vartemplate=opts.template;
102+
varnodeVersion=opts.nodeVersion||process.version;
97103

98104
// get the section
99105
varsection=getSection(lexed);

0 commit comments

Comments
(0)