Fixed return types not showing for methods.

Fixes #219
pull/231/head
Ashley Whetter 4 years ago
parent f5823855ba
commit 3faa27053b

@ -3,6 +3,15 @@ Changelog
Versions follow `Semantic Versioning <https://semver.org/>`_ (``<major>.<minor>.<patch>``).
TBC (TBC)
---------
Bug Fixes
^^^^^^^^^
* `#219 <https://github.com/readthedocs/sphinx-autoapi/issues/219>`:
Fixed return types not showing for methods.
v1.4.0 (2020-06-07)
-------------------

@ -1,6 +1,6 @@
{%- if obj.display %}
{% if sphinx_version >= (2, 1) %}
.. method:: {{ obj.short_name }}({{ obj.args }})
.. method:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
{% for property in obj.properties %}
:{{ property }}:
{% endfor %}

@ -53,6 +53,10 @@ class A:
"""My property."""
return "prop"
def my_method(self) -> str:
"""My method."""
return "method"
async def async_function(self, wait: bool) -> int:
if wait:

@ -1,5 +1,6 @@
import io
import os
import re
import shutil
import sys
from mock import patch, Mock, call
@ -172,12 +173,17 @@ class TestPy3Module(object):
assert "global_a :A" in example_file
assert "my_method(self) -> str" in example_file
def test_async(self):
example_path = "_build/text/autoapi/example/index.txt"
with io.open(example_path, encoding="utf8") as example_handle:
example_file = example_handle.read()
if sphinx.version_info >= (2, 1):
if sphinx.version_info >= (3, 1):
assert re.search("async_method[^\n]*:async:", example_file)
assert "async example.async_function" in example_file
elif sphinx.version_info >= (2, 1):
assert "async async_method" in example_file
assert "async example.async_function" in example_file
else:

Loading…
Cancel
Save