Skip to content

Commit 2016491

Browse files
committed
passes siteConfig to tags even if they are in comment blocks for bit-docs/bit-docs-html-codepen-link#1
1 parent 973e8c9 commit 2016491

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

process/code_and_comment.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var typeCheckReg = /^\s*@(\w+)/;
1515
* [bit-docs/types/docObject].
1616
*
1717
* @param {bit-docs-js/types/processCodeOptions} options
18-
*
18+
*
1919
* Options object that includes the [bit-docs-js/types/codeTagBlock] and any
2020
* [bit-docs-js/types/codeLine] that immediately followed the
2121
* [bit-docs-js/types/codeTagBlock].
@@ -45,7 +45,8 @@ module.exports = function(options, callback){
4545
scope: newScope || options.scope,
4646
docMap: options.docMap,
4747
docObject: newDoc || options.docObject || {},
48-
tags: options.tags || {}
48+
tags: options.tags || {},
49+
siteConfig: options.siteConfig || {}
4950
}, function(newDoc, newScope){
5051
callback(newDoc, newScope);
5152
});
@@ -58,7 +59,8 @@ module.exports = function(options, callback){
5859
scope: options.scope,
5960
docMap: options.docMap,
6061
docObject: {},
61-
tags: options.tags || {}
62+
tags: options.tags || {},
63+
siteConfig: options.siteConfig || {}
6264
}, function(newDoc, newScope){
6365
callback(newDoc, newScope);
6466
});

process/javascript.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ module.exports = function(filename, source, docMap, siteConfig, addDocObjectToDo
2929
docMap: docMap,
3030
scope: scope,
3131
tags: siteConfig.tags,
32-
docObject: {src: {line: comment.line, codeLine: comment.codeLine, path: filename}}
32+
docObject: {src: {line: comment.line, codeLine: comment.codeLine, path: filename}},
33+
siteConfig: siteConfig
3334
}, function(docObject, newScope){
3435
if(docObject) {
3536
addDocObjectToDocMap(docObject);

process/process_test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,5 +440,29 @@ describe("bit-docs-js", function(){
440440
done();
441441
});
442442
});
443+
444+
it("processJavaScript provides filename and line if available to tags", function(done){
445+
var count = 0;
446+
tags.siteconfigtest = {
447+
add: function(line, curData, scope, docMap, defaultWriteProp, options){
448+
449+
assert.ok(options.siteConfig,"siteConfig exists");
450+
}
451+
};
452+
453+
fs.readFile(path.join(__dirname,"test","should-get-siteconfig.js"), function(err, data){
454+
if(err) {
455+
return done(err);
456+
}
457+
458+
var docMap = {};
459+
processJavaScript("utils/should-get-siteconfig.js", ""+data,docMap, {tags: tags},makeAddToDocMap(docMap));
460+
done();
461+
});
462+
463+
});
464+
465+
466+
443467
});
444468
});

process/test/filename_and_line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ First
55
/**
66
* @filetest
77
*/
8-
Second
8+
Second

process/test/should-get-siteconfig.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @siteconfigtest
3+
*/
4+
First
5+
/**
6+
* @siteconfigtest
7+
*/
8+
Second

0 commit comments

Comments
 (0)