Skip to content

Instantly share code, notes, and snippets.

@lencioni
Created November 15, 2014 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lencioni/4f5e799117b0474d9166 to your computer and use it in GitHub Desktop.
Save lencioni/4f5e799117b0474d9166 to your computer and use it in GitHub Desktop.
function definition snippet
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
@arusahni
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment