{#- Template for Python classes. This template renders a Python class. Context: class (griffe.Class): The class to render. root (bool): Whether this is the root object, injected with `:::` in a Markdown page. heading_level (int): The HTML heading level to use. config (dict): The configuration options. -#} {% block logs scoped %} {#- Logging block. This block can be used to log debug messages, deprecation messages, warnings, etc. -#} {{ log.debug("Rendering " + class.path) }} {% endblock logs %}
{% with obj = class, html_id = class.path %} {% if root %} {% set show_full_path = config.show_root_full_path %} {% set root_members = True %} {% elif root_members %} {% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %} {% set root_members = False %} {% else %} {% set show_full_path = config.show_object_full_path %} {% endif %} {% set class_name = class.path if show_full_path else class.name %} {% if not root or config.show_root_heading %} {% filter heading( heading_level, role="class", id=html_id, class="doc doc-heading", toc_label=(' '|safe if config.show_symbol_type_toc else '') + class.name, ) %} {% block heading scoped %} {#- Heading block. This block renders the heading for the class. -#} {% if config.show_symbol_type_heading %}{% endif %} {% if config.separate_signature %} {{ class_name }} {% elif config.merge_init_into_class and "__init__" in class.all_members %} {% with function = class.all_members["__init__"] %} {%+ filter highlight(language="python", inline=True) %} {{ class_name }}{% include "signature.html.jinja" with context %} {% endfilter %} {% endwith %} {% else %} {{ class_name }} {% endif %} {% endblock heading %} {% block labels scoped %} {#- Labels block. This block renders the labels for the class. -#} {% with labels = class.labels %} {% include "labels.html.jinja" with context %} {% endwith %} {% endblock labels %} {% endfilter %} {% block signature scoped %} {#- Signature block. This block renders the signature for the class. -#} {% if config.separate_signature and config.merge_init_into_class %} {% if "__init__" in class.all_members %} {% with function = class.all_members["__init__"] %} {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} {{ class.name }} {% endfilter %} {% endwith %} {% endif %} {% endif %} {% endblock signature %} {% else %} {% if config.show_root_toc_entry %} {% filter heading(heading_level, role="class", id=html_id, toc_label=(' '|safe if config.show_symbol_type_toc else '') + class.name, hidden=True, ) %} {% endfilter %} {% endif %} {% set heading_level = heading_level - 1 %} {% endif %}
{% block contents scoped %} {#- Contents block. This block renders the contents of the class. It contains other blocks that users can override. Overriding the contents block allows to rearrange the order of the blocks. -#} {% block bases scoped %} {#- Class bases block. This block renders the bases for the class. -#} {% if config.show_bases and class.bases %}

Bases: {% for expression in class.bases -%} {% include "expression.html.jinja" with context %}{% if not loop.last %}, {% endif %} {% endfor -%}

{% endif %} {% endblock bases %} {% block inheritance_diagram scoped %} {#- Inheritance diagram block. This block renders the inheritance diagram for the class, using Mermaid syntax and a bit of JavaScript to make the nodes clickable, linking to the corresponding class documentation. -#} {% if config.show_inheritance_diagram and class.bases %} {% macro edges(class) %} {% for base in class.resolved_bases %} {{ base.path }} --> {{ class.path }} {{ edges(base) }} {% endfor %} {% endmacro %}
{% for base in class.mro() %} {% endfor %}
flowchart {{ config.inheritance_diagram_direction }} {{ class.path }}[{{ class.name }}] {% for base in class.mro() %} {{ base.path }}[{{ base.name }}] {% endfor %} {{ edges(class) | safe }} click {{ class.path }} href "" "{{ class.path }}" {% for base in class.mro() %} click {{ base.path }} href "" "{{ base.path }}" {% endfor %}
{% endif %} {% endblock inheritance_diagram %} {% block docstring scoped %} {#- Docstring block. This block renders the docstring for the class. -#} {% with docstring_sections = class.docstring.parsed %} {% include "docstring.html.jinja" with context %} {% endwith %} {% if config.merge_init_into_class %} {% if "__init__" in class.all_members and class.all_members["__init__"].has_docstring %} {% with function = class.all_members["__init__"] %} {% with obj = function, docstring_sections = function.docstring.parsed %} {% include "docstring.html.jinja" with context %} {% endwith %} {% endwith %} {% endif %} {% endif %} {% endblock docstring %} {% block summary scoped %} {#- Summary block. This block renders auto-summaries for classes, methods, and attributes. -#} {% include "summary.html.jinja" with context %} {% endblock summary %} {% block source scoped %} {#- Source block. This block renders the source code for the class. -#} {% if config.show_source %} {% if config.merge_init_into_class %} {% if "__init__" in class.all_members and class.all_members["__init__"].source %} {% with init = class.all_members["__init__"] %}
Source code in {{ init|source_location }} {{ init.source|highlight(language="python", linestart=init.lineno or 0, linenums=True) }}
{% endwith %} {% endif %} {% elif class.source %}
Source code in {{ class|source_location }} {{ class.source|highlight(language="python", linestart=class.lineno or 0, linenums=True) }}
{% endif %} {% endif %} {% endblock source %} {% block children scoped %} {#- Children block. This block renders the children (members) of the class. -#} {% set root = False %} {% set heading_level = heading_level + 1 %} {% include "children.html.jinja" with context %} {% endblock children %} {% endblock contents %}
{% endwith %}