Skip to content

Commit

Permalink
Merge pull request #6 from florimondmanca/feat/async-marker
Browse files Browse the repository at this point in the history
Display async keyword in front of async functions/methods
  • Loading branch information
tomchristie committed Oct 22, 2019
2 parents b9b5b60 + 6f32b2a commit 748d424
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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

0 comments on commit 748d424

Please sign in to comment.