`
- sponsors.forEach(function (sponsor) {
- html += `
-
-
-
- `
- });
- html += '
Summary.
+Type Aliases:
+ +**Name** | **Description** +------------ | ---------------- +`TypeAlias` | Some type alias. + +TypeAliasSummary.
+//// + +//// tab | Without classes +Summary.
+TypeAliasSummary.
+//// +/// + [](){#option-show_docstring_modules} ## `show_docstring_modules` - **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** -Whether to render the "Modules" sections of docstrings. +Whether to render the "Modules" section of docstrings. ```yaml title="in mkdocs.yml (global configuration)" plugins: @@ -1245,6 +1297,57 @@ def rand() -> int: //// /// +[](){#option-show_docstring_type_parameters} +## `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 +AClassRepresents something.
+Type Parameters:
+ +**Name** | **Bound or Constraints** | **Description** | **Default** +---------- | ------------------------ | --------------- | ----------- +`whatever` | `(int, str)` | Something. | `str` +//// + +//// tab | Without parameters +AClassRepresents something.
+//// +/// + [](){#option-show_docstring_warns} ## `show_docstring_warns` diff --git a/docs/usage/configuration/general.md b/docs/usage/configuration/general.md index 973658c1..921f3b27 100644 --- a/docs/usage/configuration/general.md +++ b/docs/usage/configuration/general.md @@ -63,9 +63,6 @@ plugins: [](){#option-backlinks} ## `backlinks` -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — -[:octicons-tag-24: Insiders 1.10.0](../../insiders/changelog.md#1.10.0) - - **:octicons-package-24: TypeLiteral ["flat", "tree", False] :material-equal: `False`{ title="default value" }**
The `backlinks` option enables rendering of backlinks within your API documentation.
@@ -269,6 +266,143 @@ plugins:
WARNING: **Packages are loaded only once.** When mkdocstrings-python collects data from a Python package (thanks to [Griffe](https://mkdocstrings.github.io/griffe/)), it collects *the entire package* and *caches it*. Next time an object from the same package is rendered, the package is retrieved from the cache and not collected again. The `force_inspection` option will therefore only have an effect the first time a package is collected, and will do nothing for objects rendered afterwards.
+[](){#option-inheritance_diagram_direction}
+## `inheritance_diagram_direction`
+
+The direction of the Mermaid chart presenting the inheritance diagram of a class, `TD` by default.
+
+```yaml title="mkdocs.yml"
+extra_javascript:
+- https://unpkg.com/mermaid@10.9.0/dist/mermaid.min.js
+```
+
+```yaml title="in mkdocs.yml (global configuration)"
+plugins:
+- mkdocstrings:
+ handlers:
+ python:
+ options:
+ inheritance_diagram_direction: TD
+```
+
+```md title="or in docs/some_page.md (local configuration)"
+::: path.to.object
+ options:
+ inheritance_diagram_direction: TD
+```
+
+/// admonition | Preview
+ type: preview
+
+
+With the following classes:
+
+```python
+class SuperAbstract:
+ """Super abstract class."""
+class Mixin1:
+ """Mixin 1."""
+class Abstract(SuperAbstract, Mixin1):
+ """Abstract class."""
+class Mixin2A:
+ """Mixin 2A."""
+class Mixin2B(Mixin2A):
+ """Mixin 2B."""
+class Concrete(Abstract, Mixin2B):
+ """Concrete class."""
+class SuperConcrete(Concrete):
+ """Super concrete class."""
+```
+
+//// tab | `TD` (or `TB`)
+
+```mermaid
+flowchart TD
+SuperConcrete[SuperConcrete]
+Concrete[Concrete]
+Abstract[Abstract]
+SuperAbstract[SuperAbstract]
+Mixin1[Mixin1]
+Mixin2B[Mixin2B]
+Mixin2A[Mixin2A]
+
+Concrete --> SuperConcrete
+Abstract --> Concrete
+SuperAbstract --> Abstract
+Mixin1 --> Abstract
+Mixin2B --> Concrete
+Mixin2A --> Mixin2B
+```
+
+////
+
+//// tab | `BT`
+
+```mermaid
+flowchart BT
+SuperConcrete[SuperConcrete]
+Concrete[Concrete]
+Abstract[Abstract]
+SuperAbstract[SuperAbstract]
+Mixin1[Mixin1]
+Mixin2B[Mixin2B]
+Mixin2A[Mixin2A]
+
+Concrete --> SuperConcrete
+Abstract --> Concrete
+SuperAbstract --> Abstract
+Mixin1 --> Abstract
+Mixin2B --> Concrete
+Mixin2A --> Mixin2B
+```
+
+////
+
+//// tab | `RL`
+
+```mermaid
+flowchart RL
+SuperConcrete[SuperConcrete]
+Concrete[Concrete]
+Abstract[Abstract]
+SuperAbstract[SuperAbstract]
+Mixin1[Mixin1]
+Mixin2B[Mixin2B]
+Mixin2A[Mixin2A]
+
+Concrete --> SuperConcrete
+Abstract --> Concrete
+SuperAbstract --> Abstract
+Mixin1 --> Abstract
+Mixin2B --> Concrete
+Mixin2A --> Mixin2B
+```
+
+////
+
+//// tab | `LR`
+
+```mermaid
+flowchart LR
+SuperConcrete[SuperConcrete]
+Concrete[Concrete]
+Abstract[Abstract]
+SuperAbstract[SuperAbstract]
+Mixin1[Mixin1]
+Mixin2B[Mixin2B]
+Mixin2A[Mixin2A]
+
+Concrete --> SuperConcrete
+Abstract --> Concrete
+SuperAbstract --> Abstract
+Mixin1 --> Abstract
+Mixin2B --> Concrete
+Mixin2A --> Mixin2B
+```
+
+////
+///
+
[](){#option-preload_modules}
## `preload_modules`
@@ -366,9 +500,6 @@ plugins:
[](){#option-show_inheritance_diagram}
## `show_inheritance_diagram`
-[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } —
-[:octicons-tag-24: Insiders 1.7.0](../../insiders/changelog.md#1.7.0)
-
- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
@@ -494,3 +625,63 @@ def some_function():
Docstring of the function.
//// /// + +[](){#option-skip_local_inventory} +## `skip_local_inventory` + +- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** + + +Whether to skip registering symbols in the objects inventory. + +With this option enabled, re-rendering docstrings for objects from external inventories is possible with their cross-references pointing to the original external inventory, not local. Similarly, it becomes possible to render the same symbol several times in the same documentation, with only one canonical location being used for cross-references (preventing confusion in mkdocs-autorefs). + +```yaml title="in mkdocs.yml (global configuration)" +plugins: +- mkdocstrings: + handlers: + python: + options: + skip_local_inventory: false +``` + +```md title="or in docs/some_page.md (local configuration)" +::: path.to.module + options: + skip_local_inventory: true +``` + +/// admonition | Preview + type: preview + + +//// tab | Without `skip_local_inventory` + +```md exec="on" +::: bisect.bisect_left + options: + heading_level: 3 + skip_local_inventory: false + show_docstring_description: false +``` + +Notice how [`bisect.bisect_left`][] now points to the section above. + +//// + +//// tab | With `skip_local_inventory` + +```md exec="on" +::: bisect.bisect_right + inventories: + - https://docs.python.org/3/objects.inv + options: + heading_level: 3 + skip_local_inventory: true + show_docstring_description: false +``` + +Notice how [`bisect.bisect_right`][] points to the original Python documentation. + +//// +/// diff --git a/docs/usage/configuration/headings.md b/docs/usage/configuration/headings.md index b4314b77..593b6fb0 100644 --- a/docs/usage/configuration/headings.md +++ b/docs/usage/configuration/headings.md @@ -77,8 +77,6 @@ plugins: [](){#option-parameter_headings} ## `parameter_headings` -[:octicons-tag-24: Insiders 1.6.0](../../insiders/changelog.md#1.6.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** @@ -88,7 +86,7 @@ With this option enabled, each function/method parameter (including 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. +and an entry in the generated objects inventory (unless [`skip_local_inventory`][] is enabled). The permalink and inventory entry allow cross-references from internal and external pages. @@ -537,8 +535,6 @@ plugins: [](){#option-show_symbol_type_heading} ## `show_symbol_type_heading` -[:octicons-tag-24: Insiders 1.1.0](../../insiders/changelog.md#1.1.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** @@ -602,8 +598,6 @@ plugins: [](){#option-show_symbol_type_toc} ## `show_symbol_type_toc` -[:octicons-tag-24: Insiders 1.1.0](../../insiders/changelog.md#1.1.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** @@ -682,3 +676,135 @@ NOTE: **Use with/without `heading`.** If you use this option without specifying heading: "My fancy module" toc_label: "My fancy module" ``` + +[](){#option-type_parameter_headings} +## `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. + + + +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 + +```md exec="on" +::: package.generics + options: + show_root_heading: false + heading_level: 3 + docstring_section_style: list + show_bases: true + summary: false + separate_signature: true + show_signature_type_parameters: true + show_inheritance_diagram: false + type_parameter_headings: true +``` + +/// + +/// admonition | Preview: Type parameter sections + type: preview + +//// tab | Table style +```md exec="on" +::: package.generics.MagicBag + options: + members: false + heading_level: 3 + show_root_heading: false + show_root_toc_entry: false + parameter_headings: true + docstring_section_style: table + show_docstring_description: false + show_docstring_parameters: false + show_docstring_returns: false + show_inheritance_diagram: false +``` +//// + +//// tab | List style +```md exec="on" +::: package.generics.MagicBag + options: + members: false + heading_level: 3 + show_root_heading: false + show_root_toc_entry: false + parameter_headings: true + docstring_section_style: list + show_docstring_description: false + show_docstring_parameters: false + show_docstring_returns: false + show_inheritance_diagram: false +``` +//// + +//// tab | Spacy style +```md exec="on" +::: package.generics.MagicBag + options: + members: false + heading_level: 3 + show_root_heading: false + show_root_toc_entry: false + parameter_headings: true + docstring_section_style: spacy + show_docstring_description: false + show_docstring_parameters: false + show_docstring_returns: false + show_inheritance_diagram: false +``` +//// +/// + +/// admonition | Preview: Table of contents (with symbol types) + type: preview + + mutate U
+
+To customize symbols, see [Customizing symbol types](../customization.md/#symbol-types).
+
+///
diff --git a/docs/usage/configuration/members.md b/docs/usage/configuration/members.md
index 7a5069a1..53d955fa 100644
--- a/docs/usage/configuration/members.md
+++ b/docs/usage/configuration/members.md
@@ -269,7 +269,7 @@ class Main(Base):
The members ordering to use. Possible values:
-- `__all__` ([:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — [:octicons-tag-24: Insiders 1.12.0](../../insiders/changelog.md#1.12.0)): Order according to `__all__` attributes. Since classes do not define `__all__` attributes, you can specify a second ordering method by using a list.
+- `__all__`: Order according to `__all__` attributes. Since classes do not define `__all__` attributes, you can specify a second ordering method by using a list.
- `alphabetical`: Order by the members names.
- `source`: Order members as they appear in the source file.
@@ -351,9 +351,6 @@ A list of filters, or `"public"`.
[](){#option-filters-public}
-[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } —
-[:octicons-tag-24: Insiders 1.11.0](../../insiders/changelog.md#1.11.0)
-
The `public` filtering method will include only public objects: those added to the `__all__` attribute of modules, or not starting with a single underscore. Special methods and attributes ("dunder" methods/attributes, starting and ending with two underscores), like `__init__`, `__call__`, `__mult__`, etc., are always considered public.
**List of filters**
@@ -577,15 +574,13 @@ package
[](){#option-summary}
## `summary`
-[:octicons-tag-24: Insiders 1.2.0](../../insiders/changelog.md#1.2.0)
-
- **:octicons-package-24: Type bool | dict [str , bool ] :material-equal: `False`{ title="default value" }**
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 98c865e5..109362e3 100644
--- a/docs/usage/configuration/signatures.md
+++ b/docs/usage/configuration/signatures.md
@@ -203,12 +203,6 @@ plugins:
[](){#option-modernize_annotations}
## `modernize_annotations`
-[: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
-[Griffe Insiders](https://mkdocstrings.github.io/griffe/insiders/)
-to be installed.**
-
- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
@@ -286,6 +280,58 @@ plugins:
///
+[](){#option-overloads_only}
+## `overloads_only`
+
+- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
+
+Whether to hide the implementation signature if the overloads are shown with [`show_overloads`][].
+
+```yaml title="in mkdocs.yml (global configuration)"
+plugins:
+- mkdocstrings:
+ handlers:
+ python:
+ options:
+ overloads_only: false
+```
+
+```md title="or in docs/some_page.md (local configuration)"
+::: path.to.module
+ options:
+ overloads_only: true
+```
+
+/// admonition | Preview
+ type: preview
+//// tab | With overloads only
+Function docstring.
+//// + +//// tab | Without signature type parameters +Function docstring.
+//// +/// + [](){#option-separate_signature} ## `separate_signature` @@ -433,9 +534,54 @@ function(param1, param2=None) //// /// +[](){#option-show_attribute_values} +## `show_attribute_values` + +- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** + + +Show initial values of attributes in classes. + +```yaml title="in mkdocs.yml (global configuration)" +plugins: +- mkdocstrings: + handlers: + python: + options: + show_attribute_values: true +``` + +```md title="or in docs/some_page.md (local configuration)" +::: path.to.object + options: + show_attribute_values: true +``` + +```python title="package/module.py" +class SomeClass: + def __init__(self): + self.some_attr = 1 +``` + +/// admonition | Preview + type: preview + +//// tab | With attribute values visible +SomeClasssome_attr = 1
+//// + +//// tab | With attribute values hidden +SomeClasssome_attr
+//// +/// + [](){#option-show_overloads} ## `show_overloads` +- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** + Whether to render function / method overloads. ```yaml title="in mkdocs.yml (global configuration)" @@ -485,8 +631,6 @@ Function docstring. [](){#option-signature_crossrefs} ## `signature_crossrefs` -[:octicons-tag-24: Insiders 1.0.0](../../insiders/changelog.md#1.0.0) - Whether to render cross-references for type annotations in signatures. When signatures are separated from headings with the [`separate_signature`][] option diff --git a/docs/usage/customization.md b/docs/usage/customization.md index 8239c2e9..d1e66b31 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,22 @@ 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"; }{text}"
- return Markup(text).format(**variables) # noqa: S704
-
-
_split_path_re = re.compile(r"([.(]?)([\w]+)(\))?")
_splitable_re = re.compile(r"[().]")
@@ -416,15 +414,15 @@ def _keep_object(name: str, filters: Sequence[tuple[Pattern, bool]]) -> bool:
def _parents(obj: Alias) -> set[str]:
- parent: Object | Alias = obj.parent # type: ignore[assignment]
+ parent: Object | Alias = obj.parent
parents = {obj.path, parent.path}
if parent.is_alias:
- parents.add(parent.final_target.path) # type: ignore[union-attr]
+ parents.add(parent.final_target.path)
while parent.parent:
parent = parent.parent
parents.add(parent.path)
if parent.is_alias:
- parents.add(parent.final_target.path) # type: ignore[union-attr]
+ parents.add(parent.final_target.path)
return parents
@@ -433,7 +431,7 @@ def _remove_cycles(objects: list[Object | Alias]) -> Iterator[Object | Alias]:
for obj in objects:
if obj.is_alias:
with suppress_errors:
- if obj.final_target.path in _parents(obj): # type: ignore[arg-type,union-attr]
+ if obj.final_target.path in _parents(obj):
continue
yield obj
@@ -522,7 +520,7 @@ def _get_formatter() -> Callable[[str, int], str]:
def _get_ruff_formatter() -> Callable[[str, int], str] | None:
try:
- from ruff.__main__ import find_ruff_bin
+ from ruff.__main__ import find_ruff_bin # noqa: PLC0415
except ImportError:
return None
@@ -558,7 +556,7 @@ def formatter(code: str, line_length: int) -> str:
def _get_black_formatter() -> Callable[[str, int], str] | None:
try:
- from black import InvalidInput, Mode, format_str
+ from black import InvalidInput, Mode, format_str # noqa: PLC0415
except ModuleNotFoundError:
return None
@@ -572,39 +570,20 @@ def formatter(code: str, line_length: int) -> str:
return formatter
-# YORE: Bump 2: Remove line.
-@pass_environment
-# YORE: Bump 2: Replace `env: Environment, ` with `` within line.
-# YORE: Bump 2: Replace `str | ` with `` within line.
-def do_get_template(env: Environment, obj: str | Object) -> str:
+def do_get_template(obj: Object | Alias) -> str:
"""Get the template name used to render an object.
Parameters:
- env: The Jinja environment, passed automatically.
- obj: A Griffe object, or a template name.
+ obj: A Griffe object.
Returns:
A template name.
"""
- name = obj
- if isinstance(obj, (Alias, Object)):
- extra_data = getattr(obj, "extra", {}).get("mkdocstrings", {})
- if name := extra_data.get("template", ""):
- return name
- name = obj.kind.value
- # YORE: Bump 2: Replace block with `return f"{name}.html.jinja"`.
- try:
- template = env.get_template(f"{name}.html")
- except TemplateNotFound:
- return f"{name}.html.jinja"
- our_template = Path(template.filename).is_relative_to(Path(__file__).parent.parent) # type: ignore[arg-type]
- if our_template:
- return f"{name}.html.jinja"
- _logger.warning(
- f"DeprecationWarning: Overriding '{name}.html' is deprecated, override '{name}.html.jinja' instead. ",
- once=True,
- )
- return f"{name}.html"
+ extra_data = getattr(obj, "extra", {}).get("mkdocstrings", {})
+ if name := extra_data.get("template", ""):
+ return name
+ name = obj.kind.value.replace(" ", "_")
+ return f"{name}.html.jinja"
@pass_context
@@ -638,7 +617,7 @@ def _parse_docstring_summary(attribute: Attribute) -> str:
name=attribute.name,
description=_parse_docstring_summary(attribute),
annotation=attribute.annotation,
- value=attribute.value, # type: ignore[arg-type]
+ value=attribute.value,
)
for attribute in attributes
if not check_public or attribute.is_public
@@ -731,6 +710,34 @@ def do_as_modules_section(
)
+@pass_context
+def do_as_type_aliases_section(
+ context: Context, # noqa: ARG001
+ type_aliases: Sequence[TypeAlias],
+ *,
+ check_public: bool = True,
+) -> DocstringSectionTypeAliases:
+ """Build a type aliases section from a list of type aliases.
+
+ Parameters:
+ type_aliases: The type aliases to build the section from.
+ check_public: Whether to check if the type_alias is public.
+
+ Returns:
+ A type aliases docstring section.
+ """
+ return DocstringSectionTypeAliases(
+ [
+ DocstringTypeAlias(
+ name=type_alias.name,
+ description=type_alias.docstring.value.split("\n", 1)[0] if type_alias.docstring else "",
+ )
+ for type_alias in type_aliases
+ if not check_public or type_alias.is_public
+ ],
+ )
+
+
class AutorefsHook(AutorefsHookInterface):
"""Autorefs hook.
@@ -759,6 +766,33 @@ def expand_identifier(self, identifier: str) -> str:
Returns:
The expanded identifier.
"""
+ # Handle leading dots in the identifier:
+ # - `.name` is a reference to the current object's `name` member.
+ # - `..name` is a reference to the parent object's `name` member.
+ # - etc.
+ # TODO: We should update the protocol to allow modifying the title too.
+ # In this case it would likely be better to strip dots from the title,
+ # when it's not explicitly specified.
+ if self.config.relative_crossrefs and identifier.startswith("."): # type: ignore[attr-defined]
+ identifier = identifier[1:]
+ obj = self.current_object
+ while identifier and identifier[0] == ".":
+ identifier = identifier[1:]
+ obj = obj.parent
+ identifier = f"{obj.path}.{identifier}" if identifier else obj.path
+
+ # We resolve the identifier to its full path.
+ # For this we take out the first name, resolve it, and then append the rest.
+ if self.config.scoped_crossrefs: # type: ignore[attr-defined]
+ if "." in identifier:
+ identifier, remaining = identifier.split(".", 1)
+ else:
+ remaining = ""
+ with suppress(Exception):
+ identifier = self.current_object.resolve(identifier)
+ if remaining:
+ identifier = f"{identifier}.{remaining}"
+
return identifier
def get_context(self) -> AutorefsHookInterface.Context:
@@ -775,8 +809,8 @@ def get_context(self) -> AutorefsHookInterface.Context:
}.get(self.current_object.kind.value.lower(), "obj")
origin = self.current_object.path
try:
- filepath = self.current_object.docstring.parent.filepath # type: ignore[union-attr]
- lineno = self.current_object.docstring.lineno or 0 # type: ignore[union-attr]
+ filepath = self.current_object.docstring.parent.filepath
+ lineno = self.current_object.docstring.lineno or 0
except AttributeError:
filepath = self.current_object.filepath
lineno = 0
diff --git a/src/mkdocstrings_handlers/python/config.py b/src/mkdocstrings_handlers/python/config.py
deleted file mode 100644
index 5edab089..00000000
--- a/src/mkdocstrings_handlers/python/config.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""Deprecated. Import from `mkdocstrings_handlers.python` directly."""
-
-# YORE: Bump 2: Remove file.
-
-import warnings
-from typing import Any
-
-from mkdocstrings_handlers.python._internal import config
-
-
-def __getattr__(name: str) -> Any:
- warnings.warn(
- "Importing from `mkdocstrings_handlers.python.config` is deprecated. Import from `mkdocstrings_handlers.python` directly.",
- DeprecationWarning,
- stacklevel=2,
- )
- return getattr(config, name)
diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py
deleted file mode 100644
index 5b334860..00000000
--- a/src/mkdocstrings_handlers/python/handler.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""Deprecated. Import from `mkdocstrings_handlers.python` directly."""
-
-# YORE: Bump 2: Remove file.
-
-import warnings
-from typing import Any
-
-from mkdocstrings_handlers.python._internal import handler
-
-
-def __getattr__(name: str) -> Any:
- warnings.warn(
- "Importing from `mkdocstrings_handlers.python.handler` is deprecated. Import from `mkdocstrings_handlers.python` directly.",
- DeprecationWarning,
- stacklevel=2,
- )
- return getattr(handler, name)
diff --git a/src/mkdocstrings_handlers/python/rendering.py b/src/mkdocstrings_handlers/python/rendering.py
deleted file mode 100644
index 5cd4d200..00000000
--- a/src/mkdocstrings_handlers/python/rendering.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""Deprecated. Import from `mkdocstrings_handlers.python` directly."""
-
-# YORE: Bump 2: Remove file.
-
-import warnings
-from typing import Any
-
-from mkdocstrings_handlers.python._internal import rendering
-
-
-def __getattr__(name: str) -> Any:
- warnings.warn(
- "Importing from `mkdocstrings_handlers.python.rendering` is deprecated. Import from `mkdocstrings_handlers.python` directly.",
- DeprecationWarning,
- stacklevel=2,
- )
- return getattr(rendering, name)
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html
deleted file mode 100644
index 37c8702c..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/attribute.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/attribute.html' is deprecated, extend '_base/attribute.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja
index 519590e5..65054689 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja
@@ -40,6 +40,7 @@ Context:
id=html_id,
class="doc doc-heading",
toc_label=(' '|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else attribute.name),
+ skip_inventory=config.skip_local_inventory,
) %}
{% block heading scoped %}
@@ -55,7 +56,7 @@ Context:
{% else %}
{%+ filter highlight(language="python", inline=True) %}
{{ attribute_name }}{% if attribute.annotation and config.show_signature_annotations %}: {{ attribute.annotation }}{% endif %}
- {% if attribute.value %} = {{ attribute.value }}{% endif %}
+ {% if config.show_attribute_values and attribute.value %} = {{ attribute.value }}{% endif %}
{% endfilter %}
{% endif %}
{% endblock heading %}
@@ -66,8 +67,7 @@ Context:
This block renders the labels for the attribute.
-#}
{% with labels = attribute.labels %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "labels"|get_template with context %}
+ {% include "labels.html.jinja" with context %}
{% endwith %}
{% endblock labels %}
@@ -79,7 +79,7 @@ Context:
This block renders the signature for the attribute.
-#}
{% if config.separate_signature %}
- {% filter format_attribute(attribute, config.line_length, crossrefs=config.signature_crossrefs) %}
+ {% filter format_attribute(attribute, config.line_length, crossrefs=config.signature_crossrefs, show_value=config.show_attribute_values) %}
{{ attribute.name }}
{% endfilter %}
{% endif %}
@@ -93,6 +93,7 @@ Context:
id=html_id,
toc_label=(' '|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else attribute_name),
hidden=True,
+ skip_inventory=config.skip_local_inventory,
) %}
{% endfilter %}
{% endif %}
@@ -113,8 +114,7 @@ Context:
This block renders the docstring for the attribute.
-#}
{% with docstring_sections = attribute.docstring.parsed %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "docstring"|get_template with context %}
+ {% include "docstring.html.jinja" with context %}
{% endwith %}
{% endblock docstring %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja
index 2ab16038..930da3e8 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja
@@ -15,3 +15,52 @@ Context:
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{% endblock logs %}
+
+{% macro render_crumb(crumb, last=false) %}
+
+ {% if crumb.url and crumb.title %}
+ {{ crumb.title | safe }}
+ {% elif crumb.title %}
+ {{ crumb.title | safe }}
+ {% endif %}
+
+{% endmacro %}
+
+{% macro render_tree(tree) %}
+ '|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 %}
@@ -53,12 +57,16 @@ Context:
{{ class_name }}
{% elif config.merge_init_into_class and "__init__" in all_members %}
{% with function = all_members["__init__"] %}
- {%+ filter highlight(language="python", inline=True) -%}
- {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
- {{ class_name }}{% include "signature"|get_template with context %}
- {%- endfilter %}
+ {%+ 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 %}
@@ -69,8 +77,7 @@ Context:
This block renders the labels for the class.
-#}
{% with labels = class.labels %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "labels"|get_template with context %}
+ {% include "labels.html.jinja" with context %}
{% endwith %}
{% endblock labels %}
@@ -82,26 +89,30 @@ Context:
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 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 %}
@@ -136,8 +148,7 @@ Context:
Bases: {% for expression in class.bases -%}
{%- with backlink_type = "subclassed-by" -%}
- {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
- {%- include "expression"|get_template with context -%}
+ {%- include "expression.html.jinja" with context -%}
{%- endwith -%}
{% if not loop.last %}, {% endif %}
{% endfor -%}
@@ -145,14 +156,61 @@ Context:
{% 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 %}
+
+
+ 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 %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "docstring"|get_template with context %}
+ {% 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 #}
@@ -161,8 +219,7 @@ Context:
{% if "__init__" in check_members and check_members["__init__"].has_docstring %}
{% with function = check_members["__init__"] %}
{% with obj = function, docstring_sections = function.docstring.parsed %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "docstring"|get_template with context %}
+ {% include "docstring.html.jinja" with context %}
{% endwith %}
{% endwith %}
{% endif %}
@@ -179,8 +236,7 @@ Context:
This block renders auto-summaries for classes, methods, and attributes.
-#}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "summary"|get_template with context %}
+ {% include "summary.html.jinja" with context %}
{% endblock summary %}
{% block source scoped %}
@@ -192,8 +248,8 @@ Context:
{% if config.merge_init_into_class %}
{% if "__init__" in all_members and all_members["__init__"].source %}
{% with init = all_members["__init__"] %}
-
+
+ {{ lang.t("Source code in") }}
{%- if init.relative_filepath.is_absolute() -%}
{{ init.relative_package_filepath }}
{%- else -%}
@@ -205,8 +261,8 @@ Context:
{% endwith %}
{% endif %}
{% elif class.source %}
-
- Source code in
+
+ {{ lang.t("Source code in") }}
{%- if class.relative_filepath.is_absolute() -%}
{{ class.relative_package_filepath }}
{%- else -%}
@@ -226,8 +282,7 @@ Context:
-#}
{% set root = False %}
{% set heading_level = heading_level + 1 %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "children"|get_template with context %}
+ {% include "children.html.jinja" with context %}
{% endblock children %}
{% endblock contents %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{{ attribute.name }}
{% if attribute.annotation %}
{% with expression = attribute.annotation %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- ({% include "expression"|get_template with context %})
+ ({% include "expression.html.jinja" with context %})
{% endwith %}
{% endif %}
–
@@ -96,10 +93,9 @@ Context:
{% if attribute.annotation %}
- TYPE:
+ {{ lang.t("TYPE:") }}
{% with expression = attribute.annotation %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html
deleted file mode 100644
index 9c04b145..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/docstring/classes.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/docstring/classes.html' is deprecated, extend '_base/docstring/classes.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja
index 09a5b758..b139a761 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja
@@ -15,8 +15,7 @@ Context:
{{ log.debug("Rendering classes section") }}
{% endblock logs %}
-{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
-{% import "language"|get_template as lang with context %}
+{% import "language.html.jinja" as lang with context %}
{#- Language module providing the `t` translation method. -#}
{% if config.docstring_section_style == "table" %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html
deleted file mode 100644
index 4f66600f..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/docstring/examples.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/docstring/examples.html' is deprecated, extend '_base/docstring/examples.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja
index 09293cfb..32360f7d 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja
@@ -15,8 +15,7 @@ Context:
{{ log.debug("Rendering examples section") }}
{% endblock logs %}
-{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
-{% import "language"|get_template as lang with context %}
+{% import "language.html.jinja" as lang with context %}
{#- Language module providing the `t` translation method. -#}
{{ section.title or lang.t("Examples:") }}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html deleted file mode 100644 index 906658b4..00000000 --- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html +++ /dev/null @@ -1,10 +0,0 @@ -{# YORE: Bump 2: Remove file. #} -{% extends "_base/docstring/functions.html.jinja" %} - -{% block logs scoped %} - {{ super() }} - {{ log.warning( - "DeprecationWarning: Extending '_base/docstring/functions.html' is deprecated, extend '_base/docstring/functions.html.jinja' instead. ", - once=True, - ) }} -{% endblock logs %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja index dd33984f..afec8f60 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja @@ -15,8 +15,7 @@ Context: {{ log.debug("Rendering functions section") }} {% endblock logs %} -{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #} -{% import "language"|get_template as lang with context %} +{% import "language.html.jinja" as lang with context %} {#- Language module providing the `t` translation method. -#} {% if config.docstring_section_style == "table" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html deleted file mode 100644 index 7b0dcc51..00000000 --- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html +++ /dev/null @@ -1,10 +0,0 @@ -{# YORE: Bump 2: Remove file. #} -{% extends "_base/docstring/modules.html.jinja" %} - -{% block logs scoped %} - {{ super() }} - {{ log.warning( - "DeprecationWarning: Extending '_base/docstring/modules.html' is deprecated, extend '_base/docstring/modules.html.jinja' instead. ", - once=True, - ) }} -{% endblock logs %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja index 106e6bf6..5556cf15 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja @@ -15,8 +15,7 @@ Context: {{ log.debug("Rendering modules section") }} {% endblock logs %} -{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #} -{% import "language"|get_template as lang with context %} +{% import "language.html.jinja" as lang with context %} {#- Language module providing the `t` translation method. -#} {% if config.docstring_section_style == "table" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html deleted file mode 100644 index 02261331..00000000 --- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html +++ /dev/null @@ -1,10 +0,0 @@ -{# YORE: Bump 2: Remove file. #} -{% extends "_base/docstring/other_parameters.html.jinja" %} - -{% block logs scoped %} - {{ super() }} - {{ log.warning( - "DeprecationWarning: Extending '_base/docstring/other_parameters.html' is deprecated, extend '_base/docstring/other_parameters.html.jinja' instead. ", - once=True, - ) }} -{% endblock logs %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja index 66940069..5e0a75f5 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja @@ -15,8 +15,7 @@ Context: {{ log.debug("Rendering other parameters section") }} {% endblock logs %} -{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #} -{% import "language"|get_template as lang with context %} +{% import "language.html.jinja" as lang with context %} {#- Language module providing the `t` translation method. -#} {% if config.docstring_section_style == "table" %} @@ -38,8 +37,7 @@ Context:{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{{ parameter.name }}
{% if parameter.annotation %}
{% with expression = parameter.annotation, backlink_type = "used-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- ({% include "expression"|get_template with context %})
+ ({% include "expression.html.jinja" with context %})
{% endwith %}
{% endif %}
–
@@ -98,8 +95,7 @@ Context:
{{ lang.t("TYPE:") }}
{% with expression = parameter.annotation, backlink_type = "used-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html
deleted file mode 100644
index f5292150..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/docstring/parameters.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/docstring/parameters.html' is deprecated, extend '_base/docstring/parameters.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja
index 1035ddf7..a67113fa 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja
@@ -15,8 +15,7 @@ Context:
{{ log.debug("Rendering parameters section") }}
{% endblock logs %}
-{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
-{% import "language"|get_template as lang with context %}
+{% import "language.html.jinja" as lang with context %}
{#- Language module providing the `t` translation method. -#}
{% if config.docstring_section_style == "table" %}
@@ -43,6 +42,7 @@ Context:
id=html_id ~ "(" ~ parameter.name ~ ")",
class="doc doc-heading doc-heading-parameter",
toc_label=(' '|safe if config.show_symbol_type_toc else '') + parameter.name,
+ skip_inventory=config.skip_local_inventory,
) %}
{{ parameter.name }}
{% endfilter %}
@@ -53,8 +53,7 @@ Context:
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% else %}
{{ lang.t("required") }}
@@ -92,6 +90,7 @@ Context:
id=html_id ~ "(" ~ parameter.name ~ ")",
class="doc doc-heading doc-heading-parameter",
toc_label=(' '|safe if config.show_symbol_type_toc else '') + parameter.name,
+ skip_inventory=config.skip_local_inventory,
) %}
{{ parameter.name }}
{% endfilter %}
@@ -100,12 +99,10 @@ Context:
{% endif %}
{% if parameter.annotation %}
{% with expression = parameter.annotation, backlink_type = "used-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- ({% include "expression"|get_template with context %}
+ ({% include "expression.html.jinja" with context %}
{%- if parameter.default %}, {{ lang.t("default:") }}
{% with expression = parameter.default, backlink_type = "used-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %})
{% endwith %}
@@ -139,6 +136,7 @@ Context:
id=html_id ~ "(" ~ parameter.name ~ ")",
class="doc doc-heading doc-heading-parameter",
toc_label=(' '|safe if config.show_symbol_type_toc else '') + parameter.name,
+ skip_inventory=config.skip_local_inventory,
) %}
{{ parameter.name }}
{% endfilter %}
@@ -155,8 +153,7 @@ Context:
{{ lang.t("TYPE:") }}
{% with expression = parameter.annotation, backlink_type = "used-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
@@ -164,8 +161,7 @@ Context:
{{ lang.t("DEFAULT:") }}
{% with expression = parameter.default, backlink_type = "used-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html
deleted file mode 100644
index 38a21e89..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/docstring/raises.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/docstring/raises.html' is deprecated, extend '_base/docstring/raises.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja
index cd034c0e..7d548035 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja
@@ -15,8 +15,7 @@ Context:
{{ log.debug("Rendering raises section") }}
{% endblock logs %}
-{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
-{% import "language"|get_template as lang with context %}
+{% import "language.html.jinja" as lang with context %}
{#- Language module providing the `t` translation method. -#}
{% if config.docstring_section_style == "table" %}
@@ -36,8 +35,7 @@ Context:
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
–
{% endif %}
@@ -88,8 +85,7 @@ Context:
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% if receives.name %}){% endif %}
{% endwith %}
{% endif %}
@@ -97,8 +94,7 @@ Context:
{% elif receives.annotation %}
{% with expression = receives.annotation, backlink_type = "received-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
@@ -112,8 +108,7 @@ Context:
{{ lang.t("TYPE:") }}
{% with expression = receives.annotation, backlink_type = "received-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html
deleted file mode 100644
index b608af5f..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/docstring/returns.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/docstring/returns.html' is deprecated, extend '_base/docstring/returns.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja
index bc8ee4ff..da693da7 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja
@@ -15,8 +15,7 @@ Context:
{{ log.debug("Rendering returns section") }}
{% endblock logs %}
-{# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
-{% import "language"|get_template as lang with context %}
+{% import "language.html.jinja" as lang with context %}
{#- Language module providing the `t` translation method. -#}
{% if config.docstring_section_style == "table" %}
@@ -39,8 +38,7 @@ Context:
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% if returns.name %}){% endif %}
{% endwith %}
{% endif %}
@@ -97,8 +94,7 @@ Context:
{% elif returns.annotation %}
{% with expression = returns.annotation, backlink_type = "returned-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
@@ -112,8 +108,7 @@ Context:
{{ lang.t("TYPE:") }}
{% with expression = returns.annotation, backlink_type = "returned-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html.jinja
new file mode 100644
index 00000000..e1c87754
--- /dev/null
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html.jinja
@@ -0,0 +1,86 @@
+{#- Template for "Type Aliases" sections in docstrings.
+
+This template renders a list of documented type aliases in the format
+specified with the [`docstring_section_style`][] configuration option.
+
+Context:
+ section (griffe.DocstringSectionTypeAliases): The section to render.
+-#}
+
+{% block logs scoped %}
+ {#- Logging block.
+
+ This block can be used to log debug messages, deprecation messages, warnings, etc.
+ -#}
+ {{ log.debug("Rendering type aliases section") }}
+{% endblock logs %}
+
+{% import "language.html.jinja" as lang with context %}
+{#- Language module providing the `t` translation method. -#}
+
+{% if config.docstring_section_style == "table" %}
+ {% block table_style scoped %}
+ {#- Block for the `table` section style. -#}
+ {{ 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(("Class " if obj.is_class else "Init " if obj.is_init_method else "") ~ "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.html.jinja" 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.html.jinja" with context %}
+ {% endwith %}
+ {% else %}
+ {{ lang.t("required") }}
+ {% endif %}
+ |
+
+ + {{ section.title or lang.t(("Class " if obj.is_class else "Init " if obj.is_init_method else "") ~ "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.bound or type_parameter.constraints or type_parameter.default -%}
+ (
+ {%- endif -%}
+ {%- if type_parameter.bound -%}
+ {%- with expression = type_parameter.bound -%}
+ {% include "expression.html.jinja" with context %}
+ {%- endwith -%}
+ {%- if type_parameter.default %}, {% endif -%}
+ {%- elif type_parameter.constraints -%}
+ {%- for expression in type_parameter.constraints -%}
+ {% include "expression.html.jinja" with context %}
+ {%- if not loop.last %}, {% endif -%}
+ {%- endfor -%}
+ {%- if type_parameter.default %}, {% endif -%}
+ {%- endif -%}
+ {%- if type_parameter.default -%}
+ {{ lang.t("default:") }}
+ {% with expression = type_parameter.default %}
+ {% include "expression.html.jinja" with context %}
+ {%- endwith -%}
+ {%- endif -%}
+ {%- if type_parameter.constraints or type_parameter.default -%}
+ )
+ {% endif -%}
+ –
+ | + + {{ (section.title or lang.t(("CLASS " if obj.is_class else "INIT " if obj.is_init_method else "") ~ "TYPE PARAMETER")).rstrip(":").upper() }} + + | +{{ 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 -%}
+ |
+
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
–
{% endif %}
@@ -88,8 +85,7 @@ Context:
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
{% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% if yields.name %}){% endif %}
{% endwith %}
{% endif %}
@@ -97,8 +94,7 @@ Context:
{% elif yields.annotation %}
{% with expression = yields.annotation, backlink_type = "yielded-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
{% endif %}
@@ -112,8 +108,7 @@ Context:
{{ lang.t("TYPE:") }}:
{% with expression = yields.annotation, backlink_type = "yielded-by" %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "expression"|get_template with context %}
+ {% include "expression.html.jinja" with context %}
{% endwith %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html
deleted file mode 100644
index 8c84928c..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/expression.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/expression.html' is deprecated, extend '_base/expression.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja
index d49e43be..4f44ae00 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja
@@ -2,6 +2,10 @@
This template renders a Griffe expression,
which is a tree-like structure representing a Python expression.
+
+Context:
+ expression (griffe.Expr): The expression to render.
+ config (dict): The configuration options.
-#}
{% block logs scoped %}
@@ -16,6 +20,25 @@ which is a tree-like structure representing a Python expression.
This macro outputs a cross-reference to the given name.
+ Parameters:
+ name (griffe.ExprName): The name to cross-reference.
+ annotation_path (str): Either "brief", "source", or "full".
+
+ Returns:
+ Either a cross-reference (using an autoref element) or the name itself.
+ -#}
+ {%- if name.classname == "ExprName" and name.is_type_parameter -%}
+ {{ type_param_crossref(name) }}
+ {%- else -%}
+ {{ object_crossref(name, annotation_path) }}
+ {%- endif -%}
+{%- endmacro -%}
+
+{%- macro object_crossref(name, annotation_path) -%}
+ {#- Output a cross-reference to a Griffe object.
+
+ This macro outputs a cross-reference to the given name.
+
Parameters:
name (griffe.ExprName): The name to cross-reference.
annotation_path (str): Either "brief", "source", or "full".
@@ -50,6 +73,26 @@ which is a tree-like structure representing a Python expression.
{%- endwith -%}
{%- endmacro -%}
+{%- macro type_param_crossref(name) -%}
+ {#- Render a cross-reference to a type parameter heading.
+
+ Parameters:
+ name (griffe.ExprName): The name to cross-reference.
+
+ Returns:
+ The autorefs cross-reference, or the type parameter name.
+ -#}
+ {%- if not signature -%}
+ ')|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else function.name),
+ skip_inventory=config.skip_local_inventory,
) %}
{% block heading scoped %}
@@ -60,8 +60,9 @@ Context:
{{ function_name }}
{% else %}
{%+ filter highlight(language="python", inline=True) -%}
- {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
- {{ function_name }}{% include "signature"|get_template with context %}
+ {{ function_name }}
+ {%- include "type_parameters.html.jinja" with context -%}
+ {%- include "signature.html.jinja" with context -%}
{%- endfilter %}
{% endif %}
{% endblock heading %}
@@ -72,8 +73,7 @@ Context:
This block renders the labels for the function.
-#}
{% with labels = function.labels %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "labels"|get_template with context %}
+ {% include "labels.html.jinja" with context %}
{% endwith %}
{% endblock labels %}
@@ -94,7 +94,7 @@ Context:
{% endfor %}
')|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else function.name),
hidden=True,
+ skip_inventory=config.skip_local_inventory,
) %}
{% endfilter %}
{% endif %}
@@ -130,8 +131,7 @@ Context:
This block renders the docstring for the function.
-#}
{% with docstring_sections = function.docstring.parsed %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "docstring"|get_template with context %}
+ {% include "docstring.html.jinja" with context %}
{% endwith %}
{% endblock docstring %}
@@ -145,7 +145,7 @@ Context:
This block renders the source code for the function.
-#}
{% if config.show_source and function.source %}
-
{%- if function.relative_filepath.is_absolute() -%}
{{ function.relative_package_filepath }}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/labels.html b/src/mkdocstrings_handlers/python/templates/material/_base/labels.html
deleted file mode 100644
index cda79114..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/labels.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/labels.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/labels.html' is deprecated, extend '_base/labels.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/language.html b/src/mkdocstrings_handlers/python/templates/material/_base/language.html
deleted file mode 100644
index a5a86545..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/language.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/language.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/language.html' is deprecated, extend '_base/language.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/language.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/language.html.jinja
index 5a4b773e..31ecfdd6 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/language.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/language.html.jinja
@@ -7,15 +7,12 @@
-#}
{% endblock logs %}
-{# YORE: Bump 2: Replace `| get_template` with `~ ".html.jinja"` within line. #}
-{% set lang_pth = "languages/" ~ locale | get_template %}
+{% set lang_pth = "languages/" ~ locale ~ ".html.jinja" %}
{% if lang_pth is existing_template %}
{% import lang_pth as lang %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% import "languages/en"|get_template as fallback %}
+ {% import "languages/en.html.jinja" as fallback %}
{% macro t(key) %}{{ lang.t(key) or fallback.t(key) }}{% endmacro %}
{% else %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% import "languages/en"|get_template as lang %}
+ {% import "languages/en.html.jinja" as lang %}
{% macro t(key) %}{{ lang.t(key) }}{% endmacro %}
{% endif %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html b/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html
deleted file mode 100644
index 2f050a32..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/languages/en.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/languages/en.html' is deprecated, extend '_base/languages/en.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja
index bcdcce2d..d2bbba03 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja
@@ -9,19 +9,30 @@
{% macro t(key) %}{{ {
"ATTRIBUTE": "ATTRIBUTE",
+ "Attributes": "Attributes",
"Attributes:": "Attributes:",
+ "BOUND:": "BOUND:",
+ "Bound or Constraints": "Bound or Constraints",
+ "Classes": "Classes",
"Classes:": "Classes:",
+ "Class Type Parameters:": "Class Type Parameters:",
+ "CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
"CLASS": "CLASS",
+ "CONSTRAINTS:": "CONSTRAINTS:",
"DEFAULT:": "DEFAULT:",
"Default": "Default",
"default:": "default:",
"DESCRIPTION": "DESCRIPTION",
"Description": "Description",
"Examples:": "Examples:",
+ "Functions": "Functions",
"Functions:": "Functions:",
"FUNCTION": "FUNCTION",
+ "Init Type Parameters:": "Init Type Parameters:",
+ "INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
"Methods:": "Methods:",
"METHOD": "METHOD",
+ "Modules": "Modules",
"Modules:": "Modules:",
"MODULE": "MODULE",
"Name": "Name",
@@ -38,6 +49,11 @@
"Source code in": "Source code in",
"TYPE:": "TYPE:",
"Type": "Type",
+ "Type Aliases": "Type Aliases",
+ "Type Aliases:": "Type Aliases:",
+ "TYPE ALIAS": "TYPE ALIAS",
+ "Type Parameters:": "Type Parameters:",
+ "TYPE PARAMETER": "TYPE PARAMETER",
"WARNS": "WARNS",
"Warns:": "Warns:",
"YIELDS": "YIELDS",
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html b/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html
deleted file mode 100644
index 1f3095f4..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/languages/ja.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/languages/ja.html' is deprecated, extend '_base/languages/ja.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja
index 0393ca03..840da89c 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja
@@ -9,19 +9,30 @@
{% macro t(key) %}{{ {
"ATTRIBUTE": "属性",
+ "Attributes": "属性",
"Attributes:": "属性:",
+ "BOUND:": "境界:",
+ "Bound or Constraints": "境界や制約",
+ "Classes": "クラス",
"Classes:": "クラス:",
+ "Class Type Parameters:": "Class Type Parameters:",
+ "CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
"CLASS": "クラス",
+ "CONSTRAINTS:": "制約:",
"DEFAULT:": "デフォルト:",
"Default": "デフォルト",
"default:": "デフォルト:",
"DESCRIPTION": "デスクリプション",
"Description": "デスクリプション",
"Examples:": "例:",
+ "Functions": "関数",
"Functions:": "関数:",
"FUNCTION": "関数",
+ "Init Type Parameters:": "Init Type Parameters:",
+ "INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
"Methods:": "メソッド:",
"METHOD": "メソッド",
+ "Modules": "モジュール",
"Modules:": "モジュール:",
"MODULE": "モジュール",
"Name": "名前",
@@ -38,6 +49,11 @@
"Source code in": "ソースコード位置:",
"TYPE:": "タイプ:",
"Type": "タイプ",
+ "Type Aliases": "型エイリアス",
+ "Type Aliases:": "型エイリアス:",
+ "TYPE ALIAS": "型エイリアス",
+ "Type Parameters:": "型パラメータ:",
+ "TYPE PARAMETER": "型パラメータ",
"WARNS": "警告",
"Warns:": "警告:",
"YIELDS": "返す",
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html b/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html
deleted file mode 100644
index b58b0479..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/languages/zh.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/languages/zh.html' is deprecated, extend '_base/languages/zh.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja
index e57169ad..53888779 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja
@@ -9,19 +9,30 @@
{% macro t(key) %}{{ {
"ATTRIBUTE": "属性",
+ "Attributes": "属性",
"Attributes:": "属性:",
+ "BOUND:": "边界:",
+ "Bound or Constraints": "边界或约束",
+ "Classes": "类",
"Classes:": "类:",
+ "Class Type Parameters:": "Class Type Parameters:",
+ "CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
"CLASS": "类",
+ "CONSTRAINTS:": "约束:",
"DEFAULT:": "默认:",
"Default": "默认",
"default:": "默认:",
"DESCRIPTION": "描述",
"Description": "描述",
"Examples:": "示例:",
+ "Functions": "函数",
"Functions:": "函数:",
"FUNCTION": "函数",
+ "Init Type Parameters:": "Init Type Parameters:",
+ "INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
"Methods:": "方法:",
"METHOD": "方法",
+ "Modules": "模块",
"Modules:": "模块:",
"MODULE": "模块",
"Name": "名称",
@@ -38,6 +49,11 @@
"Source code in": "源代码位于:",
"TYPE:": "类型:",
"Type": "类型",
+ "Type Aliases": "类型别名",
+ "Type Aliases:": "类型别名:",
+ "TYPE ALIAS": "类型别名",
+ "Type Parameters:": "类型形参:",
+ "TYPE PARAMETER": "类型形参",
"Warns:": "警告:",
"WARNS": "警告",
"YIELDS": "产生",
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/module.html b/src/mkdocstrings_handlers/python/templates/material/_base/module.html
deleted file mode 100644
index dcda15ea..00000000
--- a/src/mkdocstrings_handlers/python/templates/material/_base/module.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{# YORE: Bump 2: Remove file. #}
-{% extends "_base/module.html.jinja" %}
-
-{% block logs scoped %}
- {{ super() }}
- {{ log.warning(
- "DeprecationWarning: Extending '_base/module.html' is deprecated, extend '_base/module.html.jinja' instead. ",
- once=True,
- ) }}
-{% endblock logs %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/module.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/module.html.jinja
index 283f2654..c0f4a7cb 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/module.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/module.html.jinja
@@ -39,6 +39,7 @@ Context:
id=html_id,
class="doc doc-heading",
toc_label=(' '|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else module.name),
+ skip_inventory=config.skip_local_inventory,
) %}
{% block heading scoped %}
@@ -62,8 +63,7 @@ Context:
This block renders the labels for the module.
-#}
{% with labels = module.labels %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "labels"|get_template with context %}
+ {% include "labels.html.jinja" with context %}
{% endwith %}
{% endblock labels %}
@@ -76,6 +76,7 @@ Context:
id=html_id,
toc_label=(' '|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else module.name),
hidden=True,
+ skip_inventory=config.skip_local_inventory,
) %}
{% endfilter %}
{% endif %}
@@ -96,8 +97,7 @@ Context:
This block renders the docstring for the module.
-#}
{% with docstring_sections = module.docstring.parsed %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "docstring"|get_template with context %}
+ {% include "docstring.html.jinja" with context %}
{% endwith %}
{% endblock docstring %}
@@ -110,8 +110,7 @@ Context:
This block renders auto-summaries for classes, methods, and attributes.
-#}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "summary"|get_template with context %}
+ {% include "summary.html.jinja" with context %}
{% endblock summary %}
{% block children scoped %}
@@ -121,8 +120,7 @@ Context:
-#}
{% set root = False %}
{% set heading_level = heading_level + 1 %}
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
- {% include "children"|get_template with context %}
+ {% include "children.html.jinja" with context %}
{% endblock children %}
{% endblock contents %}
'|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.html.jinja" 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.html.jinja" 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 %}
+
+ '|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 %}
+
+
+ Bases: {% for expression in class.bases -%}
+ {% include "expression.html.jinja" with context %}{% if not loop.last %}, {% endif %}
+ {% endfor -%}
+
+ {%- 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 -%}
+