From 897cca031e3c78e2cf79845eda58de86fcfd8133 Mon Sep 17 00:00:00 2001 From: "rygwdn@gmail.com" <> Date: Fri, 30 Jul 2010 21:47:36 -0300 Subject: [PATCH] Added option to use doxygen style comments in smart def and smart class. --- UltiSnips/python.snippets | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index 339f33c..648f152 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -18,6 +18,11 @@ endsnippet ########## # COMMON # ########## + +# The smart def and smart class snippets use a global option called +# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen +# style comments in docstrings. + snippet class "smart class" b class ${1:MyClass}(${2:object}): """ ${3:Docstring for $1 }""" @@ -34,7 +39,11 @@ if args: snip += "" for arg in args: - snip += ":%s: description" % arg + style = snip.opt("g:ultisnips_python_style", "normal") + if style == "doxygen": + snip += "@param %s TODO" % arg + else: + snip += ":%s: TODO" % arg if args: snip += '"""' @@ -63,12 +72,21 @@ args = [arg for arg in args if arg and arg != "self"] if args: snip += "" +snip.locals["style"] = style = snip.opt("g:ultisnips_python_style", "normal") for arg in args: - snip += ":%s: description" % arg + if style == "doxygen": + snip += "@param %s TODO" % arg + else: + snip += ":%s: TODO" % arg `${4: - :returns: ${5:description} + `!p +style = snip.locals["style"] +if style == "doxygen": + snip.rv = "@return" +else: + snip.rv = ":returns:"` ${5:TODO} }""" ${0:pass}