-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{{ log.debug("Rendering examples section") }} | ||
<p><strong>{{ section.title or "Examples:" }}</strong></p> | ||
{% for section_type, sub_section in section.value %} | ||
{% if section_type == "markdown" %} | ||
{% if section_type.value == "text" %} | ||
{{ sub_section|convert_markdown(heading_level, html_id) }} | ||
{% elif section_type == "examples" %} | ||
{% elif section_type.value == "examples" %} | ||
{{ sub_section|highlight(language="python", linenums=False) }} | ||
{% endif %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Tests for the handlers.python module.""" | ||
"""Tests for the `collector` module.""" | ||
|
||
import pytest | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Tests for the `renderer` module.""" | ||
|
||
import pytest | ||
from griffe.docstrings.dataclasses import DocstringSection, DocstringSectionKind | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"renderer", | ||
[ | ||
{"theme": "mkdocs"}, | ||
{"theme": "readthedocs"}, | ||
{"theme": {"name": "material"}}, | ||
], | ||
indirect=["renderer"], | ||
) | ||
def test_render_docstring_examples_section(renderer): | ||
"""Assert docstrings' examples section can be rendered. | ||
Parameters: | ||
renderer: A renderer instance (parametrized). | ||
""" | ||
section = DocstringSection( | ||
DocstringSectionKind.examples, | ||
value=[ | ||
(DocstringSectionKind.text, "This is an example."), | ||
(DocstringSectionKind.examples, ">>> print('Hello')\nHello"), | ||
], | ||
) | ||
template = renderer.env.get_template("docstring/examples.html") | ||
rendered = template.render(section=section) | ||
assert "<p>This is an example.</p>" in rendered | ||
assert "print" in rendered | ||
assert "Hello" in rendered |