Closed ilcn closed 7 years ago
rtype
can generate only from type hinting.
def foo(arg1: str) -> str:
return 'foo'
will generate like folloing.
def foo(arg1: str) -> str:
"""foo
:param arg1:
:type arg1: str
:rtype: str
"""
return 'foo'
You need to annotate type hint if you want to generate return type.
def foo(arg):
return 'foo'
Because pydocstring.vim can't understand what type returns. pydocstring generate from function,method, class signature.
So I tried my own fork and tried to add a :return line to my multiline comment:
{{_header_}}
:param {{_args_}}:
:rtype: {{_returnType_}}
:return:
But this doesn't work unless I put something on that line:
{{_header_}}
:param {{_args_}}:
:rtype: {{_returnType_}}
:return: {{_header_}}
Shouldn't the line be rendered without any additional arguments? Per Sphinx docs :return is part of the rst docstring format, and I personally think it's crucial as for explaining the return, whereas the :rtype only explains the type.
This is not an issue per se, more like a minor inconvenience.
What about this?
"""
{{_header_}}
:param {{_args_}}:
{{_indent_}}:return:
"""
def foo(arg1):
"""
foo
:param arg1:
:return:
"""
pass
class Foo(object):
def foo(arg1, arg2):
"""
foo
:param arg1:
:param arg2:
:return:
"""
pass
Thanks for the template, it will be useful. But I am not exactly sure why the indent is not rendered?
I was also wondering the same. I was guessing this plugin used python's inspect
library to guess the types.
May I point out, this form of type hinting is only supported in Python 3. I am writing code which works in Python 2 and 3. So it might be useful to support this form of type hinting
@ashwinvis
Thank you for a suggestion.
I was guessing this plugin used python's inspect library to guess the types.
So, you meant I should use Vim's python binding and inspect types? I'm sorry I have no plan to do that.
I was looking at the template multi, apparently there is a line for return type named rtype. The standard doc string is usually :return in python. Moreover, it seems I only get :param but not :return or :rtype (as in the template). Am I missing something here? If not can do a PR for :return generation?