heavenshell / vim-pydocstring

Generate Python docstring to your Python source code.
BSD 3-Clause "New" or "Revised" License
337 stars 53 forks source link

Reuse existing docstring #107

Closed marconetto closed 4 years ago

marconetto commented 4 years ago

If I execute the "Pydocstring" command on a python function that already has the docstring, but for instance, a new variable was added, this plugin seems to increate the docstring template for that function from scratch (keeping the existing one there). Is this the expected behaviour of the plugin? If yes, a nice feature would be to reuse the existing docstring and just add new content in the docstring that is required (e.g. new variable). Could also thing about removing a variable and removing the docstring component of that variable.

heavenshell commented 4 years ago

@marconetto Hi, Thanks for suggestion.

Yes, expected behavior.

Kapture 2020-08-25 at 22 22 56

Because generate docstring is simple.

def | foo(arg1, arg2):

| is cursor, vim-pydocstring send def foo(arg1, arg2): pass to AST parser. vim-pydocstring does not know docstring already exists or not.

But if visual select was on and it's includes docstring, AST parser know docstring is already exists and ignore to generate docstring.

a nice feature would be to reuse the existing docstring and just add new content in the docstring that is required (e.g. new variable).

Sorry currently I don't have any plan to do this. I know it's convinent, but it too much complex.

Diffing old docstring and new docstring, compare it and add ore delete docstring param is hard. See https://github.com/heavenshell/py-doq/issues/30 for why I don't do this.