Python: added snippets for classmethod and staticmethod
This commit is contained in:
parent
a811b756d0
commit
2bffc46ecb
@ -157,6 +157,20 @@ def write_slots_args(args, snip):
|
|||||||
args = ['"_%s"' % arg for arg in args]
|
args = ['"_%s"' % arg for arg in args]
|
||||||
snip += '__slots__ = (%s,)' % ', '.join(args)
|
snip += '__slots__ = (%s,)' % ', '.join(args)
|
||||||
|
|
||||||
|
|
||||||
|
def write_function_code(t, snip):
|
||||||
|
snip.rv = ""
|
||||||
|
snip >> 1
|
||||||
|
|
||||||
|
args = get_args(t[2])
|
||||||
|
if args:
|
||||||
|
write_docstring_args(args, snip)
|
||||||
|
|
||||||
|
style = get_style(snip)
|
||||||
|
snip += format_return(style)
|
||||||
|
snip.rv += '\n' + snip.mkline('', indent='')
|
||||||
|
snip += triple_quotes(snip)
|
||||||
|
|
||||||
endglobal
|
endglobal
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
@ -395,22 +409,33 @@ def __coerce__(self, other):
|
|||||||
${25:pass}
|
${25:pass}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
snippet def "function with docstrings" b
|
snippet def "function with docstrings" b
|
||||||
def ${1:function}(`!p
|
def ${1:function}(`!p
|
||||||
if snip.indent:
|
if snip.indent:
|
||||||
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
|
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
|
||||||
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
|
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
|
||||||
snip.rv = ""
|
write_function_code(t, snip) `
|
||||||
snip >> 1
|
${0:pass}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
args = get_args(t[2])
|
|
||||||
if args:
|
|
||||||
write_docstring_args(args, snip)
|
|
||||||
|
|
||||||
style = get_style(snip)
|
snippet defc "class method with docstrings" b
|
||||||
snip += format_return(style)
|
@classmethod
|
||||||
snip.rv += '\n' + snip.mkline('', indent='')
|
def ${1:function}(`!p
|
||||||
snip += triple_quotes(snip) `
|
if snip.indent:
|
||||||
|
snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}):
|
||||||
|
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
|
||||||
|
write_function_code(t, snip) `
|
||||||
|
${0:pass}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
||||||
|
snippet defs "static method with docstrings" b
|
||||||
|
@staticmethod
|
||||||
|
def ${1:function}(${2:arg1}):
|
||||||
|
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
|
||||||
|
write_function_code(t, snip) `
|
||||||
${0:pass}
|
${0:pass}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user