Search code examples
pythonvimdocstring

generate python docstring template using current argument list


I have a python package to release soon, so now I begin to slowly add docstrings to the files using vim. So for a func like

def foo(x, y, z=None, **kwargs):

I have to manually type the following repetitively for a whole day

""" foo does this stuff.

Parameters
----------
x: 
y:
z: optional
kwargs:

Returns
-------

"""

Is there a way to dynamically generate this template docstring by defining some vim macros (which I know nothing of, so a suggestion for how to start would be great as well). Thanks.


Solution

  • The author of vim-pydocstring has kindly added the compatibility with Numpy-style docstrings to the package, which now seems to be the best answer to this question.

    You can pull/download the vim plugin from here