{#- 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 %} {% import "language.html.jinja" as lang with context %} {#- Language module providing the `t` translation method. -#}
'|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else class.name),
skip_inventory=config.skip_local_inventory,
) %}
{% block heading scoped %}
{#- Heading block.
This block renders the heading for the class.
-#}
{% if config.show_symbol_type_heading %}{% endif %}
{% if config.heading and root %}
{{ config.heading }}
{% elif config.separate_signature %}
{{ class_name }}
{% elif config.merge_init_into_class and "__init__" in all_members %}
{% with function = all_members["__init__"] %}
{%+ filter highlight(language="python", inline=True) %}
{{ class_name -}}
{%- with obj = function -%}
{%- include "type_parameters.html.jinja" with context -%}
{%- endwith -%}
{%- include "signature.html.jinja" with context -%}
{% endfilter %}
{% endwith %}
{% else %}
{# TODO: Maybe render type parameters here. #}
{{ 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.
Overloads of the `__init__` method are rendered if `merge_init_into_class` is enabled.
The actual `__init__` method signature is only rendered if `separate_signature` is also enabled.
If the class is generic, but the `__init__` method isn't or `merge_init_into_class` is disabled,
the class signature is rendered if `separate_signature` and `show_signature_type_parameters` are enabled.
If the `__init__` method or any overloads are generic, they are rendered as methods if
`merge_init_into_class`, `separate_signature` and `show_signature_type_parameters` are enabled.
-#}
{% if config.merge_init_into_class and "__init__" in all_members %}
{% with function = all_members["__init__"] %}
{% if function.overloads and config.show_overloads %}
'|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else class.name),
hidden=True,
skip_inventory=config.skip_local_inventory,
) %}
{% endfilter %}
{% endif %}
{% set heading_level = heading_level - 1 %}
{% endif %}
Bases: {% for expression in class.bases -%}
{%- with backlink_type = "subclassed-by" -%}
{%- include "expression.html.jinja" with context -%}
{%- endwith -%}
{% if not loop.last %}, {% endif %}
{% 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 %}
{# We don't want to merge the inherited `__init__` method docstring into the class docstring #}
{# if such inherited method was not selected through `inherited_members`. #}
{% with check_members = all_members if (config.inherited_members is true or (config.inherited_members is iterable and "__init__" in config.inherited_members)) else class.members %}
{% if "__init__" in check_members and check_members["__init__"].has_docstring %}
{% with function = check_members["__init__"] %}
{% with obj = function, docstring_sections = function.docstring.parsed %}
{% include "docstring.html.jinja" with context %}
{% endwith %}
{% endwith %}
{% endif %}
{% endwith %}
{% endif %}
{% endblock docstring %}
{% if config.backlinks %}
{%- if init.relative_filepath.is_absolute() -%}
{{ init.relative_package_filepath }}
{%- else -%}
{{ init.relative_filepath }}
{%- endif -%}
{%- if class.relative_filepath.is_absolute() -%}
{{ class.relative_package_filepath }}
{%- else -%}
{{ class.relative_filepath }}
{%- endif -%}