Skip to content

Instantly share code, notes, and snippets.

@arusahni
Forked from lencioni/javascript.snippets
Last active October 2, 2015 20:36
Show Gist options
  • Save arusahni/fd29be9aeaafe6a9e430 to your computer and use it in GitHub Desktop.
Save arusahni/fd29be9aeaafe6a9e430 to your computer and use it in GitHub Desktop.
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
@lencioni
Copy link

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.

@kodonnell
Copy link

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