add plugin that removes everything except JSDoc comments from source files (#304)

This commit is contained in:
Jeff Williams 2013-01-15 08:26:31 -08:00
parent b214687651
commit 5880a7bd79

16
plugins/commentsOnly.js Normal file
View File

@ -0,0 +1,16 @@
/**
* @overview Remove everything in a file except JSDoc-style comments. By enabling this plugin, you
* can document source files that are not valid JavaScript (including source files for other
* languages).
* @module plugins/commentsOnly
* @author Jeff Williams <jeffrey.l.williams@gmail.com>
*/
exports.handlers = {
beforeParse: function(e) {
// a JSDoc comment looks like: /**[one or more chars]*/
var comments = e.source.match(/\/\*\*[\s\S]+?\*\//g);
e.source = comments.join('\n\n');
console.log('source: ' + e.source);
}
};