diff options
Diffstat (limited to 'support/jsdoc/jsdoc-import-path-plugin.js')
-rw-r--r-- | support/jsdoc/jsdoc-import-path-plugin.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/support/jsdoc/jsdoc-import-path-plugin.js b/support/jsdoc/jsdoc-import-path-plugin.js new file mode 100644 index 0000000..3f0937f --- /dev/null +++ b/support/jsdoc/jsdoc-import-path-plugin.js @@ -0,0 +1,21 @@ +const path = require('path'); + +exports.handlers = { + jsdocCommentFound: function(e) { + var moduleName = path.parse(e.filename).name; + + + var lines = e.comment.split(/\r?\n/); + + var importLines = [ + '```', + `import ${moduleName} from 'async/${moduleName}';`, + '```' + ]; + + if (moduleName !== 'index') { + e.comment = [lines[0], ...importLines, ...lines.slice(1)].join("\n"); + } + + } +}; |