Created
November 15, 2014 22:12
-
-
Save lencioni/4f5e799117b0474d9166 to your computer and use it in GitHub Desktop.
function definition snippet
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) | |
arguments = t[2].split(',') | |
arguments = [argument.strip() for argument in arguments if argument] | |
if len(arguments): | |
tags = map(formatTag, arguments) | |
snip.rv = "/**" | |
for tag in tags: | |
snip += tag | |
snip += ' */' | |
snip += '' | |
else: | |
snip.rv = '' | |
`${1}: function(${2}) { | |
${0:${VISUAL}} | |
}, | |
endsnippet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I did a first-pass refactor of the Python here. I haven't had a chance to test this, so if I subtly broke the output, let me know: https://gist.github.com/arusahni/fd29be9aeaafe6a9e430
Thanks for the snippet tutorial!