diff --git a/docs/usage/configuration/docstrings.md b/docs/usage/configuration/docstrings.md index ae925f23..13c396f4 100644 --- a/docs/usage/configuration/docstrings.md +++ b/docs/usage/configuration/docstrings.md @@ -804,6 +804,64 @@ class Class: //// /// +[](){#option-show_docstring_type_aliases} +## `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 +

module

+

Summary.

+

Type Aliases:

+ +**Name** | **Description** +------------ | ---------------- +`TypeAlias` | Some type alias. + +

TypeAlias

+

Summary.

+//// + +//// tab | Without classes +

module

+

Summary.

+

TypeAlias

+

Summary.

+//// +/// + [](){#option-show_docstring_modules} ## `show_docstring_modules` @@ -1245,6 +1303,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 +

AClass

+

Represents something.

+

Type Parameters:

+ +**Name** | **Bound or Constraints** | **Description** | **Default** +---------- | ------------------------ | --------------- | ----------- +`whatever` | `(int, str)` | Something. | `str` +//// + +//// tab | Without parameters +

AClass

+

Represents something.

+//// +/// + [](){#option-show_docstring_warns} ## `show_docstring_warns` diff --git a/docs/usage/configuration/headings.md b/docs/usage/configuration/headings.md index 0c253f1f..24bf3770 100644 --- a/docs/usage/configuration/headings.md +++ b/docs/usage/configuration/headings.md @@ -197,6 +197,286 @@ To customize symbols, see [Customizing symbol types](../customization.md/#symbol /// +[](){#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. + +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 + ¤ +

+
+
set_element[T](element: T) -> None
+
+
+
+

Set element.

+

Parameters:

+ +

Type Parameters:

+ +
+
+ +/// + +/// admonition | Preview: Type parameters sections + type: preview + +//// tab | Table style +
+
+

Parameters:

+
+
+ + + + + + + + + + + + + + + + + +
NameTypeDescriptionDefault
+

+ element + ¤ +

+
+ T + +
+

The element to set.

+
+
+ required +
+
+
+

Type Parameters:

+
+
+ + + + + + + + + + + + + + + + + +
NameBound or ConstraintsDescriptionDefault
+

T + ¤ +

+
+ +
+

The type of the element.

+
+
+ required +
+
+
+
+
+//// + +//// tab | List style +
+
+

Parameters:

+ +

Type Parameters:

+ +
+
+//// + +//// tab | Spacy style +
+
+
+
+ + + + + + + + + + + + + +
PARAMETERDESCRIPTION
+

+ element + ¤ +

+
+
+

The element to set.

+
+

+ + TYPE: + T + +

+
+
+
+
+
+ + + + + + + + + + + + + +
TYPE PARAMETERDESCRIPTION
+

T + ¤ +

+
+
+

The type of the element.

+
+

+

