commentConvert.js 592 B

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