Closed patkujawa-wf closed 7 years ago
Thanks @patkujawa-wf for reporting that issue. I will try to fix it ASAP.
@patkujawa-wf a first way to address your problem is to write :returns:
instead of :return:
as returns is the expected syntax in reST format as you can notice in the link you provided.
But the observed behaviour using your example is clearly buggy! And worth I noticed that inverting :rtype:
line with :return:
line will remove both lines!
Thanks @dadadel! I wonder why PyCharm autocompletes on :return:
? I've definitely see that in other docstrings, too, but good to know! :)
@dadadel I'm confused, now, since http://sphinx-doc.org/domains.html#info-field-lists has an example that uses :return:
, not :returns:
. So which is correct?
.. py:function:: send_message(sender, recipient, message_body, [priority=1])
Send a message to a recipient
:param str sender: The person sending the message
:param str recipient: The recipient of the message
:param str message_body: The body of the message
:param priority: The priority of the message, can be a number 1-5
:type priority: integer or None
:return: the message id
:rtype: int
:raises ValueError: if the message_body exceeds 160 characters
:raises TypeError: if the message_body is not a basestring
Both are correct, return is an alias for returns: https://github.com/sphinx-doc/sphinx/blob/2ec179044bc7dfc647731a08bc3da7d6e133c994/sphinx/domains/c.py#L69 https://github.com/sphinx-doc/sphinx/blob/5f63aac209b0d23420ddb6374673ed13dd7ec4b2/doc/ext/napoleon.rst#L110
found this while running test suites, I'll take a look at it too
edit: added pull request #28
@maqifrnswa Thanks for your fix. I updated your test commit.
The issue is fixed by the PR #28.
https://pythonhosted.org/an_example_pypi_project/sphinx.html#python-cross-referencing-syntax shows that
:rtype:
is the sphinx way to specify the type or return items, but pyment removes that tag from the docstring. It also seems to de-dent or lose the indentation of the:return:
tag: