Debian Codegraph @

src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja

raw
1 {#- Template for "Examples" sections in docstrings.
2
3 This template renders a list of documented examples.
4 It alternates between rendering text and code examples.
5
6 Context:
7 section (griffe.DocstringSectionAttributes): The section to render.
8 -#}
9
10 {% block logs scoped %}
11 {#- Logging block.
12
13 This block can be used to log debug messages, deprecation messages, warnings, etc.
14 -#}
15 {{ log.debug("Rendering examples section") }}
16 {% endblock logs %}
17
18 {% import "language.html.jinja" as lang with context %}
19 {#- Language module providing the `t` translation method. -#}
20
21 <p><span class="doc-section-title">{{ section.title or lang.t("Examples:") }}</span></p>
22 {% for section_type, sub_section in section.value %}
23 {% if section_type.value == "text" %}
24 {{ sub_section|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
25 {% elif section_type.value == "examples" %}
26 {{ sub_section|highlight(language="pycon") }}
27 {% endif %}
28 {% endfor %}