UNPKG

649 BJavaScriptView Raw
1/**
2 @overview Demonstrate how to modify the source code before the parser sees it.
3 @module plugins/commentConvert
4 @author Michael Mathews <micmath@gmail.com>
5 */
6'use strict';
7
8/*eslint spaced-line-comment: 0 */
9
10exports.handlers = {
11 ///
12 /// Convert ///-style comments into jsdoc comments.
13 /// @param e
14 /// @param e.filename
15 /// @param e.source
16 ///
17 beforeParse: function(e) {
18 e.source = e.source.replace(/(\n[ \t]*\/\/\/[^\n]*)+/g, function($) {
19 var replacement = '\n/**' + $.replace(/^[ \t]*\/\/\//mg, '').replace(/(\n$|$)/, '*/$1');
20 return replacement;
21 });
22 }
23};