| 1 |
{#- Template for "Attributes" sections in docstrings. |
| 2 |
|
| 3 |
This template renders a list of documented attributes 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 attributes 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 |
<p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p> |
| 25 |
<table> |
| 26 |
<thead> |
| 27 |
<tr> |
| 28 |
<th>{{ lang.t("Name") }}</th> |
| 29 |
<th>{{ lang.t("Type") }}</th> |
| 30 |
<th>{{ lang.t("Description") }}</th> |
| 31 |
</tr> |
| 32 |
</thead> |
| 33 |
<tbody> |
| 34 |
{% for attribute in section.value %} |
| 35 |
<tr class="doc-section-item"> |
| 36 |
<td><code><autoref identifier="{{ obj.path }}.{{ attribute.name }}" optional hover>{{ attribute.name }}</autoref></code></td> |
| 37 |
<td> |
| 38 |
{% if attribute.annotation %} |
| 39 |
{% with expression = attribute.annotation %} |
| 40 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 41 |
{% endwith %} |
| 42 |
{% endif %} |
| 43 |
</td> |
| 44 |
<td> |
| 45 |
<div class="doc-md-description"> |
| 46 |
{{ attribute.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook|default(AutorefsHook(obj[attribute.name], config))) }} |
| 47 |
</div> |
| 48 |
</td> |
| 49 |
</tr> |
| 50 |
{% endfor %} |
| 51 |
</tbody> |
| 52 |
</table> |
| 53 |
{% endblock table_style %} |
| 54 |
{% elif config.docstring_section_style == "list" %} |
| 55 |
{% block list_style scoped %} |
| 56 |
{#- Block for the `list` section style. -#} |
| 57 |
<p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p> |
| 58 |
<ul> |
| 59 |
{% for attribute in section.value %} |
| 60 |
<li class="doc-section-item field-body"> |
| 61 |
<b><code><autoref identifier="{{ obj.path }}.{{ attribute.name }}" optional hover>{{ attribute.name }}</autoref></code></b> |
| 62 |
{% if attribute.annotation %} |
| 63 |
{% with expression = attribute.annotation %} |
| 64 |
(<code>{% include "expression.html.jinja" with context %}</code>) |
| 65 |
{% endwith %} |
| 66 |
{% endif %} |
| 67 |
– |
| 68 |
<div class="doc-md-description"> |
| 69 |
{{ attribute.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook|default(AutorefsHook(obj[attribute.name], config))) }} |
| 70 |
</div> |
| 71 |
</li> |
| 72 |
{% endfor %} |
| 73 |
</ul> |
| 74 |
{% endblock list_style %} |
| 75 |
{% elif config.docstring_section_style == "spacy" %} |
| 76 |
{% block spacy_style scoped %} |
| 77 |
{#- Block for the `spacy` section style. -#} |
| 78 |
<table> |
| 79 |
<thead> |
| 80 |
<tr> |
| 81 |
<th><span class="doc-section-title">{{ (section.title or lang.t("ATTRIBUTE")).rstrip(":").upper() }}</span></th> |
| 82 |
<th><span>{{ lang.t("DESCRIPTION") }}</span></th> |
| 83 |
</tr> |
| 84 |
</thead> |
| 85 |
<tbody> |
| 86 |
{% for attribute in section.value %} |
| 87 |
<tr class="doc-section-item"> |
| 88 |
<td><code><autoref identifier="{{ obj.path }}.{{ attribute.name }}" optional hover>{{ attribute.name }}</autoref></code></td> |
| 89 |
<td class="doc-attribute-details"> |
| 90 |
<div class="doc-md-description"> |
| 91 |
{{ attribute.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook|default(AutorefsHook(obj[attribute.name], config))) }} |
| 92 |
</div> |
| 93 |
<p> |
| 94 |
{% if attribute.annotation %} |
| 95 |
<span class="doc-attribute-annotation"> |
| 96 |
<b>{{ lang.t("TYPE:") }}</b> |
| 97 |
{% with expression = attribute.annotation %} |
| 98 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 99 |
{% endwith %} |
| 100 |
</span> |
| 101 |
{% endif %} |
| 102 |
</p> |
| 103 |
</td> |
| 104 |
</tr> |
| 105 |
{% endfor %} |
| 106 |
</tbody> |
| 107 |
</table> |
| 108 |
{% endblock spacy_style %} |
| 109 |
{% endif %} |