+
+
+
+
+
+//// +/// + +/// admonition | Preview: Table of contents (with symbol types) + type: preview + + set_element
+ T + +To customize symbols, see [Customizing symbol types](../customization.md/#symbol-types). + +/// + [](){#option-show_root_heading} ## `show_root_heading` diff --git a/docs/usage/configuration/members.md b/docs/usage/configuration/members.md index 7a5069a1..3c344221 100644 --- a/docs/usage/configuration/members.md +++ b/docs/usage/configuration/members.md @@ -585,7 +585,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 c49cd181..0dabf74f 100644 --- a/docs/usage/configuration/signatures.md +++ b/docs/usage/configuration/signatures.md @@ -430,6 +430,61 @@ function(param1, param2=None) //// /// +[](){#option-show_signature_type_parameters} +## `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

+ +```python +function[T, *R](param: T) -> tuple[*R] +``` + +

Function docstring.

+//// + +//// tab | Without signature type parameters +

function

+ +```python +function(param: T) -> tuple[*R] +``` + +

Function docstring.

+//// +/// + [](){#option-separate_signature} ## `separate_signature` diff --git a/docs/usage/customization.md b/docs/usage/customization.md index 8239c2e9..26fe789b 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"; } @@ -324,6 +364,19 @@ Available context: - `config`: The handler configuration (dictionary). - `module`: The [Module][griffe.Module] instance. +#### `type_alias.html` + +- `heading`: The class heading. +- `labels`: The class labels. +- `signature`: The class signature. +- `contents`: The class contents: bases, docstring, source and children blocks. +- `docstring`: The class docstring. + +Available context: + +- `config`: The handler configuration (dictionary). +- `type_alias`: The [TypeAlias][griffe.TypeAlias] instance. + #### `class.html` - `heading`: The class heading. @@ -379,6 +432,8 @@ In `docstring/attributes.html`, `docstring/raises.html`, `docstring/receives.html`, `docstring/returns.html`, +`docstring/type_aliases.html`, +`docstring/type_parameters.html`, `docstring/warns.html`, and `docstring/yields.html`: diff --git a/mkdocs.yml b/mkdocs.yml index 0199ea9a..0796e003 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -166,6 +166,7 @@ plugins: line_length: 88 merge_init_into_class: true parameter_headings: true + type_parameter_headings: true preload_modules: [mkdocstrings] relative_crossrefs: true scoped_crossrefs: true @@ -175,6 +176,7 @@ plugins: show_root_heading: true show_root_full_path: false show_signature_annotations: true + show_signature_type_parameters: true show_source: false show_symbol_type_heading: true show_symbol_type_toc: true diff --git a/src/mkdocstrings_handlers/python/_internal/config.py b/src/mkdocstrings_handlers/python/_internal/config.py index 952fc159..62c124ba 100644 --- a/src/mkdocstrings_handlers/python/_internal/config.py +++ b/src/mkdocstrings_handlers/python/_internal/config.py @@ -423,6 +423,15 @@ class SummaryOption: ), ] = False + type_aliases: Annotated[ + bool, + _Field( + group="members", + parent="summary", + description="Whether to render summaries of type aliases.", + ), + ] = False + # YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. @dataclass(**_dataclass_options) # type: ignore[call-overload] @@ -797,6 +806,22 @@ class PythonInputOptions: ), ] = True + show_docstring_type_aliases: Annotated[ + bool, + _Field( + group="docstrings", + description="Whether to display the 'Type Aliases' section in the object's docstring.", + ), + ] = True + + show_docstring_type_parameters: Annotated[ + bool, + _Field( + group="docstrings", + description="Whether to display the 'Type Parameters' section in the object's docstring.", + ), + ] = True + show_docstring_warns: Annotated[ bool, _Field( @@ -888,6 +913,14 @@ class PythonInputOptions: ), ] = False + show_signature_type_parameters: Annotated[ + bool, + _Field( + group="signatures", + description="Show the type parameters in generic classes, methods, functions and type aliases signatures.", + ), + ] = False + show_signature: Annotated[ bool, _Field( @@ -960,6 +993,14 @@ class PythonInputOptions: ), ] = "" + type_parameter_headings: Annotated[ + bool, + _Field( + group="headings", + description="Whether to render headings for type parameters (therefore showing type parameters in the ToC).", + ), + ] = False + unwrap_annotated: Annotated[ bool, _Field( @@ -1001,9 +1042,15 @@ def coerce(cls, **data: Any) -> MutableMapping[str, Any]: if "summary" in data: summary = data["summary"] if summary is True: - summary = SummaryOption(attributes=True, functions=True, classes=True, modules=True) + summary = SummaryOption(attributes=True, functions=True, classes=True, modules=True, type_aliases=True) elif summary is False: - summary = SummaryOption(attributes=False, functions=False, classes=False, modules=False) + summary = SummaryOption( + attributes=False, + functions=False, + classes=False, + modules=False, + type_aliases=False, + ) else: summary = SummaryOption(**summary) data["summary"] = summary @@ -1028,7 +1075,7 @@ class PythonOptions(PythonInputOptions): # type: ignore[override,unused-ignore] """A list of filters, or `"public"`.""" summary: SummaryOption = field(default_factory=SummaryOption) - """Whether to render summaries of modules, classes, functions (methods) and attributes.""" + """Whether to render summaries of modules, classes, functions (methods), attributes and type aliases.""" @classmethod def coerce(cls, **data: Any) -> MutableMapping[str, Any]: diff --git a/src/mkdocstrings_handlers/python/_internal/handler.py b/src/mkdocstrings_handlers/python/_internal/handler.py index 8bc40d27..313b17ba 100644 --- a/src/mkdocstrings_handlers/python/_internal/handler.py +++ b/src/mkdocstrings_handlers/python/_internal/handler.py @@ -322,12 +322,14 @@ def update_env(self, config: Any) -> None: # noqa: ARG002 self.env.filters["format_code"] = rendering.do_format_code self.env.filters["format_signature"] = rendering.do_format_signature self.env.filters["format_attribute"] = rendering.do_format_attribute + self.env.filters["format_type_alias"] = rendering.do_format_type_alias self.env.filters["filter_objects"] = rendering.do_filter_objects self.env.filters["stash_crossref"] = rendering.do_stash_crossref self.env.filters["get_template"] = rendering.do_get_template self.env.filters["as_attributes_section"] = rendering.do_as_attributes_section self.env.filters["as_functions_section"] = rendering.do_as_functions_section self.env.filters["as_classes_section"] = rendering.do_as_classes_section + self.env.filters["as_type_aliases_section"] = rendering.do_as_type_aliases_section self.env.filters["as_modules_section"] = rendering.do_as_modules_section self.env.filters["backlink_tree"] = rendering.do_backlink_tree self.env.globals["AutorefsHook"] = rendering.AutorefsHook diff --git a/src/mkdocstrings_handlers/python/_internal/rendering.py b/src/mkdocstrings_handlers/python/_internal/rendering.py index 0e5f3d39..9350d016 100644 --- a/src/mkdocstrings_handlers/python/_internal/rendering.py +++ b/src/mkdocstrings_handlers/python/_internal/rendering.py @@ -10,7 +10,6 @@ import warnings from collections import defaultdict from contextlib import suppress -from dataclasses import replace from functools import lru_cache from pathlib import Path from re import Match, Pattern @@ -28,7 +27,10 @@ DocstringSectionClasses, DocstringSectionFunctions, DocstringSectionModules, + DocstringSectionTypeAliases, + DocstringTypeAlias, Object, + TypeAlias, ) from jinja2 import TemplateNotFound, pass_context, pass_environment from markupsafe import Markup @@ -160,16 +162,20 @@ def do_format_signature( The same code, formatted. """ env = context.environment - # YORE: Bump 2: Replace `do_get_template(env, "signature")` with `"signature.html.jinja"` within line. - template = env.get_template(do_get_template(env, "signature")) + # TODO: Stop using `do_get_template` when `*.html` templates are removed. + type_params_template = env.get_template(do_get_template(env, "type_parameters")) + signature_template = env.get_template(do_get_template(env, "signature")) if annotations is None: new_context = context.parent else: new_context = dict(context.parent) - new_context["config"] = replace(new_context["config"], show_signature_annotations=annotations) + new_context["config"] = dict(new_context["config"]) + new_context["config"]["show_signature_annotations"] = annotations + + signature = type_params_template.render(context.parent, obj=function, signature=True) + signature += signature_template.render(new_context, function=function, signature=True) - signature = template.render(new_context, function=function, signature=True) signature = _format_signature(callable_path, signature, line_length) signature = str( env.filters["highlight"]( @@ -185,12 +191,10 @@ def do_format_signature( # Pygments sees it as a function call and not a function definition. # The result is that the function name is not parsed as such, # but instead as a regular name: `n` CSS class instead of `nf`. - # When the function name is a known special name like `__exit__`, - # Pygments will set an `fm` (function -> magic) CSS class. - # To fix this, we replace the CSS class in the first span with `nf`, - # unless we already found an `nf` span. - if not re.search(r'', signature): - signature = re.sub(r'', '', signature, count=1) + # To fix it, we replace the first occurrence of an `n` CSS class + # with an `nf` one, unless we found `nf` already. + if signature.find('class="nf"') == -1: + signature = signature.replace('class="n"', 'class="nf"', 1) if stash := env.filters["stash_crossref"].stash: for key, value in stash.items(): @@ -259,6 +263,66 @@ def do_format_attribute( return signature +@pass_context +def do_format_type_alias( + context: Context, + type_alias_path: Markup, + type_alias: TypeAlias, + line_length: int, + *, + crossrefs: bool = False, # noqa: ARG001 +) -> str: + """Format a type alias. + + Parameters: + context: Jinja context, passed automatically. + type_alias_path: The path of the type alias we render the signature of. + type_alias: The type alias we render the signature of. + line_length: The line length. + crossrefs: Whether to cross-reference types in the signature. + + Returns: + The same code, formatted. + """ + env = context.environment + # TODO: Stop using `do_get_template` when `*.html` templates are removed. + type_params_template = env.get_template(do_get_template(env, "type_parameters")) + expr_template = env.get_template(do_get_template(env, "expression")) + + signature = str(type_alias_path).strip() + signature += type_params_template.render(context.parent, obj=type_alias, signature=True) + value = expr_template.render(context.parent, expression=type_alias.value, signature=True) + signature += f" = {value}" + + signature = do_format_code(signature, line_length) + signature = str( + env.filters["highlight"]( + Markup.escape(signature), + language="python", + inline=False, + classes=["doc-signature"], + linenums=False, + ), + ) + + # Since we highlight the signature without `type`, + # Pygments sees only an assignment, not a type alias definition. + # (At the moment it does not understand type alias definitions anyway) + # The result is that the type alias name is not parsed as such, + # but instead as a regular name: `n` CSS class instead of `nc`. + # To fix it, we replace the first occurrence of an `n` CSS class + # with an `nc` one, unless we found `nc` already. + if signature.find('class="nc"') == -1: + signature = signature.replace('class="n"', 'class="nc"', 1) + + if stash := env.filters["stash_crossref"].stash: + for key, value in stash.items(): + signature = re.sub(rf"\b{key}\b", value, signature) + stash.clear() + + return signature + + def do_order_members( members: Sequence[Object | Alias], order: Order | list[Order], @@ -592,7 +656,7 @@ def do_get_template(env: Environment, obj: str | Object) -> str: extra_data = getattr(obj, "extra", {}).get("mkdocstrings", {}) if name := extra_data.get("template", ""): return name - name = obj.kind.value + name = obj.kind.value.replace(" ", "_") # YORE: Bump 2: Replace block with `return f"{name}.html.jinja"`. try: template = env.get_template(f"{name}.html") @@ -732,6 +796,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. diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja index 0538aa9a..93d26035 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja @@ -57,6 +57,26 @@ Context: {% endif %} {% endwith %} + {% with type_aliases = 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, + ) %} + {% if type_aliases %} + {% if config.show_category_heading %} + {% filter heading(heading_level, id=html_id ~ "-type_aliases") %}Type Aliases{% endfilter %} + {% endif %} + {% with heading_level = heading_level + extra_level %} + {% for type_alias in type_aliases|order_members(config.members_order, members_list) %} + {% if members_list is not none or (not type_alias.is_imported or type_alias.is_public) %} + {% include type_alias|get_template with context %} + {% endif %} + {% endfor %} + {% endwith %} + {% endif %} + {% endwith %} + {% with classes = obj.classes|filter_objects( filters=config.filters, members_list=members_list, @@ -143,6 +163,11 @@ Context: {% include attribute|get_template with context %} {% endwith %} + {% elif child.is_type_alias %} + {% with type_alias = child %} + {% include type_alias|get_template with context %} + {% endwith %} + {% elif child.is_class %} {% with class = child %} {% include class|get_template with context %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja index f366f497..c7ef1b58 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja @@ -54,13 +54,24 @@ 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 -}} + {%- if config.show_signature_annotations and config.show_signature_type_parameters -%} + {# TODO: Merge type parameters instead of concatenating them. #} + {%- include "type_parameters"|get_template with context -%} + {% if function.is_generic %} + {%- with obj = function -%} + {%- include "type_parameters"|get_template with context -%} + {%- endwith -%} + {%- endif -%} + {%- 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 %} @@ -83,26 +94,31 @@ 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 %} -
- {% for overload in function.overloads %} - {% filter format_signature(overload, config.line_length, annotations=True, crossrefs=config.signature_crossrefs) %} - {{ class.name }} - {% endfilter %} - {% endfor %} -
- {% endif %} - {% if config.separate_signature %} - {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} - {{ class.name }} - {% endfilter %} - {% endif %} - {% endwith %} - {% endif %} + {# TODO: Merge type parameters of class and its `__init__` method. #} + {% if config.merge_init_into_class and "__init__" in all_members %} + {% with function = all_members["__init__"] %} + {% if function.overloads and config.show_overloads %} +
+ {% for overload in function.overloads %} + {% filter format_signature(overload, config.line_length, annotations=True, crossrefs=config.signature_crossrefs) %} + {{ class.name }} + {% endfilter %} + {% endfor %} +
+ {% endif %} + {% if config.separate_signature %} + {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} + {{ class.name }} + {% endfilter %} + {% endif %} + {% endwith %} {% endif %} {% endblock signature %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja index c560668e..435bc5b2 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja @@ -32,9 +32,13 @@ Context: {% elif config.show_docstring_classes and section.kind.value == "classes" %} {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #} {% include "docstring/classes"|get_template with context %} + {% elif config.show_docstring_type_aliases and section.kind.value == "type_aliases" %} + {% include "docstring/type_aliases"|get_template with context %} {% elif config.show_docstring_modules and section.kind.value == "modules" %} {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #} {% include "docstring/modules"|get_template with context %} + {% elif config.show_docstring_type_parameters and section.kind.value == "type parameters" %} + {% include "docstring/type_parameters"|get_template with context %} {% elif config.show_docstring_parameters and section.kind.value == "parameters" %} {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #} {% include "docstring/parameters"|get_template with context %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html new file mode 100644 index 00000000..e9a99d1b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html @@ -0,0 +1,10 @@ +{# YORE: Bump 2: Remove file. #} +{% extends "_base/docstring/type_aliases.html.jinja" %} + +{% block logs scoped %} + {{ super() }} + {{ log.warning( + "DeprecationWarning: Extending '_base/docstring/type_aliases.html' is deprecated, extend '_base/docstring/type_aliases.html.jinja' instead. ", + once=True, + ) }} +{% endblock logs %} 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..ceaa520c --- /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"|get_template 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:") }}

+ + + + + + + + + {% for type_alias in section.value %} + + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Description") }}
{{ type_alias.name }} +
+ {{ type_alias.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} + {#- Block for the `list` section style. -#} +

{{ section.title or lang.t("Type Aliases:") }}

+
    + {% for type_alias in section.value %} +
  • + {{ type_alias.name }} + – +
    + {{ type_alias.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} +
    +
  • + {% endfor %} +
+ {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + {#- Block for the `spacy` section style. -#} + + + + + + + + + {% for type_alias in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("TYPE ALIAS")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
{{ type_alias.name }} +
+ {{ type_alias.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} +
+
+ {% endblock spacy_style %} +{% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html new file mode 100644 index 00000000..90a1af38 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html @@ -0,0 +1,10 @@ +{# YORE: Bump 2: Remove file. #} +{% extends "_base/docstring/type_parameters.html.jinja" %} + +{% block logs scoped %} + {{ super() }} + {{ log.warning( + "DeprecationWarning: Extending '_base/docstring/type_parameters.html' is deprecated, extend '_base/docstring/type_parameters.html.jinja' instead. ", + once=True, + ) }} +{% endblock logs %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html.jinja new file mode 100644 index 00000000..36382462 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html.jinja @@ -0,0 +1,192 @@ +{#- Template for "Parameters" sections in docstrings. + +This template renders a list of documented type parameters in the format +specified with the [`docstring_section_style`][] configuration option. + +Context: + section (griffe.DocstringSectionTypeParameters): 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 parameters section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} +{#- Language module providing the `t` translation method. -#} + +{% with %} + {% if config.docstring_section_style == "table" %} + {% block table_style scoped %} + {#- Block for the `table` section style. -#} +

{{ section.title or lang.t("Type Parameters:") }}

+ + + + + + + + + + + {% for type_parameter in section.value %} + + + + + + + {% endfor %} + +
{{ 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 %} +
+ {% endblock table_style %} + {% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} + {#- Block for the `list` section style. -#} +

{{ section.title or lang.t("Type Parameters:") }}

+
    + {% for type_parameter in section.value %} +
  • + {% 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 %} + ( + {%- 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 %} + – +
    + {{ type_parameter.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }} +
    +
  • + {% endfor %} +
+ {% endblock list_style %} + {% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + {#- Block for the `spacy` section style. -#} + + + + + + + + + {% for type_parameter in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("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 %} + {%- endwith -%} + {%- if not loop.last %}, {% endif -%} + {% endfor %} + + {% elif type_parameter.bound %} + + {{ lang.t("BOUND:") }} + {% 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 %} +

+
+ {% endblock spacy_style %} + {% endif %} +{% endwith %} 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..54781739 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 -%} + {{ name.name }} + {%- elif config.signature_crossrefs -%} + {%- filter stash_crossref(length=name.name|length) -%} + {{ name.name }} + {%- endfilter -%} + {%- else -%} + {{ name.name }} + {%- endif -%} +{%- endmacro -%} + {%- macro param_crossref(expression) -%} {#- Render a cross-reference to a parameter heading. @@ -89,7 +132,14 @@ which is a tree-like structure representing a Python expression. {%- elif config.unwrap_annotated and expression.classname == "ExprSubscript" and expression.canonical_path in ("typing.Annotated", "typing_extensions.Annotated") -%} {{ render(expression.slice.elements[0], annotations_path) }} {%- elif expression.classname == "ExprAttribute" -%} - {%- if annotations_path == "brief" -%} + {%- if expression.first.is_type_parameter -%} + {{ type_param_crossref(expression.first) }} + {%- for element in expression -%} + {%- if not loop.first -%} + {{ render(element, "brief") }} + {%- endif -%} + {%- endfor -%} + {%- elif annotations_path == "brief" -%} {%- if expression.last.is_enum_value -%} {{ crossref(expression.last.parent, "brief", backlink_type) }}.value {%- else -%} 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..a2b9e327 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 @@ -10,8 +10,11 @@ {% macro t(key) %}{{ { "ATTRIBUTE": "ATTRIBUTE", "Attributes:": "Attributes:", + "BOUND:": "BOUND:", + "Bound or Constraints": "Bound or Constraints", "Classes:": "Classes:", "CLASS": "CLASS", + "CONSTRAINTS:": "CONSTRAINTS:", "DEFAULT:": "DEFAULT:", "Default": "Default", "default:": "default:", @@ -38,6 +41,10 @@ "Source code in": "Source code in", "TYPE:": "TYPE:", "Type": "Type", + "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/summary.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja index 78b0b9d7..e840eec5 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja @@ -13,6 +13,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 %} {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #} {% include "summary/classes"|get_template with context %} 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..68554b8c --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html @@ -0,0 +1,10 @@ +{# YORE: Bump 2: Remove file. #} +{% extends "_base/summary/type_aliases.html.jinja" %} + +{% block logs scoped %} + {{ super() }} + {{ log.warning( + "DeprecationWarning: Extending '_base/type_aliases/classes.html' is deprecated, extend '_base/type_aliases/classes.html.jinja' instead.", + 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..d811f7f3 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html @@ -0,0 +1,10 @@ +{# YORE: Bump 2: Remove file. #} +{% extends "_base/type_alias.html.jinja" %} + +{% block logs scoped %} + {{ super() }} + {{ log.warning( + "DeprecationWarning: Extending '_base/type_alias.html' is deprecated, extend '_base/type_alias.html.jinja' instead. ", + 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 %} + +
+ {% with obj = type_alias, html_id = type_alias.path %} + + {% if root %} + {% set show_full_path = config.show_root_full_path %} + {% set root_members = True %} + {% elif root_members %} + {% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %} + {% set root_members = False %} + {% else %} + {% set show_full_path = config.show_object_full_path %} + {% endif %} + + {% set type_alias_name = type_alias.path if show_full_path else type_alias.name %} + + {% if not root or config.show_root_heading %} + {% filter heading( + heading_level, + role="typealias", + id=html_id, + class="doc doc-heading", + toc_label=(' '|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 %} + +
+ {% block contents scoped %} + {#- Contents block. + + This block renders the contents of the type alias. + It contains other blocks that users can override. + Overriding the contents block allows to rearrange the order of the blocks. + -#} + {% block docstring scoped %} + {#- Docstring block. + + This block renders the docstring for the type alias. + -#} + {% with docstring_sections = type_alias.docstring.parsed %} + {% include "docstring"|get_template with context %} + {% endwith %} + {% endblock docstring %} + {% endblock contents %} +
+ + {% endwith %} +
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/type_parameters.html b/src/mkdocstrings_handlers/python/templates/material/_base/type_parameters.html new file mode 100644 index 00000000..782b1e8b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/type_parameters.html @@ -0,0 +1,10 @@ +{# YORE: Bump 2: Remove file. #} +{% extends "_base/type_parameters.html.jinja" %} + +{% block logs scoped %} + {{ super() }} + {{ log.warning( + "DeprecationWarning: Extending '_base/type_parameters.html' is deprecated, extend '_base/type_parameters.html.jinja' instead.", + once=True, + ) }} +{% endblock logs %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/type_parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/type_parameters.html.jinja new file mode 100644 index 00000000..cad49420 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/type_parameters.html.jinja @@ -0,0 +1,93 @@ +{#- Template for type parameters. + +This template renders the type parameters of a generic obj. +It iterates over the type parameters of the object to rebuild the signature. +The signature is the list of type parameters of a generic object, including their names, default values, and bound or constraints. + +Context: + obj (griffe.Object): The object to render. + config (dict): The configuration options. +-#} + +{%- if config.show_signature_type_parameters -%} + {%- block logs scoped -%} + {#- Logging block. + + This block can be used to log debug messages, deprecation messages, warnings, etc. + -#} + {{ log.debug("Rendering type parameters") }} + {%- endblock logs -%} + {%- with -%} + + {%- set ns = namespace( + annotation="", + equal="=", + default=False, + ) -%} + + {%- if obj.is_generic -%} + [ + {%- for type_parameter in obj.type_parameters -%} + {#- Prepare type bound or constraints. -#} + {%- if config.show_signature_annotations and type_parameter.annotation is not none -%} + {%- set ns.equal = " = " -%} + {%- if config.separate_signature and config.signature_crossrefs -%} + {%- with expression = type_parameter.annotation -%} + {%- set ns.annotation -%}: {% include "expression"|get_template with context %}{%- endset -%} + {%- endwith -%} + {%- else -%} + {%- set ns.annotation = ": " + type_parameter.annotation|safe -%} + {%- endif -%} + {%- else -%} + {%- set ns.equal = "=" -%} + {%- set ns.annotation = "" -%} + {%- endif -%} + + {#- Prepare default value. -#} + {%- if type_parameter.default is not none -%} + {%- set ns.default = True -%} + {%- else -%} + {%- set ns.default = False -%} + {%- endif -%} + + {#- Prepare name. -#} + {%- set type_param_prefix -%} + {%- if type_parameter.kind == "type-var-tuple" -%} + * + {%- elif type_parameter.kind == "param-spec" -%} + ** + {%- endif -%} + {%- endset -%} + + {#- Render type parameter name with optional cross-reference to its heading. -#} + {{ type_param_prefix }} + {%- if config.separate_signature and config.type_parameter_headings and config.signature_crossrefs -%} + {%- filter stash_crossref(length=type_parameter.name|length) -%} + {{ type_parameter.name }} + {%- endfilter -%} + {%- else -%} + {{ type_parameter.name }} + {%- endif -%} + + {#- Render type parameter bound or constraints. -#} + {{ ns.annotation }} + + {#- Render type parameter default value. -#} + {%- if ns.default -%} + {{ ns.equal }} + {%- if config.signature_crossrefs and config.separate_signature -%} + {%- with expression = type_parameter.default -%} + {%- include "expression"|get_template with context -%} + {%- endwith -%} + {%- else -%} + {{ type_parameter.default|safe }} + {%- endif -%} + {%- endif -%} + + {%- if not loop.last %}, {% endif -%} + {%- endfor -%} + ] + {%- endif -%} + + {%- endwith -%} +{%- endif -%} diff --git a/src/mkdocstrings_handlers/python/templates/material/docstring/type_aliases.html b/src/mkdocstrings_handlers/python/templates/material/docstring/type_aliases.html new file mode 100644 index 00000000..78bd497a --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/docstring/type_aliases.html @@ -0,0 +1 @@ +{% extends "_base/docstring/type_aliases.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/docstring/type_aliases.html.jinja b/src/mkdocstrings_handlers/python/templates/material/docstring/type_aliases.html.jinja new file mode 100644 index 00000000..78bd497a --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/docstring/type_aliases.html.jinja @@ -0,0 +1 @@ +{% extends "_base/docstring/type_aliases.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/docstring/type_parameters.html b/src/mkdocstrings_handlers/python/templates/material/docstring/type_parameters.html new file mode 100644 index 00000000..223fbb04 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/docstring/type_parameters.html @@ -0,0 +1 @@ +{% extends "_base/docstring/type_parameters.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/docstring/type_parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/docstring/type_parameters.html.jinja new file mode 100644 index 00000000..223fbb04 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/docstring/type_parameters.html.jinja @@ -0,0 +1 @@ +{% extends "_base/docstring/type_parameters.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/style.css b/src/mkdocstrings_handlers/python/templates/material/style.css index b8c3e639..489f5176 100644 --- a/src/mkdocstrings_handlers/python/templates/material/style.css +++ b/src/mkdocstrings_handlers/python/templates/material/style.css @@ -26,12 +26,14 @@ } /* Defaults in Spacy table style. */ -.doc-param-default { +.doc-param-default, +.doc-type_param-default { float: right; } /* Parameter headings must be inline, not blocks. */ -.doc-heading-parameter { +.doc-heading-parameter, +.doc-heading-type_parameter { display: inline; } @@ -41,7 +43,8 @@ } /* Prefer space on the right, not the left of parameter permalinks. */ -.doc-heading-parameter .headerlink { +.doc-heading-parameter .headerlink, +.doc-heading-type_parameter .headerlink { margin-left: 0 !important; margin-right: 0.2rem; } @@ -77,33 +80,41 @@ :root, :host, [data-md-color-scheme="default"] { --doc-symbol-parameter-fg-color: #df50af; + --doc-symbol-type_parameter-fg-color: #df50af; --doc-symbol-attribute-fg-color: #953800; --doc-symbol-function-fg-color: #8250df; --doc-symbol-method-fg-color: #8250df; --doc-symbol-class-fg-color: #0550ae; + --doc-symbol-type_alias-fg-color: #0550ae; --doc-symbol-module-fg-color: #5cad0f; --doc-symbol-parameter-bg-color: #df50af1a; + --doc-symbol-type_parameter-bg-color: #df50af1a; --doc-symbol-attribute-bg-color: #9538001a; --doc-symbol-function-bg-color: #8250df1a; --doc-symbol-method-bg-color: #8250df1a; --doc-symbol-class-bg-color: #0550ae1a; + --doc-symbol-type_alias-bg-color: #0550ae1a; --doc-symbol-module-bg-color: #5cad0f1a; } [data-md-color-scheme="slate"] { --doc-symbol-parameter-fg-color: #ffa8cc; + --doc-symbol-type_parameter-fg-color: #ffa8cc; --doc-symbol-attribute-fg-color: #ffa657; --doc-symbol-function-fg-color: #d2a8ff; --doc-symbol-method-fg-color: #d2a8ff; --doc-symbol-class-fg-color: #79c0ff; + --doc-symbol-type_alias-fg-color: #79c0ff; --doc-symbol-module-fg-color: #baff79; --doc-symbol-parameter-bg-color: #ffa8cc1a; + --doc-symbol-type_parameter-bg-color: #ffa8cc1a; --doc-symbol-attribute-bg-color: #ffa6571a; --doc-symbol-function-bg-color: #d2a8ff1a; --doc-symbol-method-bg-color: #d2a8ff1a; --doc-symbol-class-bg-color: #79c0ff1a; + --doc-symbol-type_alias-bg-color: #79c0ff1a; --doc-symbol-module-bg-color: #baff791a; } @@ -124,6 +135,16 @@ code.doc-symbol-parameter::after { content: "param"; } +code.doc-symbol-type_parameter, +a code.doc-symbol-type_parameter { + color: var(--doc-symbol-type_parameter-fg-color); + background-color: var(--doc-symbol-type_parameter-bg-color); +} + +code.doc-symbol-type_parameter::after { + content: "type-param"; +} + code.doc-symbol-attribute, a code.doc-symbol-attribute { color: var(--doc-symbol-attribute-fg-color); @@ -164,6 +185,17 @@ code.doc-symbol-class::after { content: "class"; } + +code.doc-symbol-type_alias, +a code.doc-symbol-type_alias { + color: var(--doc-symbol-type_alias-fg-color); + background-color: var(--doc-symbol-type_alias-bg-color); +} + +code.doc-symbol-type_alias::after { + content: "alias"; +} + code.doc-symbol-module, a code.doc-symbol-module { color: var(--doc-symbol-module-fg-color); diff --git a/src/mkdocstrings_handlers/python/templates/material/summary/type_aliases.html b/src/mkdocstrings_handlers/python/templates/material/summary/type_aliases.html new file mode 100644 index 00000000..ca10bc88 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/summary/type_aliases.html @@ -0,0 +1 @@ +{% extends "_base/summary/type_aliases.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/summary/type_aliases.html.jinja b/src/mkdocstrings_handlers/python/templates/material/summary/type_aliases.html.jinja new file mode 100644 index 00000000..ca10bc88 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/summary/type_aliases.html.jinja @@ -0,0 +1 @@ +{% extends "_base/summary/type_aliases.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/type_alias.html b/src/mkdocstrings_handlers/python/templates/material/type_alias.html new file mode 100644 index 00000000..5139a2db --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/type_alias.html @@ -0,0 +1 @@ +{% extends "_base/type_alias.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/type_alias.html.jinja b/src/mkdocstrings_handlers/python/templates/material/type_alias.html.jinja new file mode 100644 index 00000000..5139a2db --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/type_alias.html.jinja @@ -0,0 +1 @@ +{% extends "_base/type_alias.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/type_parameters.html b/src/mkdocstrings_handlers/python/templates/material/type_parameters.html new file mode 100644 index 00000000..c39ca528 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/type_parameters.html @@ -0,0 +1 @@ +{% extends "_base/type_parameters.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/material/type_parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/type_parameters.html.jinja new file mode 100644 index 00000000..c39ca528 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/type_parameters.html.jinja @@ -0,0 +1 @@ +{% extends "_base/type_parameters.html.jinja" %} diff --git a/tests/snapshots/__init__.py b/tests/snapshots/__init__.py new file mode 100644 index 00000000..f9c00d43 --- /dev/null +++ b/tests/snapshots/__init__.py @@ -0,0 +1,405 @@ +"""Snaphots for the inline-snapshot pytest plugin.""" + +from inline_snapshot import external, snapshot + +snapshots_signatures = snapshot( + { + ( + ("separate_signature", True), + ("show_signature_annotations", False), + ("signature_crossrefs", False), + ): external("4370d843cc76*.html"), + ( + ("separate_signature", True), + ("show_signature_annotations", True), + ("signature_crossrefs", True), + ): external("955e5111f426*.html"), + ( + ("separate_signature", False), + ("show_signature_annotations", True), + ("signature_crossrefs", True), + ): external("59872531a086*.html"), + ( + ("separate_signature", False), + ("show_signature_annotations", False), + ("signature_crossrefs", True), + ): external("1c04883284f6*.html"), + ( + ("separate_signature", False), + ("show_signature_annotations", False), + ("signature_crossrefs", False), + ): external("b0761b5d88e0*.html"), + ( + ("separate_signature", True), + ("show_signature_annotations", True), + ("signature_crossrefs", False), + ): external("f5ce06acbb7a*.html"), + ( + ("separate_signature", True), + ("show_signature_annotations", False), + ("signature_crossrefs", True), + ): external("9c0bfc0ee407*.html"), + ( + ("separate_signature", False), + ("show_signature_annotations", True), + ("signature_crossrefs", False), + ): external("9c7eeb0d7bfb*.html"), + }, +) + +snapshots_members = snapshot( + { + ( + ("filters", ()), + ("inherited_members", ("method1",)), + ("members", False), + ): external("ab0ddac637b5*.html"), + (("filters", None), ("inherited_members", True), ("members", True)): external( + "5206643f1d79*.html", + ), + (("filters", ()), ("inherited_members", False), ("members", True)): external( + "2688494d14e8*.html", + ), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ()), + ("members", ("module_attribute",)), + ): external("6d12192d6b4d*.html"), + (("filters", ()), ("inherited_members", ()), ("members", False)): external( + "366b0537fe06*.html", + ), + ( + ("filters", ()), + ("inherited_members", ("method1",)), + ("members", ("module_attribute",)), + ): external("e90c3e0c85dd*.html"), + (("filters", ()), ("inherited_members", True), ("members", True)): external( + "bf3b380c0319*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ("method1",)), + ("members", ()), + ): external("f8f32ea6a0c8*.html"), + ( + ("filters", ()), + ("inherited_members", ("method1",)), + ("members", True), + ): external("0e5bca1984e9*.html"), + (("filters", ()), ("inherited_members", False), ("members", False)): external( + "5cf0130e3b4f*.html", + ), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", True), + ("members", True), + ): external("dc101bbf9385*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", False), + ("members", ()), + ): external("fb5ebb7546d8*.html"), + ( + ("filters", None), + ("inherited_members", ("method1",)), + ("members", ("module_attribute",)), + ): external("afd5c166367d*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ("method1",)), + ("members", ("module_attribute",)), + ): external("26bc66c2ba29*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", False), + ("members", ("module_attribute",)), + ): external("247a6063b698*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", False), + ("members", ("module_attribute",)), + ): external("5a9c10410801*.html"), + (("filters", ()), ("inherited_members", False), ("members", ())): external( + "fba0d78ae23e*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ("method1",)), + ("members", None), + ): external("cfcd41685591*.html"), + (("filters", ()), ("inherited_members", False), ("members", None)): external( + "ca8e03e3261a*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ()), + ("members", False), + ): external("76ee8e01e1c0*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ("method1",)), + ("members", ()), + ): external("42c053a5e567*.html"), + ( + ("filters", None), + ("inherited_members", ("method1",)), + ("members", ()), + ): external("4f60da13e2d4*.html"), + (("filters", ()), ("inherited_members", True), ("members", ())): external( + "c915eb92fd5d*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ()), + ("members", None), + ): external("c9a15552eed3*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ("method1",)), + ("members", None), + ): external("3313930abb15*.html"), + (("filters", None), ("inherited_members", False), ("members", False)): external( + "9bd282a6f2fe*.html", + ), + ( + ("filters", None), + ("inherited_members", ()), + ("members", ("module_attribute",)), + ): external("166b8dfab738*.html"), + (("filters", None), ("inherited_members", ()), ("members", False)): external( + "44e42f27bfe3*.html", + ), + (("filters", None), ("inherited_members", False), ("members", None)): external( + "2e4d65061027*.html", + ), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", True), + ("members", ()), + ): external("28d8862dd086*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", True), + ("members", False), + ): external("f3f3acb6b51b*.html"), + (("filters", None), ("inherited_members", ()), ("members", True)): external( + "4312e98ede3c*.html", + ), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", True), + ("members", None), + ): external("8306095b18c4*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", False), + ("members", False), + ): external("eee65d3705a6*.html"), + ( + ("filters", None), + ("inherited_members", False), + ("members", ("module_attribute",)), + ): external("a200913d9a7d*.html"), + ( + ("filters", None), + ("inherited_members", True), + ("members", ("module_attribute",)), + ): external("bd6594ae3b51*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", True), + ("members", ("module_attribute",)), + ): external("8d4e1f9af997*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", False), + ("members", ()), + ): external("d5a6bf59c663*.html"), + (("filters", None), ("inherited_members", ()), ("members", None)): external( + "06b3a345d3df*.html", + ), + (("filters", ()), ("inherited_members", True), ("members", None)): external( + "e555bf966edd*.html", + ), + ( + ("filters", ()), + ("inherited_members", False), + ("members", ("module_attribute",)), + ): external("09d96d69d9dc*.html"), + ( + ("filters", None), + ("inherited_members", ("method1",)), + ("members", None), + ): external("adcc51aa0d87*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", True), + ("members", ()), + ): external("95f8e480937f*.html"), + (("filters", None), ("inherited_members", False), ("members", True)): external( + "e22a35456321*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", True), + ("members", True), + ): external("d7988a46775a*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", False), + ("members", None), + ): external("94faed07f275*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ("method1",)), + ("members", False), + ): external("f0014d9505ec*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", True), + ("members", ("module_attribute",)), + ): external("96cf94f4822a*.html"), + (("filters", None), ("inherited_members", True), ("members", ())): external( + "ce06da7f07b3*.html", + ), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ()), + ("members", False), + ): external("74bfab19cbd4*.html"), + ( + ("filters", None), + ("inherited_members", ("method1",)), + ("members", True), + ): external("f697469880cb*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", True), + ("members", False), + ): external("d726cb8367d9*.html"), + (("filters", None), ("inherited_members", False), ("members", ())): external( + "fb770e6537bc*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", True), + ("members", None), + ): external("2bf34b4dd82e*.html"), + ( + ("filters", ()), + ("inherited_members", ("method1",)), + ("members", ()), + ): external("4892e0fe1920*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ()), + ("members", True), + ): external("c90af3fe1d72*.html"), + ( + ("filters", ()), + ("inherited_members", ()), + ("members", ("module_attribute",)), + ): external("388a13d71284*.html"), + (("filters", None), ("inherited_members", True), ("members", False)): external( + "3f5d794823a4*.html", + ), + ( + ("filters", ()), + ("inherited_members", True), + ("members", ("module_attribute",)), + ): external("9d03089a46fa*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ("method1",)), + ("members", ("module_attribute",)), + ): external("8b097c69ac2f*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", False), + ("members", True), + ): external("059dc5c474ca*.html"), + ( + ("filters", None), + ("inherited_members", ("method1",)), + ("members", False), + ): external("e3defc3620e5*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ()), + ("members", True), + ): external("3ea5302e71e5*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ("method1",)), + ("members", False), + ): external("c6e7ef9564cd*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", False), + ("members", None), + ): external("62e18d3e5777*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ()), + ("members", None), + ): external("adcecdb71c09*.html"), + (("filters", None), ("inherited_members", ()), ("members", ())): external( + "f77f1c850398*.html", + ), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", False), + ("members", True), + ): external("5e331d13e0e0*.html"), + (("filters", None), ("inherited_members", True), ("members", None)): external( + "1895a0c88668*.html", + ), + (("filters", ()), ("inherited_members", ()), ("members", None)): external( + "76176ed54147*.html", + ), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ()), + ("members", ()), + ): external("c260e7f4ef3b*.html"), + ( + ("filters", ("!module_attribute",)), + ("inherited_members", ("method1",)), + ("members", True), + ): external("14c3d2f7287b*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ()), + ("members", ("module_attribute",)), + ): external("f6e292b8358a*.html"), + (("filters", ()), ("inherited_members", True), ("members", False)): external( + "b0a9b08f1f72*.html", + ), + (("filters", ()), ("inherited_members", ()), ("members", True)): external( + "7f570c4de561*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", False), + ("members", False), + ): external("710706687213*.html"), + (("filters", ()), ("inherited_members", ()), ("members", ())): external( + "11598fec2d07*.html", + ), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ("method1",)), + ("members", True), + ): external("fa334e855708*.html"), + ( + ("filters", ()), + ("inherited_members", ("method1",)), + ("members", None), + ): external("57e7bb4ad48c*.html"), + ( + ("filters", ("module_attribute",)), + ("inherited_members", ()), + ("members", ()), + ): external("a185e216dc7b*.html"), + }, +) diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=None.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=None.html index dce4e148..d66d123f 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=None.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=None.html @@ -23,8 +23,10 @@

- - Class + + + Class +

@@ -111,8 +113,10 @@

- - NestedClass + + + NestedClass +

@@ -229,8 +233,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=True.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=True.html index 6d460dd2..64b40616 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=True.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=('method1',),members=True.html @@ -54,8 +54,10 @@

- - Class + + + Class +

@@ -142,8 +144,10 @@

- - NestedClass + + + NestedClass +

@@ -260,8 +264,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=None.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=None.html index 793f43a4..dfd0df14 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=None.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=None.html @@ -21,8 +21,10 @@

- - Class + + + Class +

@@ -109,8 +111,10 @@

- - NestedClass + + + NestedClass +

@@ -227,8 +231,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=True.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=True.html index 07120341..3fbf1ca0 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=True.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=(),members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -140,8 +142,10 @@

- - NestedClass + + + NestedClass +

@@ -258,8 +262,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=None.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=None.html index 5a87832a..e18a2923 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=None.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=None.html @@ -21,8 +21,10 @@

- - Class + + + Class +

@@ -109,8 +111,10 @@

- - NestedClass + + + NestedClass +

@@ -227,8 +231,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=True.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=True.html index 40ebfa36..b1d1ec7d 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=True.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=False,members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -140,8 +142,10 @@

- - NestedClass + + + NestedClass +

@@ -258,8 +262,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=None.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=None.html index cb43eee6..258c0348 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=None.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=None.html @@ -21,8 +21,10 @@

- - Class + + + Class +

@@ -109,8 +111,10 @@

- - NestedClass + + + NestedClass +

@@ -227,8 +231,10 @@

- - Subclass + + + Subclass +

@@ -323,8 +329,10 @@

- - NestedClass + + + NestedClass +

diff --git a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=True.html b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=True.html index 8357168e..668a5c79 100644 --- a/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=True.html +++ b/tests/snapshots/members/filters=('!module_attribute',),inherited_members=True,members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -140,8 +142,10 @@

- - NestedClass + + + NestedClass +

@@ -258,8 +262,10 @@

- - Subclass + + + Subclass +

@@ -354,8 +360,10 @@

- - NestedClass + + + NestedClass +

diff --git a/tests/snapshots/members/filters=('module_attribute',),inherited_members=('method1',),members=True.html b/tests/snapshots/members/filters=('module_attribute',),inherited_members=('method1',),members=True.html index 795378be..08244348 100644 --- a/tests/snapshots/members/filters=('module_attribute',),inherited_members=('method1',),members=True.html +++ b/tests/snapshots/members/filters=('module_attribute',),inherited_members=('method1',),members=True.html @@ -54,8 +54,10 @@

- - Class + + + Class +

@@ -72,8 +74,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('module_attribute',),inherited_members=(),members=True.html b/tests/snapshots/members/filters=('module_attribute',),inherited_members=(),members=True.html index a7eb7dce..5dd89a0e 100644 --- a/tests/snapshots/members/filters=('module_attribute',),inherited_members=(),members=True.html +++ b/tests/snapshots/members/filters=('module_attribute',),inherited_members=(),members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -70,8 +72,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('module_attribute',),inherited_members=False,members=True.html b/tests/snapshots/members/filters=('module_attribute',),inherited_members=False,members=True.html index e196b599..ffdf6611 100644 --- a/tests/snapshots/members/filters=('module_attribute',),inherited_members=False,members=True.html +++ b/tests/snapshots/members/filters=('module_attribute',),inherited_members=False,members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -70,8 +72,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=('module_attribute',),inherited_members=True,members=True.html b/tests/snapshots/members/filters=('module_attribute',),inherited_members=True,members=True.html index 26cb9e39..43afb9f1 100644 --- a/tests/snapshots/members/filters=('module_attribute',),inherited_members=True,members=True.html +++ b/tests/snapshots/members/filters=('module_attribute',),inherited_members=True,members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -70,8 +72,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=('method1',),members=None.html b/tests/snapshots/members/filters=(),inherited_members=('method1',),members=None.html index d9ae307d..bf50b323 100644 --- a/tests/snapshots/members/filters=(),inherited_members=('method1',),members=None.html +++ b/tests/snapshots/members/filters=(),inherited_members=('method1',),members=None.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -140,8 +142,10 @@

- - NestedClass + + + NestedClass +

@@ -258,8 +262,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=('method1',),members=True.html b/tests/snapshots/members/filters=(),inherited_members=('method1',),members=True.html index a52964c3..5b572067 100644 --- a/tests/snapshots/members/filters=(),inherited_members=('method1',),members=True.html +++ b/tests/snapshots/members/filters=(),inherited_members=('method1',),members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -140,8 +142,10 @@

- - NestedClass + + + NestedClass +

@@ -258,8 +262,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=(),members=None.html b/tests/snapshots/members/filters=(),inherited_members=(),members=None.html index 9058ed13..87de82a1 100644 --- a/tests/snapshots/members/filters=(),inherited_members=(),members=None.html +++ b/tests/snapshots/members/filters=(),inherited_members=(),members=None.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=(),members=True.html b/tests/snapshots/members/filters=(),inherited_members=(),members=True.html index ccfa8d64..fdcbee61 100644 --- a/tests/snapshots/members/filters=(),inherited_members=(),members=True.html +++ b/tests/snapshots/members/filters=(),inherited_members=(),members=True.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=False,members=None.html b/tests/snapshots/members/filters=(),inherited_members=False,members=None.html index 7c90168c..fe8a0ca2 100644 --- a/tests/snapshots/members/filters=(),inherited_members=False,members=None.html +++ b/tests/snapshots/members/filters=(),inherited_members=False,members=None.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=False,members=True.html b/tests/snapshots/members/filters=(),inherited_members=False,members=True.html index d6c51063..3e403f6e 100644 --- a/tests/snapshots/members/filters=(),inherited_members=False,members=True.html +++ b/tests/snapshots/members/filters=(),inherited_members=False,members=True.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=True,members=None.html b/tests/snapshots/members/filters=(),inherited_members=True,members=None.html index b2490df7..16d70a97 100644 --- a/tests/snapshots/members/filters=(),inherited_members=True,members=None.html +++ b/tests/snapshots/members/filters=(),inherited_members=True,members=None.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

@@ -352,8 +358,10 @@

- - NestedClass + + + NestedClass +

diff --git a/tests/snapshots/members/filters=(),inherited_members=True,members=True.html b/tests/snapshots/members/filters=(),inherited_members=True,members=True.html index 7c65c72b..986b649e 100644 --- a/tests/snapshots/members/filters=(),inherited_members=True,members=True.html +++ b/tests/snapshots/members/filters=(),inherited_members=True,members=True.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

@@ -352,8 +358,10 @@

- - NestedClass + + + NestedClass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=('method1',),members=None.html b/tests/snapshots/members/filters=None,inherited_members=('method1',),members=None.html index ddce47f6..d1d747db 100644 --- a/tests/snapshots/members/filters=None,inherited_members=('method1',),members=None.html +++ b/tests/snapshots/members/filters=None,inherited_members=('method1',),members=None.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -140,8 +142,10 @@

- - NestedClass + + + NestedClass +

@@ -258,8 +262,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=('method1',),members=True.html b/tests/snapshots/members/filters=None,inherited_members=('method1',),members=True.html index fa970eca..893e51cc 100644 --- a/tests/snapshots/members/filters=None,inherited_members=('method1',),members=True.html +++ b/tests/snapshots/members/filters=None,inherited_members=('method1',),members=True.html @@ -52,8 +52,10 @@

- - Class + + + Class +

@@ -140,8 +142,10 @@

- - NestedClass + + + NestedClass +

@@ -258,8 +262,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=(),members=None.html b/tests/snapshots/members/filters=None,inherited_members=(),members=None.html index 91614cf0..2708ced5 100644 --- a/tests/snapshots/members/filters=None,inherited_members=(),members=None.html +++ b/tests/snapshots/members/filters=None,inherited_members=(),members=None.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=(),members=True.html b/tests/snapshots/members/filters=None,inherited_members=(),members=True.html index 2d79edd5..847b49ba 100644 --- a/tests/snapshots/members/filters=None,inherited_members=(),members=True.html +++ b/tests/snapshots/members/filters=None,inherited_members=(),members=True.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=False,members=None.html b/tests/snapshots/members/filters=None,inherited_members=False,members=None.html index 332a5c53..b6722a87 100644 --- a/tests/snapshots/members/filters=None,inherited_members=False,members=None.html +++ b/tests/snapshots/members/filters=None,inherited_members=False,members=None.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=False,members=True.html b/tests/snapshots/members/filters=None,inherited_members=False,members=True.html index cce2be49..e44e7335 100644 --- a/tests/snapshots/members/filters=None,inherited_members=False,members=True.html +++ b/tests/snapshots/members/filters=None,inherited_members=False,members=True.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=True,members=None.html b/tests/snapshots/members/filters=None,inherited_members=True,members=None.html index 68c7d720..ba53b550 100644 --- a/tests/snapshots/members/filters=None,inherited_members=True,members=None.html +++ b/tests/snapshots/members/filters=None,inherited_members=True,members=None.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

@@ -352,8 +358,10 @@

- - NestedClass + + + NestedClass +

diff --git a/tests/snapshots/members/filters=None,inherited_members=True,members=True.html b/tests/snapshots/members/filters=None,inherited_members=True,members=True.html index e9f375b2..ba688398 100644 --- a/tests/snapshots/members/filters=None,inherited_members=True,members=True.html +++ b/tests/snapshots/members/filters=None,inherited_members=True,members=True.html @@ -50,8 +50,10 @@

- - Class + + + Class +

@@ -138,8 +140,10 @@

- - NestedClass + + + NestedClass +

@@ -256,8 +260,10 @@

- - Subclass + + + Subclass +

@@ -352,8 +358,10 @@

- - NestedClass + + + NestedClass +

diff --git a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=False.html b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=False.html index 599197fe..3fc98686 100644 --- a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=False.html +++ b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=False.html @@ -16,8 +16,10 @@

- - Class + + + Class +

diff --git a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=True.html b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=True.html index 70567c97..2a424f53 100644 --- a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=True.html +++ b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=False,signature_crossrefs=True.html @@ -16,8 +16,10 @@

- - Class + + + Class +

diff --git a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=False.html b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=False.html index 65e87e01..4ca680ba 100644 --- a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=False.html +++ b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=False.html @@ -16,8 +16,10 @@

- - Class + + + Class +

diff --git a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=True.html b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=True.html index 44516fe5..d1aed71e 100644 --- a/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=True.html +++ b/tests/snapshots/signatures/separate_signature=False,show_signature_annotations=True,signature_crossrefs=True.html @@ -16,8 +16,10 @@

- - Class + + + Class +