Skip to content

Support PEP 695 generics #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions docs/usage/configuration/docstrings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<h2>module</h2>
<p>Summary.</p>
<p><b>Type Aliases:</b></p>

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

<h3><code>TypeAlias</code></h3>
<p>Summary.</p>
////

//// tab | Without classes
<h2>module</h2>
<p>Summary.</p>
<h3><code>TypeAlias</code></h3>
<p>Summary.</p>
////
///

[](){#option-show_docstring_modules}
## `show_docstring_modules`

Expand Down Expand Up @@ -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" }**
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) -->

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
<h2><code>AClass</code></h2>
<p>Represents something.</p>
<p><b>Type Parameters:</b></p>

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

//// tab | Without parameters
<h2><code>AClass</code></h2>
<p>Represents something.</p>
////
///

[](){#option-show_docstring_warns}
## `show_docstring_warns`

Expand Down
Loading
Loading