Skip to content

Commit 9274a2f

Browse files
committed
adding better generate callbacks
1 parent bc036a1 commit 9274a2f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

bit-docs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var postProcessTags = require("./post-process");
2+
var processTags = require("./process-tags");
3+
4+
module.exports = function(bitDocs){
5+
// this makes tags run
6+
bitDocs.register("postProcessor", postProcessTags);
7+
bitDocs.register("processor", processTags);
8+
};

post-process.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
var _ = require('lodash');
3+
4+
// for each tag that has a .done method, calls it on every item in the docMap
5+
module.exports = function(docMap, siteConfig){
6+
var tags = siteConfig.tags
7+
var dones = [];
8+
for ( var tag in tags ) {
9+
if ( tags[tag].done ) {
10+
dones.push(tags[tag].done);
11+
}
12+
}
13+
// some tags inherit methods other tags. We don't want to duplicate the same done behavior
14+
dones = _.uniq(dones);
15+
16+
for( var name in docMap) {
17+
dones.forEach(function(done){
18+
done.call(docMap[name]);
19+
});
20+
}
21+
};

0 commit comments

Comments
 (0)