| 1 |
{#- Template for "Yields" sections in docstrings. |
| 2 |
|
| 3 |
This template renders a list of documented yielded values (generators) in the format |
| 4 |
specified with the [`docstring_section_style`][] configuration option. |
| 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 yields section") }} |
| 16 |
{% endblock logs %} |
| 17 |
|
| 18 |
{% import "language.html.jinja" as lang with context %} |
| 19 |
{#- Language module providing the `t` translation method. -#} |
| 20 |
|
| 21 |
{% if config.docstring_section_style == "table" %} |
| 22 |
{% block table_style scoped %} |
| 23 |
{#- Block for the `table` section style. -#} |
| 24 |
{% set name_column = section.value|selectattr("name")|any %} |
| 25 |
<p><span class="doc-section-title">{{ section.title or lang.t("Yields:") }}</span></p> |
| 26 |
<table> |
| 27 |
<thead> |
| 28 |
<tr> |
| 29 |
{% if name_column %}<th>{{ lang.t("Name") }}</th>{% endif %} |
| 30 |
<th>{{ lang.t("Type") }}</th> |
| 31 |
<th>{{ lang.t("Description") }}</th> |
| 32 |
</tr> |
| 33 |
</thead> |
| 34 |
<tbody> |
| 35 |
{% for yields in section.value %} |
| 36 |
<tr class="doc-section-item"> |
| 37 |
{% if name_column %}<td>{% if yields.name %}<code>{{ yields.name }}</code>{% endif %}</td>{% endif %} |
| 38 |
<td> |
| 39 |
{% if yields.annotation %} |
| 40 |
{% with expression = yields.annotation, backlink_type = "yielded-by" %} |
| 41 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 42 |
{% endwith %} |
| 43 |
{% endif %} |
| 44 |
</td> |
| 45 |
<td> |
| 46 |
<div class="doc-md-description"> |
| 47 |
{{ yields.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} |
| 48 |
</div> |
| 49 |
</td> |
| 50 |
</tr> |
| 51 |
{% endfor %} |
| 52 |
</tbody> |
| 53 |
</table> |
| 54 |
{% endblock table_style %} |
| 55 |
{% elif config.docstring_section_style == "list" %} |
| 56 |
{% block list_style scoped %} |
| 57 |
{#- Block for the `list` section style. -#} |
| 58 |
<p><span class="doc-section-title">{{ section.title or lang.t("Yields:") }}</span></p> |
| 59 |
<ul> |
| 60 |
{% for yields in section.value %} |
| 61 |
<li class="doc-section-item field-body"> |
| 62 |
{% if yields.name %}<b><code>{{ yields.name }}</code></b>{% endif %} |
| 63 |
{% if yields.annotation %} |
| 64 |
{% with expression = yields.annotation, backlink_type = "yielded-by" %} |
| 65 |
{% if yields.name %} ({% endif %} |
| 66 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 67 |
{% if yields.name %}){% endif %} |
| 68 |
{% endwith %} |
| 69 |
{% endif %} |
| 70 |
– |
| 71 |
<div class="doc-md-description"> |
| 72 |
{{ yields.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} |
| 73 |
</div> |
| 74 |
</li> |
| 75 |
{% endfor %} |
| 76 |
</ul> |
| 77 |
{% endblock list_style %} |
| 78 |
{% elif config.docstring_section_style == "spacy" %} |
| 79 |
{% block spacy_style scoped %} |
| 80 |
{#- Block for the `spacy` section style. -#} |
| 81 |
<table> |
| 82 |
<thead> |
| 83 |
<tr> |
| 84 |
<th><span class="doc-section-title">{{ (section.title or lang.t("YIELDS")).rstrip(":").upper() }}</span></th> |
| 85 |
<th><span>{{ lang.t("DESCRIPTION") }}</span></th> |
| 86 |
</tr> |
| 87 |
</thead> |
| 88 |
<tbody> |
| 89 |
{% for yields in section.value %} |
| 90 |
<tr class="doc-section-item"> |
| 91 |
<td> |
| 92 |
{% if yields.name %} |
| 93 |
<code>{{ yields.name }}</code> |
| 94 |
{% elif yields.annotation %} |
| 95 |
<span class="doc-yields-annotation"> |
| 96 |
{% with expression = yields.annotation, backlink_type = "yielded-by" %} |
| 97 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 98 |
{% endwith %} |
| 99 |
</span> |
| 100 |
{% endif %} |
| 101 |
</td> |
| 102 |
<td class="doc-yields-details"> |
| 103 |
<div class="doc-md-description"> |
| 104 |
{{ yields.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} |
| 105 |
</div> |
| 106 |
{% if yields.name and yields.annotation %} |
| 107 |
<p> |
| 108 |
<span class="doc-yields-annotation"> |
| 109 |
<b>{{ lang.t("TYPE:") }}:</b> |
| 110 |
{% with expression = yields.annotation, backlink_type = "yielded-by" %} |
| 111 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 112 |
{% endwith %} |
| 113 |
</span> |
| 114 |
</p> |
| 115 |
{% endif %} |
| 116 |
</td> |
| 117 |
</tr> |
| 118 |
{% endfor %} |
| 119 |
</tbody> |
| 120 |
</table> |
| 121 |
{% endblock spacy_style %} |
| 122 |
{% endif %} |