pixelneo / vim-python-docstring Goto Github PK
View Code? Open in Web Editor NEWA Vim plugin for generating python docstrings.
License: Other
A Vim plugin for generating python docstrings.
License: Other
Hi, just another small feedback on your great plugin.
I haven't found any official guideline for what to put in a docstring when no explicit return statement is found,
but this stackoverflow question suggests it should be like this:
"""Prints the element given as input
Args:
x: any element
Returns:
None
"""
Do you think this is something you could/would like to implement?
Hi there, thanks for this amazing plugin!
Just wanted to let you know that when I generate a class docstring,
I see a list of attributes which are missing the colons at the end of the attribute names.
E.g.:
class PointsToRaster:
"""
Attributes:
x_raster
x_dim_da
"""
Add parameter/return types when users include type hint in their code
Numpy style is ignored in lunarvim with the following config
{
'pixelneo/vim-python-docstring',
config = function()
vim.cmd("let g:python_style = 'numpy'")
end,
},
Related to #1
"""
Parameters
----------
foo1 :
foo2 :
...
"""
"""
Parameters
----------
foo1 :
foo2 :
...
"""
Is it possible to add an option for the user to choose? Or just change the default format.
Hi,
after some environment changes (which I am unable to track down) I am not getting this error when using :Docstring
in vim.
Doctring ERROR: module 'ast' has no attribute 'unparse'
Do you have any suggestion on how to debug this?
I've tried opening python and calling ast.unparse
but that does not give me an error.
Hello,
Nice plugin by the way.
I've made some small error handling improvements to your plugin on my own machine that I would like to raise a PR for.
I've just improved how errors are logged mainly (no stack traces, just concise error messages).
If you happy with this I can raise a PR with your approval.
Cheers!
As it is mentioned in README.md I added :
Plugin pixelneo/vim-python-docstring
to my .vimrc file.
When I want to use it by doing
:Docstring
however I get the error:
E492: Not an editor command
I would appreciate any comment.
With this function (reproduced with only this contents in a file too):
def f(x, y):
if x == 1:
raise ValueError(f'x ({x}) == 1')
return a, b
Calling :Docstring
produces this docstring:
"""
Args:
x:
y:
Returns:
Raises:
ValueError: x:
"""
Expected output:
"""
Args:
x:
y:
Returns:
Raises:
ValueError:
"""
It seems related to the f-string.
I'm on Ubuntu 20.04, and my output of vim --version
is:
vim_version.txt
One minor README typo I didn't feel was worth a separate issue: Instalation -> Installation
If function does not have a body, plugin does not work.
e.g.
def foo(a,b):
Add support for type hints in function arguments.
e.g.
def foo(a:str, b:int):
pass
should get this docstring:
def foo(a:str, b:int):
"""
Args:
a (str): ...
b (int): ...
"""
pass
This can be done using typing.get_type_hints('foo')
. Or in case foo
is in class A
, typing.get_type_hints('A.foo')
(this needs to be distinguished โ using ast
).
I found that even if I setup let g:python_stype="numpy"
in the .vimrc
file. It still uses google style.
My guess is because of the following lines:
vim-python-docstring/python/vimenv.py
Lines 62 to 64 in 60f58e3
Code quality is not great, lot of don't touch if it works vibes
If a function is the last thing in a file and its body does not have an empty line after it, the plugin does not work.
e.g.
# ... there can be some code at the beginning
def foo(a,b):
pass
(there is no empty line at the end)
Plugin does not work for functions starting with async
.
e.g.
async def foo(a, b):
pass
Currently the docstring plugin produces unexpected results when used on a function that enforces keyword-only arguments. For example:
def foo(*, arg1, arg2):
return arg1 + arg2
produces an empty docstring when using the plugin and the result is:
def foo(*, arg1, arg2):
"""
Returns
-------
"""
return arg1 + arg2
It would be nice if the *
indicating keyword-only args would be supported.
Why: Now, a new docstring is always created. On a change of some arguments, on function that already has some docstring, that docstring should only be updated โ new args added, old ones removed.
Maybe I am missing something, but how can I add type
along with param
?
Example:
def foo(foo_one, foo_two):
"""Function with reStructuredText style docstring
:param foo_one:
:type foo_one:
:param foo_two:
:type foo_two:
"""
pass
With the following code, the plugin gives Docstring ERROR: list index out of range
:
def f():
pass
Include the default values in the doc string in cases such as :
def foo(a: int = 3, name: str = 'bar'):
pass
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.