| 1 |
{#- Template for "Parameters" sections in docstrings. |
| 2 |
|
| 3 |
This template renders a list of documented parameters 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 parameters 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("Parameters:") }}</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 |
<th>{{ lang.t("Default") }}</th> |
| 32 |
</tr> |
| 33 |
</thead> |
| 34 |
<tbody> |
| 35 |
{% for parameter in section.value %} |
| 36 |
<tr class="doc-section-item"> |
| 37 |
<td> |
| 38 |
{% if config.parameter_headings %} |
| 39 |
{% filter heading( |
| 40 |
heading_level + 1, |
| 41 |
role="param", |
| 42 |
id=html_id ~ "(" ~ parameter.name ~ ")", |
| 43 |
class="doc doc-heading doc-heading-parameter", |
| 44 |
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-parameter"></code> '|safe if config.show_symbol_type_toc else '') + parameter.name, |
| 45 |
skip_inventory=config.skip_local_inventory, |
| 46 |
) %} |
| 47 |
<code>{{ parameter.name }}</code> |
| 48 |
{% endfilter %} |
| 49 |
{% else %} |
| 50 |
<code>{{ parameter.name }}</code> |
| 51 |
{% endif %} |
| 52 |
</td> |
| 53 |
<td> |
| 54 |
{% if parameter.annotation %} |
| 55 |
{% with expression = parameter.annotation, backlink_type = "used-by" %} |
| 56 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 57 |
{% endwith %} |
| 58 |
{% endif %} |
| 59 |
</td> |
| 60 |
<td> |
| 61 |
<div class="doc-md-description"> |
| 62 |
{{ parameter.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} |
| 63 |
</div> |
| 64 |
</td> |
| 65 |
<td> |
| 66 |
{% if parameter.default %} |
| 67 |
{% with expression = parameter.default, backlink_type = "used-by" %} |
| 68 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 69 |
{% endwith %} |
| 70 |
{% else %} |
| 71 |
<em>{{ lang.t("required") }}</em> |
| 72 |
{% endif %} |
| 73 |
</td> |
| 74 |
</tr> |
| 75 |
{% endfor %} |
| 76 |
</tbody> |
| 77 |
</table> |
| 78 |
{% endblock table_style %} |
| 79 |
{% elif config.docstring_section_style == "list" %} |
| 80 |
{% block list_style scoped %} |
| 81 |
{#- Block for the `list` section style. -#} |
| 82 |
<p><span class="doc-section-title">{{ section.title or lang.t("Parameters:") }}</span></p> |
| 83 |
<ul> |
| 84 |
{% for parameter in section.value %} |
| 85 |
<li class="doc-section-item field-body"> |
| 86 |
{% if config.parameter_headings %} |
| 87 |
{% filter heading( |
| 88 |
heading_level + 1, |
| 89 |
role="param", |
| 90 |
id=html_id ~ "(" ~ parameter.name ~ ")", |
| 91 |
class="doc doc-heading doc-heading-parameter", |
| 92 |
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-parameter"></code> '|safe if config.show_symbol_type_toc else '') + parameter.name, |
| 93 |
skip_inventory=config.skip_local_inventory, |
| 94 |
) %} |
| 95 |
<b><code>{{ parameter.name }}</code></b> |
| 96 |
{% endfilter %} |
| 97 |
{% else %} |
| 98 |
<b><code>{{ parameter.name }}</code></b> |
| 99 |
{% endif %} |
| 100 |
{% if parameter.annotation %} |
| 101 |
{% with expression = parameter.annotation, backlink_type = "used-by" %} |
| 102 |
(<code>{% include "expression.html.jinja" with context %}</code> |
| 103 |
{%- if parameter.default %}, {{ lang.t("default:") }} |
| 104 |
{% with expression = parameter.default, backlink_type = "used-by" %} |
| 105 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 106 |
{% endwith %} |
| 107 |
{% endif %}) |
| 108 |
{% endwith %} |
| 109 |
{% endif %} |
| 110 |
– |
| 111 |
<div class="doc-md-description"> |
| 112 |
{{ parameter.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} |
| 113 |
</div> |
| 114 |
</li> |
| 115 |
{% endfor %} |
| 116 |
</ul> |
| 117 |
{% endblock list_style %} |
| 118 |
{% elif config.docstring_section_style == "spacy" %} |
| 119 |
{% block spacy_style scoped %} |
| 120 |
{#- Block for the `spacy` section style. -#} |
| 121 |
<table> |
| 122 |
<thead> |
| 123 |
<tr> |
| 124 |
<th><span class="doc-section-title">{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</span></th> |
| 125 |
<th><span>{{ lang.t("DESCRIPTION") }}</span></th> |
| 126 |
</tr> |
| 127 |
</thead> |
| 128 |
<tbody> |
| 129 |
{% for parameter in section.value %} |
| 130 |
<tr class="doc-section-item"> |
| 131 |
<td> |
| 132 |
{% if config.parameter_headings %} |
| 133 |
{% filter heading( |
| 134 |
heading_level + 1, |
| 135 |
role="param", |
| 136 |
id=html_id ~ "(" ~ parameter.name ~ ")", |
| 137 |
class="doc doc-heading doc-heading-parameter", |
| 138 |
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-parameter"></code> '|safe if config.show_symbol_type_toc else '') + parameter.name, |
| 139 |
skip_inventory=config.skip_local_inventory, |
| 140 |
) %} |
| 141 |
<code>{{ parameter.name }}</code> |
| 142 |
{% endfilter %} |
| 143 |
{% else %} |
| 144 |
<code>{{ parameter.name }}</code> |
| 145 |
{% endif %} |
| 146 |
</td> |
| 147 |
<td class="doc-param-details"> |
| 148 |
<div class="doc-md-description"> |
| 149 |
{{ parameter.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} |
| 150 |
</div> |
| 151 |
<p> |
| 152 |
{% if parameter.annotation %} |
| 153 |
<span class="doc-param-annotation"> |
| 154 |
<b>{{ lang.t("TYPE:") }}</b> |
| 155 |
{% with expression = parameter.annotation, backlink_type = "used-by" %} |
| 156 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 157 |
{% endwith %} |
| 158 |
</span> |
| 159 |
{% endif %} |
| 160 |
{% if parameter.default %} |
| 161 |
<span class="doc-param-default"> |
| 162 |
<b>{{ lang.t("DEFAULT:") }}</b> |
| 163 |
{% with expression = parameter.default, backlink_type = "used-by" %} |
| 164 |
<code>{% include "expression.html.jinja" with context %}</code> |
| 165 |
{% endwith %} |
| 166 |
</span> |
| 167 |
{% endif %} |
| 168 |
</p> |
| 169 |
</td> |
| 170 |
</tr> |
| 171 |
{% endfor %} |
| 172 |
</tbody> |
| 173 |
</table> |
| 174 |
{% endblock spacy_style %} |
| 175 |
{% endif %} |