From f82c9a2699635f10ddc500e3f1edc61a1f7b0157 Mon Sep 17 00:00:00 2001 From: yannickreiss Date: Wed, 11 Oct 2023 18:11:09 +0200 Subject: [PATCH] Python plugin update --- UltiSnips/python.snippets | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index 47ac20a..3106faa 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -2,27 +2,31 @@ snippet docmodule "Documentation for modules" A """ File: `!p snip.rv = fn` Author: ${1:Yannick Reiß} -Description: ${2:No further description} Created on: `date` +Description: ${2:No further description} """ $0 endsnippet snippet def "Python Function" A -def ${1:function}($2): +def ${1:function}(${2}): """ - ${3:function description} + @name $1 + @brief ${3:function description} Args: - ${2} (${4:type}): ${5:description} - + `!p +params = t[2].replace(", ", ",").split(",") +snip.rv = "" +for param in params: + snip.rv += f"@param {param}" +` Returns: - $6 ${7:description} + $4 ${5:description} """ + $6 `!p -if t[6] != "" and not t[8].endswith(f"return {t[6]}"): - t[8] = t[8] + f"\n\treturn {t[6]}"` - $8 +if t[4] != "": + snip.rv = f"\n\treturn {t[4]}"` $0 endsnippet -