Using the snippets plugin I'm able to get:
class MyClasnippets(object):
"""Docstring for MyClasnippets. """
def __init__(self):
"""TODO: to be defined. """
from just typing class
. If I add params I can get:
class MyClass(object):
"""Docstring for MyClass. """
def __init__(self, x, y):
"""TODO: to be defined.
:x: TODO
:y: TODO
"""
self._x = x
self._y = y
I want to edit the docstring + the triggers, so 2 things would change:
- When adding exception in a forward trigger, the docstring will add a "Raises" section (using Google's format)
- Change the entire format to Google's...
I looked at the vim ./bundle/vim-snippets/UltiSnips/python.snippets
, specifically at the class
definition there:
snippet class "class with docstrings" b
class ${1:MyClass}(${2:object}):
`!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
def __init__(self$4):
`!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p
snip.rv = ""
snip >> 2
args = get_args(t[4])
write_docstring_args(args, snip)
if args:
snip.rv += '\n' + snip.mkline('', indent='')
snip += '{0}'.format(triple_quotes(snip))
write_init_body(args, t[2], snip)
`
$0
endsnippet
but have no idea where the Docstring
is defined and what to do next.