Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display async keyword in front of async functions/methods #6

Merged
merged 1 commit into from Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions mkautodoc/extension.py
Expand Up @@ -182,6 +182,9 @@ def render_signature(
if inspect.isclass(item):
qualifier_elem = etree.SubElement(signature_elem, "em")
qualifier_elem.text = "class "
elif inspect.iscoroutinefunction(item):
qualifier_elem = etree.SubElement(signature_elem, "em")
qualifier_elem.text = "async "

name_elem = etree.SubElement(signature_elem, "code")
if module_string:
Expand Down
6 changes: 6 additions & 0 deletions tests/mocklib/mocklib.py
Expand Up @@ -24,3 +24,9 @@ def example_property(self):
"""
This is a property with a *docstring*.
"""


async def example_async_function():
"""
This is a coroutine function as can be seen by the *async* keyword.
"""
12 changes: 12 additions & 0 deletions tests/test_extension.py
Expand Up @@ -18,6 +18,18 @@ def test_docstring():
]


def test_async_function():
content = """
::: mocklib.example_async_function
"""
output = markdown.markdown(content, extensions=["mkautodoc"])
assert output.splitlines() == [
'<div class="autodoc">',
'<div class="autodoc-signature"><em>async </em><code>mocklib.<strong>example_async_function</strong></code><span class="autodoc-punctuation">(</span><span class="autodoc-punctuation">)</span></div>',
"</div>",
]


def test_members():
content = """
# Example
Expand Down