Created
November 7, 2017 06:46
-
-
Save erukiti/09801e5e82f542b415130c91fa5b59fd to your computer and use it in GitHub Desktop.
s2sでコメントを挿入する実験 (Babel6でも動くバージョン)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const plugin = babel => { | |
| const {types: t} = babel | |
| return { | |
| inherits: inheritsOpts, | |
| name: 's2s-jsdoc-creator', | |
| visitor: { | |
| Function(nodePath, state) { | |
| const comment = `* | |
| * @hoge | |
| * @fuga | |
| `.split('\n').map(line => line.trim()).join('\n') | |
| const stPath = nodePath.getStatementParent() | |
| // assert inList | |
| stPath.insertBefore(t.emptyStatement()) | |
| stPath.getPrevSibling().addComment('trailing', comment) | |
| }, | |
| }, | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment