# -*- mode: snippet -*-
# Insert Google style docstring and function definition.
# name: Python Google style Docstring
# key: defg
# type: snippet
# contributor: Xaldew
# --
def ${1:name}($2):
\"\"\"$3
${2:$(python-args-to-google-docstring yas-text t)}
${5:Returns:
$6
}
\"\"\"
${0:$$(let ((beg yas-snippet-beg)
(end yas-snippet-end))
(yas-expand-snippet
(buffer-substring-no-properties beg end) beg end
(quote ((yas-indent-line nil) (yas-wrap-around-region nil))))
(delete-trailing-whitespace beg (- end 1)))}
There is still an issue with using thisThere is still an issue with using this inside nested indentation, e.g., within classes or as nested functions. In those cases the docstring is erroneously indented an extra time for some reason. I'll update this post if I manage to fix that.
The snippet should now work inside nested indentation, e.g., within classes or as nested functions. In those casesother scopes by forbidding yasnippet
from auto-indenting the docstring is erroneously indented an extra time for some reason. I'll update this post if I manage to fix thatsecond expansion.