Add @module annotation to source modules

This commit is contained in:
Tim Schaub
2017-09-05 14:46:05 -06:00
parent f118338c0a
commit e412ba113c

View File

@@ -259,5 +259,17 @@ module.exports = function(info, api) {
// replace any initial comments
root.get().node.comments = comments;
// add @module annotation for src modules
if (info.path.startsWith('src')) {
const name = info.path.replace(/^src\//, '').replace(/\.js$/, '');
const comment = j.commentBlock(`*\n * @module ${name}\n `);
const node = root.get().node;
if (!node.comments) {
node.comments = [comment];
} else {
node.comments.unshift(comment);
}
}
return root.toSource({quote: 'single'});
};