-
-
Save arusahni/fd29be9aeaafe6a9e430 to your computer and use it in GitHub Desktop.
This file contains 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
snippet fun "function with dynamic docblock" b | |
`!p | |
# Currently Ultisnips does not support dynamic tabstops, so we cannot add | |
# tabstops to the datatype for these param tags until that feature is added. | |
def formatTag(argument): | |
return " * @param {{}} {0}".format(argument) | |
tags = [formatTag(argument.strip()) for argument in t[2].split(',') if argument] | |
if tags: | |
snip.rv = "/**{0} */".format("".join(tags)) | |
else: | |
snip.rv = '' | |
`${1}: function(${2}) { | |
${0:${VISUAL}} | |
}, | |
endsnippet |
I suspect changing snip.rv = "/**{0} */".format("".join(tags))
to snip.rv = "/**{0} */".format("\n".join(tags))
will add new lines.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the refactoring! Unfortunately, this appears to lose the newlines. Although it isn't apparent at all by looking at the code that newlines are happening, it seems that every time you do
snip += '...'
, a newline is created. I'd love to see a refactored version that maintains this aspect though.