diff --git a/docs/schema.json b/docs/schema.json index e1863d26..fc1d3467 100644 --- a/docs/schema.json +++ b/docs/schema.json @@ -144,6 +144,12 @@ "type": "boolean", "default": false }, + "show_signature_type_parameters": { + "title": "Show the type parameters in generic classes, methods, functions and type aliases signatures.", + "markdownDescription": "https://mkdocstrings.github.io/python/usage/configuration/signatures/#show_signature_type_parameters", + "type": "boolean", + "default": true + }, "separate_signature": { "title": "Whether to put the whole signature in a code block below the heading. If a formatter (Black or Ruff) is installed, the signature is also formatted using it.", "markdownDescription": "https://mkdocstrings.github.io/python/usage/configuration/signatures/#separate_signature", @@ -210,6 +216,12 @@ "type": "boolean", "default": true }, + "show_docstring_type_parameters": { + "title": "Whether to display the \"Type Parameters\" section in the object's docstring.", + "markdownDescription": "https://mkdocstrings.github.io/python/usage/configuration/docstrings/#show_docstring_type_parameters", + "type": "boolean", + "default": true + }, "show_docstring_warns": { "title": "Whether to display the \"Warns\" section in the object's docstring.", "markdownDescription": "https://mkdocstrings.github.io/python/usage/configuration/docstrings/#show_docstring_warns", @@ -313,4 +325,4 @@ } }, "additionalProperties": false -} \ No newline at end of file +} diff --git a/docs/usage/configuration/docstrings.md b/docs/usage/configuration/docstrings.md index 0cf2dac1..72036be3 100644 --- a/docs/usage/configuration/docstrings.md +++ b/docs/usage/configuration/docstrings.md @@ -792,6 +792,63 @@ class Class: //// /// +## `show_docstring_type_aliases` + +- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** + +Whether to render the "Type Aliases" sections of docstrings. + +```yaml title="in mkdocs.yml (global configuration)" +plugins: +- mkdocstrings: + handlers: + python: + options: + show_docstring_type_aliases: true +``` + +```md title="or in docs/some_page.md (local configuration)" +::: path.to.module + options: + show_docstring_type_aliases: false +``` + +```python +"""Summary. + +Type Aliases: + TypeAlias: Some type alias. +""" + + +type TypeAlias = int +"""Summary.""" +``` + +/// admonition | Preview + type: preview + +//// tab | With type_aliases +
Summary.
+Type Aliases:
+ +**Name** | **Description** +------------ | ---------------- +`TypeAlias` | Some type alias. + +TypeAlias
Summary.
+//// + +//// tab | Without classes +Summary.
+TypeAlias
Summary.
+//// +/// + ## `show_docstring_modules` - **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** @@ -1225,6 +1282,56 @@ def rand() -> int: //// /// +## `show_docstring_type_parameters` + +- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** + + +Whether to render the "Type Parameters" section of docstrings. + +```yaml title="in mkdocs.yml (global configuration)" +plugins: +- mkdocstrings: + handlers: + python: + options: + show_docstring_type_parameters: true +``` + +```md title="or in docs/some_page.md (local configuration)" +::: path.to.module + options: + show_docstring_type_parameters: false +``` + +```python +class AClass[X: (int, str) = str]: + """Represents something. + + Type Parameters: + X: Something. + """ +``` + +/// admonition | Preview + type: preview + +//// tab | With parameters +AClass
Represents something.
+Type Parameters:
+ +**Name** | **Bound or Constraints** | **Description** | **Default** +---------- | ------------------------ | --------------- | ----------- +`whatever` | `(int, str)` | Something. | `str` +//// + +//// tab | Without parameters +AClass
Represents something.
+//// +/// + ## `show_docstring_warns` - **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** diff --git a/docs/usage/configuration/headings.md b/docs/usage/configuration/headings.md index 467779e4..511650ff 100644 --- a/docs/usage/configuration/headings.md +++ b/docs/usage/configuration/headings.md @@ -179,6 +179,285 @@ To customize symbols, see [Customizing symbol types](../customization.md/#symbol /// +## `type_parameter_headings` + +- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** + +Whether to render headings for generic class, function/method and type alias +type parameters. + +With this option enabled, each type parameter of a generic object (including +type parameters of `__init__` methods merged in their parent class with the +[`merge_init_into_class`][] option) gets a permalink, an entry in the Table of +Contents, and an entry in the generated objects inventory. The permalink and +inventory entry allow cross-references from internal and external pages. + +The identifier used in the permalink and inventory is of the following form: +`path.to.function:type_param_name`. To manually cross-reference a parameter, +you can therefore use this Markdown syntax: + +```md +- Class type parameter: [`Param`][package.module.Class:Param] +- Method type parameter: [`Param`][package.module.Class.method:Param] +- Function type parameter: [`Param`][package.module.function:Param] +- Type alias type parameter: [`Param`][package.module.TypeAlias:Param] +- Type variable tuple: [`*Args`][package.module.function:*Args] +- Parameter specification: [`**Params`][package.module.function:**Params] +``` + +Enabling this option along with [`signature_crossrefs`][] will automatically +render cross-references to type parameters in class/function/method/type alias +signatures. + +```yaml title="in mkdocs.yml (global configuration)" +plugins: +- mkdocstrings: + handlers: + python: + options: + type_parameter_headings: false +``` + +```md title="or in docs/some_page.md (local configuration)" +::: path.to.module + options: + type_parameter_headings: true +``` + +/// admonition | Preview: Cross-references + type: preview + +
set_element
+ ¤
+ Parameters:
+Type Parameters:
+Name | +Bound or Constraints | +Description | +Default | +
---|---|---|---|
+
+ |
+ + | +
+
+
+ The type of the element. + |
+ + required + | +
set_element
T
+
+To customize symbols, see [Customizing symbol types](../customization.md/#symbol-types).
+
+///
+
## `show_root_heading`
- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
@@ -286,15 +565,15 @@ More text.
type: preview
//// tab | With ToC entry
-**Table of contents**
-[Some heading](#permalink-to-some-heading){ title="#permalink-to-some-heading" }
-[`object`](#permalink-to-object){ title="#permalink-to-object" }
-[Other heading](#permalink-to-other-heading){ title="#permalink-to-other-heading" }
+**Table of contents**
+[Some heading](#permalink-to-some-heading){ title="#permalink-to-some-heading" }
+[`object`](#permalink-to-object){ title="#permalink-to-object" }
+[Other heading](#permalink-to-other-heading){ title="#permalink-to-other-heading" }
////
//// tab | Without ToC entry
-**Table of contents**
-[Some heading](#permalink-to-some-heading){ title="#permalink-to-some-heading" }
+**Table of contents**
+[Some heading](#permalink-to-some-heading){ title="#permalink-to-some-heading" }
[Other heading](#permalink-to-other-heading){ title="#permalink-to-other-heading" }
////
///
@@ -400,7 +679,7 @@ plugins:
Show the full Python path of every object.
Same as for [`show_root_members_full_path`][],
-but for every member, recursively. This option takes precedence over
+but for every member, recursively. This option takes precedence over
[`show_root_members_full_path`][]:
`show_root_members_full_path` | `show_object_full_path` | Direct root members path
@@ -454,7 +733,7 @@ When [grouped by categories][group_by_category], show a heading for each categor
These category headings will appear in the table of contents,
allowing you to link to them using their permalinks.
-WARNING: **Not recommended with deeply nested object**
+WARNING: **Not recommended with deeply nested object**
When injecting documentation for deeply nested objects,
you'll quickly run out of heading levels, and the objects
at the bottom of the tree risk all getting documented
diff --git a/docs/usage/configuration/members.md b/docs/usage/configuration/members.md
index 220a26fe..aa8b9f41 100644
--- a/docs/usage/configuration/members.md
+++ b/docs/usage/configuration/members.md
@@ -560,7 +560,7 @@ package
Whether to render summaries of modules, classes, functions (methods) and attributes.
This option accepts a boolean (`yes`, `true`, `no`, `false` in YAML)
-or a dictionary with one or more of the following keys: `attributes`, `functions`, `classes`, `modules`,
+or a dictionary with one or more of the following keys: `attributes`, `functions`, `classes`, `modules`, `type_aliases`,
with booleans as values. Class methods summary is (de)activated with the `functions` key.
By default, `summary` is false, and by extension all values are false.
diff --git a/docs/usage/configuration/signatures.md b/docs/usage/configuration/signatures.md
index 879db6b1..df32f505 100644
--- a/docs/usage/configuration/signatures.md
+++ b/docs/usage/configuration/signatures.md
@@ -202,7 +202,7 @@ plugins:
[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } —
[:octicons-tag-24: Insiders 1.8.0](../../insiders/changelog.md#1.8.0) —
-**This feature also requires
+**This feature also requires
[Griffe Insiders](https://mkdocstrings.github.io/griffe/insiders/)
to be installed.**
@@ -377,6 +377,60 @@ function(param1, param2=None)
////
///
+## `show_signature_type_parameters`
+
+- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
+
+
+Show the type parameters in generic classes, methods, functions and type aliases
+signatures.
+
+Since the heading can become quite long when type parameters are rendered, it is
+usually best to [separate the signature][separate_signature] from the heading.
+
+```yaml title="in mkdocs.yml (global configuration)"
+plugins:
+- mkdocstrings:
+ handlers:
+ python:
+ options:
+ separate_signature: true
+ show_signature_annotations: true
+ show_signature_type_parameters: true
+```
+
+```md title="or in docs/some_page.md (local configuration)"
+::: path.to.module
+ options:
+ separate_signature: true
+ show_signature_annotations: true
+ show_signature_type_parameters: false
+```
+
+/// admonition | Preview
+ type: preview
+
+//// tab | With signature type parameters
+Function docstring.
+//// + +//// tab | Without signature type parameters +Function docstring.
+//// +/// + ## `separate_signature` - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** diff --git a/docs/usage/customization.md b/docs/usage/customization.md index 907809c8..7f9dc2c6 100644 --- a/docs/usage/customization.md +++ b/docs/usage/customization.md @@ -34,9 +34,10 @@ The following CSS classes are used in the generated HTML: - `doc-class`: on `div`s containing a class - `doc-function`: on `div`s containing a function - `doc-module`: on `div`s containing a module + - `doc-type_alias`: on `div`s containing a type alias - `doc-heading`: on objects headings - `doc-object-name`: on `span`s wrapping objects names/paths in the heading - - `doc-KIND-name`: as above, specific to the kind of object (module, class, function, attribute) + - `doc-KIND-name`: as above, specific to the kind of object (module, class, function, attribute, type_alias) - `doc-contents`: on `div`s wrapping the docstring then the children (if any) - `first`: same, but only on the root object's contents `div` - `doc-labels`: on `span`s wrapping the object's labels @@ -48,7 +49,7 @@ The following CSS classes are used in the generated HTML: - `doc-symbol`: on `code` tags of symbol types - `doc-symbol-heading`: on symbol types in headings - `doc-symbol-toc`: on symbol types in the ToC - - `doc-symbol-KIND`: specific to the kind of object (`module`, `class`, `function`, `method`, `attribute`) + - `doc-symbol-KIND`: specific to the kind of object (`module`, `class`, `function`, `method`, `attribute`, `type_alias`) /// admonition | Example with colorful labels type: example @@ -90,33 +91,41 @@ by overriding the values of our CSS variables, for example: ```css title="docs/css/mkdocstrings.css" [data-md-color-scheme="default"] { --doc-symbol-parameter-fg-color: #df50af; + --doc-symbol-type_parameter-fg-color: #df50af; --doc-symbol-attribute-fg-color: #0079ff; --doc-symbol-function-fg-color: #00dfa2; --doc-symbol-method-fg-color: #00dfa2; --doc-symbol-class-fg-color: #d1b619; + --doc-symbol-type_alias-fg-color: #d1b619; --doc-symbol-module-fg-color: #ff0060; --doc-symbol-parameter-bg-color: #df50af1a; + --doc-symbol-type_parameter-bg-color: #df50af1a; --doc-symbol-attribute-bg-color: #0079ff1a; --doc-symbol-function-bg-color: #00dfa21a; --doc-symbol-method-bg-color: #00dfa21a; --doc-symbol-class-bg-color: #d1b6191a; + --doc-symbol-type_alias-bg-color: #d1b6191a; --doc-symbol-module-bg-color: #ff00601a; } [data-md-color-scheme="slate"] { --doc-symbol-parameter-fg-color: #ffa8cc; + --doc-symbol-type_parameter-fg-color: #ffa8cc; --doc-symbol-attribute-fg-color: #963fb8; --doc-symbol-function-fg-color: #6d67e4; --doc-symbol-method-fg-color: #6d67e4; --doc-symbol-class-fg-color: #46c2cb; + --doc-symbol-type_alias-fg-color: #46c2cb; --doc-symbol-module-fg-color: #f2f7a1; --doc-symbol-parameter-bg-color: #ffa8cc1a; + --doc-symbol-type_parameter-bg-color: #ffa8cc1a; --doc-symbol-attribute-bg-color: #963fb81a; --doc-symbol-function-bg-color: #6d67e41a; --doc-symbol-method-bg-color: #6d67e41a; --doc-symbol-class-bg-color: #46c2cb1a; + --doc-symbol-type_alias-bg-color: #46c2cb1a; --doc-symbol-module-bg-color: #f2f7a11a; } ``` @@ -129,17 +138,21 @@ otherwise just override the variables at root level: ```css title="docs/css/mkdocstrings.css" :root { --doc-symbol-parameter-fg-color: #df50af; + --doc-symbol-type_parameter-fg-color: #df50af; --doc-symbol-attribute-fg-color: #0079ff; --doc-symbol-function-fg-color: #00dfa2; --doc-symbol-method-fg-color: #00dfa2; --doc-symbol-class-fg-color: #d1b619; + --doc-symbol-type_alias-fg-color: #d1b619; --doc-symbol-module-fg-color: #ff0060; --doc-symbol-parameter-bg-color: #df50af1a; + --doc-symbol-type_parameter-bg-color: #df50af1a; --doc-symbol-attribute-bg-color: #0079ff1a; --doc-symbol-function-bg-color: #00dfa21a; --doc-symbol-method-bg-color: #00dfa21a; --doc-symbol-class-bg-color: #d1b6191a; + --doc-symbol-type_alias-bg-color: #d1b6191a; --doc-symbol-module-bg-color: #ff00601a; } ``` @@ -151,33 +164,41 @@ otherwise just override the variables at root level: @@ -204,6 +225,10 @@ For example, to use single letters instead of truncated types: content: "P"; } +.doc-symbol-type_parameter::after { + content: "P"; +} + .doc-symbol-attribute::after { content: "A"; } @@ -220,6 +245,10 @@ For example, to use single letters instead of truncated types: content: "C"; } +.doc-symbol-type_alias::after { + content: "T"; +} + .doc-symbol-module::after { content: "M"; } @@ -234,6 +263,10 @@ For example, to use single letters instead of truncated types: content: "P"; } + #preview-symbol-names .doc-symbol-type_parameter::after { + content: "P"; + } + #preview-symbol-names .doc-symbol-attribute::after { content: "A"; } @@ -250,16 +283,23 @@ For example, to use single letters instead of truncated types: content: "C"; } + #preview-symbol-names .doc-symbol-type_alias::after { + content: "T"; + } + + #preview-symbol-names .doc-symbol-module::after { content: "M"; }
{% endif %}
@@ -52,17 +52,27 @@ Context:
{% elif config.merge_init_into_class and "__init__" in all_members %}
{% with function = all_members["__init__"] %}
{%+ filter highlight(language="python", inline=True) %}
- {{ class_name }}{% include "signature"|get_template with context %}
+ {{ class_name -}}
+ {%- include "type_parameters"|get_template with context -%}
+ {%- if function.is_generic and config.show_signature_annotations and config.show_signature_type_parameters -%}
+ {%- with obj = function -%}
+ .__init__
+ {%- include "type_parameters"|get_template with context -%}
+ {%- endwith -%}
+ {%- endif -%}
+ {%- include "signature"|get_template with context -%}
{% endfilter %}
{% endwith %}
{% else %}
- {{ class_name }}
+ {%+ filter highlight(language="python", inline=True) %}
+ {{ class_name }}{% include "type_parameters"|get_template with context %}
+ {% endfilter %}
{% endif %}
{% endblock heading %}
{% block labels scoped %}
{#- Labels block.
-
+
This block renders the labels for the class.
-#}
{% with labels = class.labels %}
@@ -74,30 +84,39 @@ Context:
{% 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 %}
- {% if "__init__" in all_members %}
- {% with function = all_members["__init__"] %}
- {% if function.overloads %}
- {{ section.title or lang.t("Type Aliases:") }}
+{{ lang.t("Name") }} | +{{ lang.t("Description") }} | +
---|---|
|
+
+
+ {{ type_alias.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
+
+ |
+
{{ section.title or lang.t("Type Aliases:") }}
+{{ type_alias.name }}
+ –
+ {{ (section.title or lang.t("TYPE ALIAS")).rstrip(":").upper() }} | +{{ lang.t("DESCRIPTION") }} | +
---|---|
|
+
+
+ {{ type_alias.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
+
+ |
+
{{ section.title or lang.t("Type Parameters:") if not is_merged_init else lang.t("__init__
Type Parameters:") }}
{{ lang.t("Name") }} | +{{ lang.t("Bound or Constraints") }} | +{{ lang.t("Description") }} | +{{ lang.t("Default") }} | +
---|---|---|---|
+ {% if config.type_parameter_headings %}
+ {% filter heading(
+ heading_level + 1,
+ role="typeparam",
+ id=obj.path ~ ":" ~ type_parameter.name,
+ class="doc doc-heading doc-heading-type_parameter",
+ toc_label=(' '|safe if config.show_symbol_type_toc else '') + type_parameter.name,
+ ) %}
+ {{ type_parameter.name }}
+ {% endfilter %}
+ {% else %}
+ {{ type_parameter.name }}
+ {% endif %}
+ |
+
+ {% if type_parameter.annotation %}
+ {% with expression = type_parameter.annotation %}
+ {% include "expression"|get_template with context %}
+ {% endwith %}
+ {% endif %}
+ |
+
+
+ {{ type_parameter.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
+
+ |
+
+ {% if type_parameter.default %}
+ {% with expression = type_parameter.default %}
+ {% include "expression"|get_template with context %}
+ {% endwith %}
+ {% else %}
+ {{ lang.t("required") }}
+ {% endif %}
+ |
+
{{ section.title or lang.t("Type Parameters:") if not is_merged_init else lang.t("__init__
Type Parameters:") }}
'|safe if config.show_symbol_type_toc else '') + type_parameter.name,
+ ) %}
+ {{ type_parameter.name }}
+ {% endfilter %}
+ {% else %}
+ {{ type_parameter.name }}
+ {% endif %}
+ {% if type_parameter.annotation %}
+ (
+ {%- if type_parameter.constraints -%}
+ {%- for expression in type_parameter.constraints -%}
+ {% include "expression"|get_template with context %}
+ {%- if not loop.last %}, {% endif -%}
+ {%- endfor -%}
+ {%- else -%}
+ {%- with expression = type_parameter.bound -%}
+ {% include "expression"|get_template with context %}
+ {%- endwith -%}
+ {%- endif -%}
+ {%- if type_parameter.default %}, {{ lang.t("default:") }}
+ {% with expression = type_parameter.default %}
+ {% include "expression"|get_template with context %}
+ {% endwith %}
+ {% endif %})
+ {% endif %}
+ –
+ {{ (section.title or lang.t("TYPE PARAMETER")).rstrip(":").upper() if not is_merged_init else lang.t("__init__ TYPE PARAMETER") }} |
+ {{ lang.t("DESCRIPTION") }} | +
---|---|
+ {% if config.type_parameter_headings %}
+ {% filter heading(
+ heading_level + 1,
+ role="typeparam",
+ id=obj.path ~ ":" ~ type_parameter.name ,
+ class="doc doc-heading doc-heading-type_parameter",
+ toc_label=(' '|safe if config.show_symbol_type_toc else '') + type_parameter.name,
+ ) %}
+ {{ type_parameter.name }}
+ {% endfilter %}
+ {% else %}
+ {{ type_parameter.name }}
+ {% endif %}
+ |
+
+
+ {{ type_parameter.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
+
+
+ {% if type_parameter.constraints %}
+
+ {{ lang.t("CONSTRAINTS:") }}
+ {% for constraint in type_parameter.constraints -%}
+ {%- with expression = constraint -%}
+ |
+
__init__
Type Parameters:": "__init__
Type Parameters:"|safe,
+ "TYPE PARAMETER": "TYPE PARAMETER",
+ "__init__
TYPE PARAMETER": "__init__
TYPE PARAMETER"|safe,
"WARNS": "WARNS",
"Warns:": "Warns:",
"YIELDS": "YIELDS",
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja
index 508e5660..f1e110a8 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja
@@ -2,7 +2,7 @@
{% block logs scoped %}
{#- Logging block.
-
+
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{% endblock logs %}
@@ -12,6 +12,10 @@
{% include "summary/modules"|get_template with context %}
{% endif %}
+ {% if config.summary.type_aliases %}
+ {% include "summary/type_aliases"|get_template with context %}
+ {% endif %}
+
{% if config.summary.classes %}
{% include "summary/classes"|get_template with context %}
{% endif %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html b/src/mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html
new file mode 100644
index 00000000..bf0e6ca0
--- /dev/null
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html
@@ -0,0 +1,11 @@
+{% extends "_base/summary/type_aliases.html.jinja" %}
+
+{% block logs scoped %}
+ {{ super() }}
+ {# TODO: Switch to a warning after some time. #}
+ {{ log.info(
+ "DeprecationWarning: Extending '_base/type_aliases/classes.html' is deprecated, extend '_base/type_aliases/classes.html.jinja' instead. " ~
+ "After some time, this message will be logged as a warning, causing strict builds to fail.",
+ once=True,
+ ) }}
+{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html.jinja
new file mode 100644
index 00000000..ce62269c
--- /dev/null
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html.jinja
@@ -0,0 +1,21 @@
+{#- Summary of type aliases. -#}
+
+{% block logs scoped %}
+ {#- Logging block.
+
+ This block can be used to log debug messages, deprecation messages, warnings, etc.
+ -#}
+{% endblock logs %}
+
+{% with section = obj.type_aliases
+ |filter_objects(
+ filters=config.filters,
+ members_list=members_list,
+ inherited_members=config.inherited_members,
+ keep_no_docstrings=config.show_if_no_docstring,
+ )
+ |order_members(config.members_order, members_list)
+ |as_type_aliases_section(check_public=not members_list)
+ %}
+ {% if section %}{% include "docstring/type_aliases"|get_template with context %}{% endif %}
+{% endwith %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html b/src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html
new file mode 100644
index 00000000..18b50751
--- /dev/null
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html
@@ -0,0 +1,11 @@
+{% extends "_base/type_alias.html.jinja" %}
+
+{% block logs scoped %}
+ {{ super() }}
+ {# TODO: Switch to a warning after some time. #}
+ {{ log.info(
+ "DeprecationWarning: Extending '_base/type_alias.html' is deprecated, extend '_base/type_alias.html.jinja' instead. " ~
+ "After some time, this message will be logged as a warning, causing strict builds to fail.",
+ once=True,
+ ) }}
+{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html.jinja
new file mode 100644
index 00000000..5a21f8a6
--- /dev/null
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html.jinja
@@ -0,0 +1,117 @@
+{#- Template for Python type aliases.
+
+This template renders a Python type alias.
+
+Context:
+ type_alias (griffe.TypeAlias): The type alias 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 " + type_alias.path) }}
+{% endblock logs %}
+
+
'|safe if config.show_symbol_type_toc else '') + type_alias.name,
+ ) %}
+
+ {% block heading scoped %}
+ {#- Heading block.
+
+ This block renders the heading for the type alias.
+ -#}
+ {% if config.show_symbol_type_heading %}
{% endif %}
+ {% if config.separate_signature %}
+ {{ type_alias_name }}
+ {% else %}
+ {%+ filter highlight(language="python", inline=True) %}
+ {{ type_alias_name }}{% include "type_parameters"|get_template with context %} = {{ type_alias.value }}
+ {% endfilter %}
+ {% endif %}
+ {% endblock heading %}
+
+ {% block labels scoped %}
+ {#- Labels block.
+
+ This block renders the labels for the type alias.
+ -#}
+ {% with labels = type_alias.labels %}
+ {% include "labels"|get_template with context %}
+ {% endwith %}
+ {% endblock labels %}
+
+ {% endfilter %}
+
+ {% block signature scoped %}
+ {#- Signature block.
+
+ This block renders the signature for the type alias.
+ -#}
+ {% if config.separate_signature %}
+ {% filter format_type_alias(type_alias, config.line_length, crossrefs=config.signature_crossrefs) %}
+ {{ type_alias.name }}
+ {% endfilter %}
+ {% endif %}
+ {% endblock signature %}
+
+ {% else %}
+ {% if config.show_root_toc_entry %}
+ {% filter heading(heading_level,
+ role="typealias",
+ id=html_id,
+ toc_label=('
'|safe if config.show_symbol_type_toc else '') + type_alias.name,
+ hidden=True,
+ ) %}
+ {% endfilter %}
+ {% endif %}
+ {% set heading_level = heading_level - 1 %}
+ {% endif %}
+
+
- Class
+
+
+ Class
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- NestedClass
+
+
+ NestedClass
+
- Class
+
+
+ Class
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- NestedClass
+
+
+ NestedClass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- NestedClass
+
+
+ NestedClass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- NestedClass
+
+
+ NestedClass
+
- Class
+
+
+ Class
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- NestedClass
+
+
+ NestedClass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- NestedClass
+
+
+ NestedClass
+
- Class
+
+
+ Class
+
- NestedClass
+
+
+ NestedClass
+
- Subclass
+
+
+ Subclass
+
- Class
+
+
+ Class
+
- Subclass
+
+
+ Subclass
+