Debian Codegraph @

src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja

raw
1 {#- Template for Python attributes.
2
3 This template renders a Python attribute (or variable).
4 This can be a module attribute or a class attribute.
5
6 Context:
7 attribute (griffe.Attribute): The attribute to render.
8 root (bool): Whether this is the root object, injected with `:::` in a Markdown page.
9 heading_level (int): The HTML heading level to use.
10 config (dict): The configuration options.
11 -#}
12
13 {% block logs scoped %}
14 {#- Logging block.
15
16 This block can be used to log debug messages, deprecation messages, warnings, etc.
17 -#}
18 {{ log.debug("Rendering " + attribute.path) }}
19 {% endblock logs %}
20
21 <div class="doc doc-object doc-attribute">
22 {% with obj = attribute, html_id = attribute.path %}
23
24 {% if root %}
25 {% set show_full_path = config.show_root_full_path %}
26 {% set root_members = True %}
27 {% elif root_members %}
28 {% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %}
29 {% set root_members = False %}
30 {% else %}
31 {% set show_full_path = config.show_object_full_path %}
32 {% endif %}
33
34 {% set attribute_name = attribute.path if show_full_path else attribute.name %}
35
36 {% if not root or config.show_root_heading %}
37 {% filter heading(
38 heading_level,
39 role="data" if attribute.parent.kind.value == "module" else "attr",
40 id=html_id,
41 class="doc doc-heading",
42 toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else attribute.name),
43 skip_inventory=config.skip_local_inventory,
44 ) %}
45
46 {% block heading scoped %}
47 {#- Heading block.
48
49 This block renders the heading for the attribute.
50 -#}
51 {% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code>{% endif %}
52 {% if config.heading and root %}
53 {{ config.heading }}
54 {% elif config.separate_signature %}
55 <span class="doc doc-object-name doc-attribute-name">{{ attribute_name }}</span>
56 {% else %}
57 {%+ filter highlight(language="python", inline=True) %}
58 {{ attribute_name }}{% if attribute.annotation and config.show_signature_annotations %}: {{ attribute.annotation }}{% endif %}
59 {% if config.show_attribute_values and attribute.value %} = {{ attribute.value }}{% endif %}
60 {% endfilter %}
61 {% endif %}
62 {% endblock heading %}
63
64 {% block labels scoped %}
65 {#- Labels block.
66
67 This block renders the labels for the attribute.
68 -#}
69 {% with labels = attribute.labels %}
70 {% include "labels.html.jinja" with context %}
71 {% endwith %}
72 {% endblock labels %}
73
74 {% endfilter %}
75
76 {% block signature scoped %}
77 {#- Signature block.
78
79 This block renders the signature for the attribute.
80 -#}
81 {% if config.separate_signature %}
82 {% filter format_attribute(attribute, config.line_length, crossrefs=config.signature_crossrefs, show_value=config.show_attribute_values) %}
83 {{ attribute.name }}
84 {% endfilter %}
85 {% endif %}
86 {% endblock signature %}
87
88 {% else %}
89
90 {% if config.show_root_toc_entry %}
91 {% filter heading(heading_level,
92 role="data" if attribute.parent.kind.value == "module" else "attr",
93 id=html_id,
94 toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else attribute_name),
95 hidden=True,
96 skip_inventory=config.skip_local_inventory,
97 ) %}
98 {% endfilter %}
99 {% endif %}
100 {% set heading_level = heading_level - 1 %}
101 {% endif %}
102
103 <div class="doc doc-contents {% if root %}first{% endif %}">
104 {% block contents scoped %}
105 {#- Contents block.
106
107 This block renders the contents of the attribute.
108 It contains other blocks that users can override.
109 Overriding the contents block allows to rearrange the order of the blocks.
110 -#}
111 {% block docstring scoped %}
112 {#- Docstring block.
113
114 This block renders the docstring for the attribute.
115 -#}
116 {% with docstring_sections = attribute.docstring.parsed %}
117 {% include "docstring.html.jinja" with context %}
118 {% endwith %}
119 {% endblock docstring %}
120
121 {% if config.backlinks %}
122 <backlinks identifier="{{ html_id }}" handler="python" />
123 {% endif %}
124 {% endblock contents %}
125 </div>
126
127 {% endwith %}
128 </div>