mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
add plugin that removes everything except JSDoc comments from source files (#304)
This commit is contained in:
parent
b214687651
commit
5880a7bd79
16
plugins/commentsOnly.js
Normal file
16
plugins/commentsOnly.js
Normal 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);
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user