Sublime 3, snippet for python function docstring with arguments and return
I would like to write a snippet to add docstring to Python function:
for example:
def foo(a):
b=a+1
return b
should produce the following
def foo(a):
"""One liner description
Parameters
----------
a : type
some comment
Returns
-------
b : type
some comment
"""
b=a+1
return b
My first attempt is this snippet:
<snippet>
<content><![CDATA[
"""${1:One liner description}
Parameters
----------
${2}
Returns
-------
${3}
"""
]]></content>
<tabTrigger>docstring</tabTrigger>
<scope>source.python</scope>
<description>Adds a docstring skeleton to function</description>
</snippet>
which produces the following when typing docstring and then Tab:
def foo(a):
"""One liner description
Parameters
----------
Returns
-------
"""
b=a+1
return b
How can I get the parameter "a" and "b" inside the snippet ?
No comments:
Post a Comment