From f25b2ecf73f30ac0ea836bec1aa60e87a360e23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 9 Sep 2025 14:07:57 +0200 Subject: [PATCH 01/16] docs: Add recommended settings section in usage page Issue-199: https://github.com/mkdocstrings/python/issues/199 --- docs/usage/index.md | 104 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/docs/usage/index.md b/docs/usage/index.md index e1fa457f..3348a627 100644 --- a/docs/usage/index.md +++ b/docs/usage/index.md @@ -380,3 +380,107 @@ poetry install poetry run mkdocs build ``` /// + +## Recommended settings + +If you're in a hurry, here is the configuration we recommend for the Python handler. + +```yaml +- mkdocstrings: + handlers: + python: + + # Where to find your sources, see "Finding modules". + paths: [src] + + # Load object inventories to enable cross-references to other projects. + inventories: + - https://docs.python.org/3/objects.inv + # Also load inventories of your dependencies, generally served at + # https://docs-url-for-your-dependency/objects.inv. + + options: + + # DOCSTRINGS ------------------------------------------------------------- + docstring_options: + # Discard first line of `__init__` method docstrings, + # useful when merging such docstrings into their parent class'. + ignore_init_summary: true + + # Tables are generally too large, lists will fix this. + docstring_section_style: list + + # CROSS-REFERENCES ------------------------------------------------------- + # Enable relative crossrefs and scoped crossrefs, see Docstrings options. + relative_crossrefs: true # Sponsors only! + scoped_crossrefs: true # Sponsors only! + + # Enable cross-references in signatures. + signature_crossrefs: true + + # Unwrap actual types from `Annotated` type annotations. + unwrap_annotated: true + + # MEMBERS ---------------------------------------------------------------- + # Only render pulic symbols. + filters: public # Sponsors only! + # Comment the option otherwise to get the default filters. + + # Show class inherited members. + inherited_members: true + + # Render auto-generated summaries of attributes, functions, etc. + # at the start of each symbol's documentation. + summary: true + + # HEADINGS --------------------------------------------------------------- + # For auto-generated pages, one module per page, + # make the module heading be the H1 heading of the page. + heading_level: 1 + + # Render headings for parameters, making them linkable. + parameter_headings: true + + # Render headings for type parameters too. + type_parameter_headings: true + + # Always show the heading for the symbol you render with `::: id`. + show_root_heading: true + + # Only show the name of the symbols you inject render `::: id`. + show_root_full_path: false + + # Show the type of symbol (class, function, etc.) in the heading. + show_symbol_type_heading: true + + # Show the type of symbol (class, function, etc.) in the table of contents. + show_symbol_type_toc: true + + # SIGNATURES ------------------------------------------------------------- + # Format code to 80 + 10% margin (Black and Ruff defaults) + # in signatures and attribute value code blocks. + # Needs Black/Ruff installed. + line_length: 88 + + # Merge signature and docstring of `__init__` methods + # into their parent class signature and docstring. + merge_init_into_class: true + + # Render signatures and attribute values in a separate code block, + # below the symbol heading. + separate_signature: true + + # Show type annotations in signatures. + show_signature_annotations: true + + # Show type parameters in signatures. + show_signature_type_parameters: true + + # OTHER ------------------------------------------------------------------ + # Show backlinks to other documentation sections within each symbol. + backlinks: tree # Sponsors only! + + # Show base classes OR inheritance diagram. + show_bases: false + show_inheritance_diagram: true # Sponsors only! +``` From be7d65da939b88997935a3ecfdce1e5052817795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 9 Oct 2025 13:10:07 +0200 Subject: [PATCH 02/16] docs: Show default value for `show_overloads` and `overloads_only` options Issue-312: https://github.com/mkdocstrings/python/issues/312 Issue-313: https://github.com/mkdocstrings/python/issues/313 --- docs/usage/configuration/signatures.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/usage/configuration/signatures.md b/docs/usage/configuration/signatures.md index 0dabf74f..16ac218b 100644 --- a/docs/usage/configuration/signatures.md +++ b/docs/usage/configuration/signatures.md @@ -289,6 +289,8 @@ plugins: [](){#option-overloads_only} ## `overloads_only` +- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** + Whether to hide the implementation signature if the overloads are shown with [`show_overloads`][]. ```yaml title="in mkdocs.yml (global configuration)" @@ -297,7 +299,7 @@ plugins: handlers: python: options: - overloads_only: true + overloads_only: false ``` ```md title="or in docs/some_page.md (local configuration)" @@ -584,6 +586,8 @@ class SomeClass: [](){#option-show_overloads} ## `show_overloads` +- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** + Whether to render function / method overloads. ```yaml title="in mkdocs.yml (global configuration)" From 6d600238c631bca29d95df711b6c788d978fbe98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 9 Oct 2025 13:34:58 +0200 Subject: [PATCH 03/16] chore: Template upgrade --- .copier-answers.yml | 2 +- .github/pull_request_template.md | 15 +++++ .github/workflows/ci.yml | 30 ++++++++- Makefile | 7 +++ README.md | 2 +- config/pytest.ini | 2 + config/pytest_39.ini | 17 ++++++ docs/js/insiders.js | 13 ++-- duties.py | 24 +++++--- scripts/get_version.py | 7 ++- scripts/make.py | 61 +++++++++++++++---- .../python/_internal/debug.py | 2 +- tests/test_api.py | 6 +- 13 files changed, 153 insertions(+), 35 deletions(-) create mode 100644 .github/pull_request_template.md create mode 100644 config/pytest_39.ini diff --git a/.copier-answers.yml b/.copier-answers.yml index 76531124..0d9a98c3 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier. -_commit: 1.4.5 +_commit: 1.5.1 _src_path: gh:mkdocstrings/handler-template author_email: dev@pawamoy.fr author_fullname: Timothée Mazzucotelli diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..6f0f2faf --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +### For reviewers + + +- [ ] I did not use AI +- [ ] I used AI and thoroughly reviewed every code/docs change + +### Description of the change + + +### Relevant resources + + +- +- +- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf37ef60..2399abb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,17 @@ name: ci on: push: + branches: + - main + - test-me-* pull_request: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + defaults: run: shell: bash @@ -14,13 +21,30 @@ env: LANG: en_US.utf-8 LC_ALL: en_US.utf-8 PYTHONIOENCODING: UTF-8 + PYTHONWARNDEFAULTENCODING: "1" PYTHON_VERSIONS: "" jobs: quality: + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + python-version: + - "3.9" + - "3.13" + include: + - os: ubuntu-latest + python-version: "3.10" + - os: ubuntu-latest + python-version: "3.11" + - os: ubuntu-latest + python-version: "3.12" - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -32,7 +56,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: "3.13" + python-version: ${{ matrix.python-version }} - name: Setup uv uses: astral-sh/setup-uv@v5 @@ -109,7 +133,7 @@ jobs: - lowest-direct exclude: ${{ fromJSON(needs.exclude-test-jobs.outputs.jobs) }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.python-version == '3.14' }} + continue-on-error: true steps: - name: Checkout diff --git a/Makefile b/Makefile index 5e88121d..1b3391da 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,13 @@ # the `make` command will point at the `scripts/make` shell script. # This Makefile is just here to allow auto-completion in the terminal. +default: help + @echo + @echo 'Enable direnv in your shell to use the `make` command: `direnv allow`' + @echo 'Or use `python scripts/make ARGS` to run the commands/tasks directly.' + +.DEFAULT_GOAL: default + actions = \ allrun \ changelog \ diff --git a/README.md b/README.md index 937a3a84..44507e72 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![ci](https://github.com/mkdocstrings/python/workflows/ci/badge.svg)](https://github.com/mkdocstrings/python/actions?query=workflow%3Aci) [![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://mkdocstrings.github.io/python/) [![pypi version](https://img.shields.io/pypi/v/mkdocstrings-python.svg)](https://pypi.org/project/mkdocstrings-python/) -[![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#python:gitter.im) +[![gitter](https://img.shields.io/badge/matrix-chat-4DB798.svg?style=flat)](https://app.gitter.im/#/room/#mkdocstrings_python:gitter.im) --- diff --git a/config/pytest.ini b/config/pytest.ini index 4f43c18e..39ee3a3c 100644 --- a/config/pytest.ini +++ b/config/pytest.ini @@ -10,6 +10,8 @@ testpaths = # action:message_regex:warning_class:module_regex:line filterwarnings = error + default::EncodingWarning + error::EncodingWarning:python # TODO: Remove once pytest-xdist 4 is released. ignore:.*rsyncdir:DeprecationWarning:xdist # TODO: Remove once mkdocstrings stops setting fallback function. diff --git a/config/pytest_39.ini b/config/pytest_39.ini new file mode 100644 index 00000000..a876e994 --- /dev/null +++ b/config/pytest_39.ini @@ -0,0 +1,17 @@ +# YORE: EOL 3.9: Remove file. +# This file is used on 3.9 due to forward compatibility issue with filterwarnings. +# See https://github.com/pytest-dev/pytest/issues/11101. +[pytest] +python_files = + test_*.py +addopts = + --cov + --cov-config config/coverage.ini +testpaths = + tests + +# action:message_regex:warning_class:module_regex:line +filterwarnings = + error + # TODO: remove once pytest-xdist 4 is released + ignore:.*rsyncdir:DeprecationWarning:xdist diff --git a/docs/js/insiders.js b/docs/js/insiders.js index 8bb68485..a86a0918 100644 --- a/docs/js/insiders.js +++ b/docs/js/insiders.js @@ -29,11 +29,14 @@ function updatePremiumSponsors(dataURL, rank) { let html = ''; html += `${capRank} sponsors

` sponsors.forEach(function (sponsor) { - html += ` - - ${sponsor.name} - - ` + html += `` + if (sponsor.image) { + html += `${sponsor.name}` + } else if (sponsor.imageLight && sponsor.imageDark) { + html += `${sponsor.name}` + html += `${sponsor.name}` + } + html += ''; }); html += '

' sponsorsDiv.innerHTML = html; diff --git a/duties.py b/duties.py index 0fa73ea0..41df37b6 100644 --- a/duties.py +++ b/duties.py @@ -26,6 +26,8 @@ WINDOWS = os.name == "nt" PTY = not WINDOWS and not CI MULTIRUN = os.environ.get("MULTIRUN", "0") == "1" +PY_VERSION = f"{sys.version_info.major}{sys.version_info.minor}" +PY_DEV = "314" def pyprefix(title: str) -> str: @@ -84,7 +86,7 @@ def check(ctx: Context) -> None: """Check it all!""" -@duty +@duty(nofail=PY_VERSION == PY_DEV) def check_quality(ctx: Context) -> None: """Check the code quality.""" ctx.run( @@ -93,7 +95,7 @@ def check_quality(ctx: Context) -> None: ) -@duty(skip_if=sys.version_info < (3, 13), skip_reason=pyprefix("Skipped: docs require modern generics syntax")) +@duty(nofail=PY_VERSION == PY_DEV, skip_if=sys.version_info < (3, 13), skip_reason=pyprefix("Skipped: docs require modern generics syntax")) def check_docs(ctx: Context) -> None: """Check if the documentation builds correctly.""" Path("htmlcov").mkdir(parents=True, exist_ok=True) @@ -105,7 +107,7 @@ def check_docs(ctx: Context) -> None: ) -@duty +@duty(nofail=PY_VERSION == PY_DEV) def check_types(ctx: Context) -> None: """Check that the code is correctly typed.""" os.environ["MYPYPATH"] = "src" @@ -118,7 +120,7 @@ def check_types(ctx: Context) -> None: ) -@duty +@duty(nofail=PY_VERSION == PY_DEV) def check_api(ctx: Context, *cli_args: str) -> None: """Check for API breaking changes.""" ctx.run( @@ -239,7 +241,7 @@ def coverage(ctx: Context) -> None: ctx.run(tools.coverage.html(rcfile="config/coverage.ini")) -@duty +@duty(nofail=PY_VERSION == PY_DEV) def test(ctx: Context, *cli_args: str, match: str = "", snapshot: str = "report") -> None: # noqa: PT028 """Run the test suite. @@ -247,17 +249,23 @@ def test(ctx: Context, *cli_args: str, match: str = "", snapshot: str = "report" match: A pytest expression to filter selected tests. snapshot: Whether to "create", "fix", "trim", or "update" snapshots. """ - py_version = f"{sys.version_info.major}{sys.version_info.minor}" - os.environ["COVERAGE_FILE"] = f".coverage.{py_version}" + os.environ["COVERAGE_FILE"] = f".coverage.{PY_VERSION}" + os.environ["PYTHONWARNDEFAULTENCODING"] = "1" args = list(cli_args) if snapshot == "disable" or not snapshot: args = ["-n", "auto", "--inline-snapshot=disable"] else: args = [f"--inline-snapshot={snapshot}"] + + config_file = "config/pytest.ini" + # YORE: EOL 3.9: Remove block. + if sys.version_info[:2] < (3, 10): + config_file = "config/pytest_39.ini" + ctx.run( tools.pytest( "tests", - config_file="config/pytest.ini", + config_file=config_file, select=match, color="yes", ).add_args(*args), diff --git a/scripts/get_version.py b/scripts/get_version.py index 6734e5b6..3c425a73 100644 --- a/scripts/get_version.py +++ b/scripts/get_version.py @@ -4,7 +4,12 @@ from contextlib import suppress from pathlib import Path -from pdm.backend.hooks.version import SCMVersion, Version, default_version_formatter, get_version_from_scm +from pdm.backend.hooks.version import ( # ty: ignore[unresolved-import] + SCMVersion, + Version, + default_version_formatter, + get_version_from_scm, +) _root = Path(__file__).parent.parent _changelog = _root / "CHANGELOG.md" diff --git a/scripts/make.py b/scripts/make.py index 5a7fb4c2..1e697bcc 100755 --- a/scripts/make.py +++ b/scripts/make.py @@ -14,7 +14,8 @@ from collections.abc import Iterator -PYTHON_VERSIONS = os.getenv("PYTHON_VERSIONS", "3.9 3.10 3.11 3.12 3.13").split() +PYTHON_VERSIONS = os.getenv("PYTHON_VERSIONS", "3.9 3.10 3.11 3.12 3.13 3.14").split() +PYTHON_DEV = "3.14" def shell(cmd: str, *, capture_output: bool = False, **kwargs: Any) -> str | None: @@ -67,16 +68,31 @@ def setup() -> None: uv_install(venv_path) +class _RunError(subprocess.CalledProcessError): + def __init__(self, *args: Any, python_version: str, **kwargs: Any): + super().__init__(*args, **kwargs) + self.python_version = python_version + + def run(version: str, cmd: str, *args: str, **kwargs: Any) -> None: """Run a command in a virtual environment.""" kwargs = {"check": True, **kwargs} uv_run = ["uv", "run", "--no-sync"] - if version == "default": - with environ(UV_PROJECT_ENVIRONMENT=".venv"): - subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510 - else: - with environ(UV_PROJECT_ENVIRONMENT=f".venvs/{version}", MULTIRUN="1"): - subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510 + try: + if version == "default": + with environ(UV_PROJECT_ENVIRONMENT=".venv"): + subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510 + else: + with environ(UV_PROJECT_ENVIRONMENT=f".venvs/{version}", MULTIRUN="1"): + subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510 + except subprocess.CalledProcessError as process: + raise _RunError( + returncode=process.returncode, + python_version=version, + cmd=process.cmd, + output=process.output, + stderr=process.stderr, + ) from process def multirun(cmd: str, *args: str, **kwargs: Any) -> None: @@ -144,19 +160,31 @@ def main() -> int: cmd = args.pop(0) if cmd == "run": - run("default", *args) + if not args: + print("make: run: missing command", file=sys.stderr) + return 1 + run("default", *args) # ty: ignore[missing-argument] return 0 if cmd == "multirun": - multirun(*args) + if not args: + print("make: run: missing command", file=sys.stderr) + return 1 + multirun(*args) # ty: ignore[missing-argument] return 0 if cmd == "allrun": - allrun(*args) + if not args: + print("make: run: missing command", file=sys.stderr) + return 1 + allrun(*args) # ty: ignore[missing-argument] return 0 if cmd.startswith("3."): - run(cmd, *args) + if not args: + print("make: run: missing command", file=sys.stderr) + return 1 + run(cmd, *args) # ty: ignore[missing-argument] return 0 opts = [] @@ -183,7 +211,14 @@ def main() -> int: if __name__ == "__main__": try: sys.exit(main()) - except subprocess.CalledProcessError as process: + except _RunError as process: if process.output: print(process.output, file=sys.stderr) - sys.exit(process.returncode) + if (code := process.returncode) == 139: # noqa: PLR2004 + print( + f"✗ (python{process.python_version}) '{' '.join(process.cmd)}' failed with return code {code} (segfault)", + file=sys.stderr, + ) + if process.python_version == PYTHON_DEV: + code = 0 + sys.exit(code) diff --git a/src/mkdocstrings_handlers/python/_internal/debug.py b/src/mkdocstrings_handlers/python/_internal/debug.py index 5fff669f..a3c99d75 100644 --- a/src/mkdocstrings_handlers/python/_internal/debug.py +++ b/src/mkdocstrings_handlers/python/_internal/debug.py @@ -85,7 +85,7 @@ def _get_debug_info() -> _Environment: interpreter_version=py_version, interpreter_path=sys.executable, platform=platform.platform(), - variables=[_Variable(var, val) for var in variables if (val := os.getenv(var))], + variables=[_Variable(var, val) for var in variables if (val := os.getenv(var))], # ty: ignore[invalid-argument-type] packages=[_Package(pkg, _get_version(pkg)) for pkg in packages], ) diff --git a/tests/test_api.py b/tests/test_api.py index 6d0b8738..099e2058 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -92,7 +92,7 @@ def _fixture_public_objects(public_api: griffe.Module) -> list[griffe.Object | g def _fixture_inventory() -> Inventory: inventory_file = Path(__file__).parent.parent / "site" / "objects.inv" if not inventory_file.exists(): - raise pytest.skip("The objects inventory is not available.") + pytest.skip("The objects inventory is not available.") # ty: ignore[call-non-callable] with inventory_file.open("rb") as file: return Inventory.parse_sphinx(file) @@ -138,7 +138,9 @@ def test_api_matches_inventory(inventory: Inventory, public_objects: list[griffe """All public objects are added to the inventory.""" ignore_names = {"__getattr__", "__init__", "__repr__", "__str__", "__post_init__"} not_in_inventory = [ - obj.path for obj in public_objects if obj.name not in ignore_names and obj.path not in inventory + f"{obj.relative_filepath}:{obj.lineno}: {obj.path}" + for obj in public_objects + if obj.name not in ignore_names and obj.path not in inventory ] msg = "Objects not in the inventory (try running `make run mkdocs build`):\n{paths}" assert not not_in_inventory, msg.format(paths="\n".join(sorted(not_in_inventory))) From 669b42ebd7c154c81764fa98c052cf857f7aa406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 13:49:13 +0100 Subject: [PATCH 04/16] feat: Release inheritance diagram features --- docs/usage/configuration/general.md | 137 ++++++++++ .../python/_internal/config.py | 8 + .../templates/material/_base/class.html.jinja | 48 ++++ .../templates/readthedocs/_base/class.html | 11 + .../readthedocs/_base/class.html.jinja | 251 ++++++++++++++++++ .../python/templates/readthedocs/class.html | 1 + .../templates/readthedocs/class.html.jinja | 1 + 7 files changed, 457 insertions(+) create mode 100644 src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html create mode 100644 src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html.jinja create mode 100644 src/mkdocstrings_handlers/python/templates/readthedocs/class.html create mode 100644 src/mkdocstrings_handlers/python/templates/readthedocs/class.html.jinja diff --git a/docs/usage/configuration/general.md b/docs/usage/configuration/general.md index 68899890..7d7b71e1 100644 --- a/docs/usage/configuration/general.md +++ b/docs/usage/configuration/general.md @@ -269,6 +269,143 @@ plugins: WARNING: **Packages are loaded only once.** When mkdocstrings-python collects data from a Python package (thanks to [Griffe](https://mkdocstrings.github.io/griffe/)), it collects *the entire package* and *caches it*. Next time an object from the same package is rendered, the package is retrieved from the cache and not collected again. The `force_inspection` option will therefore only have an effect the first time a package is collected, and will do nothing for objects rendered afterwards. +[](){#option-inheritance_diagram_direction} +## `inheritance_diagram_direction` + +The direction of the Mermaid chart presenting the inheritance diagram of a class, `TD` by default. + +```yaml title="mkdocs.yml" +extra_javascript: +- https://unpkg.com/mermaid@10.9.0/dist/mermaid.min.js +``` + +```yaml title="in mkdocs.yml (global configuration)" +plugins: +- mkdocstrings: + handlers: + python: + options: + inheritance_diagram_direction: TD +``` + +```md title="or in docs/some_page.md (local configuration)" +::: path.to.object + options: + inheritance_diagram_direction: TD +``` + +/// admonition | Preview + type: preview + + +With the following classes: + +```python +class SuperAbstract: + """Super abstract class.""" +class Mixin1: + """Mixin 1.""" +class Abstract(SuperAbstract, Mixin1): + """Abstract class.""" +class Mixin2A: + """Mixin 2A.""" +class Mixin2B(Mixin2A): + """Mixin 2B.""" +class Concrete(Abstract, Mixin2B): + """Concrete class.""" +class SuperConcrete(Concrete): + """Super concrete class.""" +``` + +//// tab | `TD` (or `TB`) + +```mermaid +flowchart TD +SuperConcrete[SuperConcrete] +Concrete[Concrete] +Abstract[Abstract] +SuperAbstract[SuperAbstract] +Mixin1[Mixin1] +Mixin2B[Mixin2B] +Mixin2A[Mixin2A] + +Concrete --> SuperConcrete +Abstract --> Concrete +SuperAbstract --> Abstract +Mixin1 --> Abstract +Mixin2B --> Concrete +Mixin2A --> Mixin2B +``` + +//// + +//// tab | `BT` + +```mermaid +flowchart BT +SuperConcrete[SuperConcrete] +Concrete[Concrete] +Abstract[Abstract] +SuperAbstract[SuperAbstract] +Mixin1[Mixin1] +Mixin2B[Mixin2B] +Mixin2A[Mixin2A] + +Concrete --> SuperConcrete +Abstract --> Concrete +SuperAbstract --> Abstract +Mixin1 --> Abstract +Mixin2B --> Concrete +Mixin2A --> Mixin2B +``` + +//// + +//// tab | `RL` + +```mermaid +flowchart RL +SuperConcrete[SuperConcrete] +Concrete[Concrete] +Abstract[Abstract] +SuperAbstract[SuperAbstract] +Mixin1[Mixin1] +Mixin2B[Mixin2B] +Mixin2A[Mixin2A] + +Concrete --> SuperConcrete +Abstract --> Concrete +SuperAbstract --> Abstract +Mixin1 --> Abstract +Mixin2B --> Concrete +Mixin2A --> Mixin2B +``` + +//// + +//// tab | `LR` + +```mermaid +flowchart LR +SuperConcrete[SuperConcrete] +Concrete[Concrete] +Abstract[Abstract] +SuperAbstract[SuperAbstract] +Mixin1[Mixin1] +Mixin2B[Mixin2B] +Mixin2A[Mixin2A] + +Concrete --> SuperConcrete +Abstract --> Concrete +SuperAbstract --> Abstract +Mixin1 --> Abstract +Mixin2B --> Concrete +Mixin2A --> Mixin2B +``` + +//// +/// + [](){#option-preload_modules} ## `preload_modules` diff --git a/src/mkdocstrings_handlers/python/_internal/config.py b/src/mkdocstrings_handlers/python/_internal/config.py index 62c124ba..e02d2fe1 100644 --- a/src/mkdocstrings_handlers/python/_internal/config.py +++ b/src/mkdocstrings_handlers/python/_internal/config.py @@ -560,6 +560,14 @@ class PythonInputOptions: ), ] = 2 + inheritance_diagram_direction: Annotated[ + Literal["TB", "TD", "BT", "RL", "LR"], + _Field( + group="docstrings", + description="The direction of the Mermaid chart presenting the inheritance diagram of a class.", + ), + ] = "TD" + inherited_members: Annotated[ bool | list[str], _Field( 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 23b3f458..0cd4ab4b 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja @@ -157,6 +157,54 @@ Context: {% endif %} {% endblock bases %} + {% block inheritance_diagram scoped %} + {#- Inheritance diagram block. + + This block renders the inheritance diagram for the class, + using Mermaid syntax and a bit of JavaScript to make the nodes clickable, + linking to the corresponding class documentation. + -#} + {% if config.show_inheritance_diagram and class.bases %} + {% macro edges(class) %} + {% for base in class.resolved_bases %} + {{ base.path }} --> {{ class.path }} + {{ edges(base) }} + {% endfor %} + {% endmacro %} +
+ + {% for base in class.mro() %} + + {% endfor %} +
+

+              flowchart {{ config.inheritance_diagram_direction }}
+              {{ class.path }}[{{ class.name }}]
+              {% for base in class.mro() %}
+              {{ base.path }}[{{ base.name }}]
+              {% endfor %}
+
+              {{ edges(class) | safe }}
+
+              click {{ class.path }} href "" "{{ class.path }}"
+              {% for base in class.mro() %}
+              click {{ base.path }} href "" "{{ base.path }}"
+              {% endfor %}
+            
+ + {% endif %} + {% endblock inheritance_diagram %} + {% block docstring scoped %} {#- Docstring block. diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html new file mode 100644 index 00000000..ac3e421e --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html @@ -0,0 +1,11 @@ +{% extends "_base/class.html.jinja" %} + +{% block logs scoped %} + {{ super() }} + {# TODO: Switch to a warning after some time. #} + {{ log.info( + "DeprecationWarning: Extending '_base/class.html' is deprecated, extend '_base/class.html.jinja' instead. " ~ + "After some time, this message will be logged as a warning, causing strict builds to fail.", + once=True, + ) }} +{% endblock logs %} diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html.jinja new file mode 100644 index 00000000..554485d7 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/class.html.jinja @@ -0,0 +1,251 @@ +{#- Template for Python classes. + +This template renders a Python class. + +Context: + class (griffe.Class): The class to render. + root (bool): Whether this is the root object, injected with `:::` in a Markdown page. + heading_level (int): The HTML heading level to use. + config (dict): The configuration options. +-#} + +{% block logs scoped %} + {#- Logging block. + + This block can be used to log debug messages, deprecation messages, warnings, etc. + -#} + {{ log.debug("Rendering " + class.path) }} +{% endblock logs %} + +
+ {% with obj = class, html_id = class.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 class_name = class.path if show_full_path else class.name %} + + {% if not root or config.show_root_heading %} + {% filter heading( + heading_level, + role="class", + id=html_id, + class="doc doc-heading", + toc_label=(' '|safe if config.show_symbol_type_toc else '') + class.name, + ) %} + + {% block heading scoped %} + {#- Heading block. + + This block renders the heading for the class. + -#} + {% if config.show_symbol_type_heading %}{% endif %} + {% if config.separate_signature %} + {{ class_name }} + {% elif config.merge_init_into_class and "__init__" in class.all_members %} + {% with function = class.all_members["__init__"] %} + {%+ filter highlight(language="python", inline=True) %} + {{ class_name }}{% include "signature"|get_template with context %} + {% endfilter %} + {% endwith %} + {% else %} + {{ class_name }} + {% endif %} + {% endblock heading %} + + {% block labels scoped %} + {#- Labels block. + + This block renders the labels for the class. + -#} + {% with labels = class.labels %} + {% include "labels"|get_template with context %} + {% endwith %} + {% endblock labels %} + + {% endfilter %} + + {% block signature scoped %} + {#- Signature block. + + This block renders the signature for the class. + -#} + {% if config.separate_signature and config.merge_init_into_class %} + {% if "__init__" in class.all_members %} + {% with function = class.all_members["__init__"] %} + {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} + {{ class.name }} + {% endfilter %} + {% endwith %} + {% endif %} + {% endif %} + {% endblock signature %} + + {% else %} + {% if config.show_root_toc_entry %} + {% filter heading(heading_level, + role="class", + id=html_id, + toc_label=(' '|safe if config.show_symbol_type_toc else '') + class.name, + hidden=True, + ) %} + {% endfilter %} + {% endif %} + {% set heading_level = heading_level - 1 %} + {% endif %} + +
+ {% block contents scoped %} + {#- Contents block. + + This block renders the contents of the class. + It contains other blocks that users can override. + Overriding the contents block allows to rearrange the order of the blocks. + -#} + {% block bases scoped %} + {#- Class bases block. + + This block renders the bases for the class. + -#} + {% if config.show_bases and class.bases %} +

+ Bases: {% for expression in class.bases -%} + {% include "expression"|get_template with context %}{% if not loop.last %}, {% endif %} + {% endfor -%} +

+ {% endif %} + {% endblock bases %} + + {% block inheritance_diagram scoped %} + {#- Inheritance diagram block. + + This block renders the inheritance diagram for the class, + using Mermaid syntax and a bit of JavaScript to make the nodes clickable, + linking to the corresponding class documentation. + -#} + {% if config.show_inheritance_diagram and class.bases %} + {% macro edges(class) %} + {% for base in class.resolved_bases %} + {{ base.path }} --> {{ class.path }} + {{ edges(base) }} + {% endfor %} + {% endmacro %} +
+ + {% for base in class.mro() %} + + {% endfor %} +
+
+ flowchart {{ config.inheritance_diagram_direction }} + {{ class.path }}[{{ class.name }}] + {% for base in class.mro() %} + {{ base.path }}[{{ base.name }}] + {% endfor %} + + {{ edges(class) | safe }} + + click {{ class.path }} href "" "{{ class.path }}" + {% for base in class.mro() %} + click {{ base.path }} href "" "{{ base.path }}" + {% endfor %} +
+ + {% endif %} + {% endblock inheritance_diagram %} + + {% block docstring scoped %} + {#- Docstring block. + + This block renders the docstring for the class. + -#} + {% with docstring_sections = class.docstring.parsed %} + {% include "docstring"|get_template with context %} + {% endwith %} + {% if config.merge_init_into_class %} + {% if "__init__" in class.all_members and class.all_members["__init__"].has_docstring %} + {% with function = class.all_members["__init__"] %} + {% with obj = function, docstring_sections = function.docstring.parsed %} + {% include "docstring"|get_template with context %} + {% endwith %} + {% endwith %} + {% endif %} + {% endif %} + {% endblock docstring %} + + {% block summary scoped %} + {#- Summary block. + + This block renders auto-summaries for classes, methods, and attributes. + -#} + {% include "summary"|get_template with context %} + {% endblock summary %} + + {% block source scoped %} + {#- Source block. + + This block renders the source code for the class. + -#} + {% if config.show_source %} + {% if config.merge_init_into_class %} + {% if "__init__" in class.all_members and class.all_members["__init__"].source %} + {% with init = class.all_members["__init__"] %} +
+ Source code in + {%- if init.relative_filepath.is_absolute() -%} + {{ init.relative_package_filepath }} + {%- else -%} + {{ init.relative_filepath }} + {%- endif -%} + + {{ init.source|highlight(language="python", linestart=init.lineno or 0, linenums=True) }} +
+ {% endwith %} + {% endif %} + {% elif class.source %} +
+ Source code in + {%- if class.relative_filepath.is_absolute() -%} + {{ class.relative_package_filepath }} + {%- else -%} + {{ class.relative_filepath }} + {%- endif -%} + + {{ class.source|highlight(language="python", linestart=class.lineno or 0, linenums=True) }} +
+ {% endif %} + {% endif %} + {% endblock source %} + + {% block children scoped %} + {#- Children block. + + This block renders the children (members) of the class. + -#} + {% set root = False %} + {% set heading_level = heading_level + 1 %} + {% include "children"|get_template with context %} + {% endblock children %} + {% endblock contents %} +
+ + {% endwith %} + +
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/class.html b/src/mkdocstrings_handlers/python/templates/readthedocs/class.html new file mode 100644 index 00000000..5e7329df --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/class.html @@ -0,0 +1 @@ +{% extends "_base/class.html.jinja" %} diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/class.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/class.html.jinja new file mode 100644 index 00000000..5e7329df --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/class.html.jinja @@ -0,0 +1 @@ +{% extends "_base/class.html.jinja" %} From fdaeb48a0f2208bafd14f2f7ead42bca37bea665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 13:50:30 +0100 Subject: [PATCH 05/16] feat: Release visually-lighter admonitions for source code blocks --- docs/insiders/changelog.md | 11 ++++++++- docs/insiders/goals.yml | 4 +++- .../templates/material/_base/class.html.jinja | 4 ++-- .../material/_base/function.html.jinja | 2 +- .../python/templates/material/style.css | 24 +++++++++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index b5717892..7898983c 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,7 +2,11 @@ ## mkdocstrings-python Insiders -### 1.12.0 March 22, 2025 { id="1.12.0" } +### 1.12.1 May 24, 2025 { id="1.12.1" } + +- Visually-lighter admonitions for source code blocks + +### 1.12.0 March 24, 2025 { id="1.12.0" } - [Ordering method: `__all__`][option-members_order] @@ -14,6 +18,11 @@ - [Backlinks][backlinks] +### 1.9.1 December 26, 2024 { id="1.9.1" } + +- Re-add class template for RTD theme +- Make inheritance diagrams rendering more robust + ### 1.9.0 September 03, 2024 { id="1.9.0" } - [Relative cross-references][relative_crossrefs] diff --git a/docs/insiders/goals.yml b/docs/insiders/goals.yml index 71128361..313322fd 100644 --- a/docs/insiders/goals.yml +++ b/docs/insiders/goals.yml @@ -50,4 +50,6 @@ goals: since: 2025/03/20 - name: "Ordering method: `__all__`" ref: /usage/configuration/members/#option-members_order - since: 2025/03/22 \ No newline at end of file + since: 2025/03/24 + - name: "Visually-lighter source code blocks" + since: 2025/05/24 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 0cd4ab4b..417afe41 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja @@ -252,7 +252,7 @@ Context: {% if config.merge_init_into_class %} {% if "__init__" in all_members and all_members["__init__"].source %} {% with init = all_members["__init__"] %} -
+
Source code in {%- if init.relative_filepath.is_absolute() -%} {{ init.relative_package_filepath }} @@ -265,7 +265,7 @@ Context: {% endwith %} {% endif %} {% elif class.source %} -
+
Source code in {%- if class.relative_filepath.is_absolute() -%} {{ class.relative_package_filepath }} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja index 708fde68..f296c214 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja @@ -149,7 +149,7 @@ Context: This block renders the source code for the function. -#} {% if config.show_source and function.source %} -
+
{{ lang.t("Source code in") }} {%- if function.relative_filepath.is_absolute() -%} {{ function.relative_package_filepath }} diff --git a/src/mkdocstrings_handlers/python/templates/material/style.css b/src/mkdocstrings_handlers/python/templates/material/style.css index 7475f5cd..7bb97041 100644 --- a/src/mkdocstrings_handlers/python/templates/material/style.css +++ b/src/mkdocstrings_handlers/python/templates/material/style.css @@ -210,3 +210,27 @@ code.doc-symbol-module::after { color: inherit; border-bottom: 1px dotted currentcolor; } + +/* Source code blocks (admonitions). */ +:root { + --md-admonition-icon--mkdocstrings-source: url('data:image/svg+xml;charset=utf-8,') +} +.md-typeset .admonition.mkdocstrings-source, +.md-typeset details.mkdocstrings-source { + border: none; + padding: 0; +} +.md-typeset .admonition.mkdocstrings-source:focus-within, +.md-typeset details.mkdocstrings-source:focus-within { + box-shadow: none; +} +.md-typeset .mkdocstrings-source > .admonition-title, +.md-typeset .mkdocstrings-source > summary { + background-color: inherit; +} +.md-typeset .mkdocstrings-source > .admonition-title::before, +.md-typeset .mkdocstrings-source > summary::before { + background-color: var(--md-default-fg-color); + -webkit-mask-image: var(--md-admonition-icon--mkdocstrings-source); + mask-image: var(--md-admonition-icon--mkdocstrings-source); +} From dbadd1e898bb2e67515077d152890bdbbf0b3eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 13:50:52 +0100 Subject: [PATCH 06/16] feat: Release expression modernization feature --- .../python/templates/material/_base/expression.html.jinja | 3 +++ 1 file changed, 3 insertions(+) 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 54781739..4f44ae00 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja @@ -166,4 +166,7 @@ Context: {%- endif -%} {%- endmacro -%} +{%- if config.modernize_annotations and expression is not string -%} + {%- set expression = expression.modernize() -%} +{%- endif -%} {{ render(expression, config.annotations_path, backlink_type|default("")) }} From ae7cc2d7d8ea5711d8ce06620edd534a3e2b47aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 13:51:19 +0100 Subject: [PATCH 07/16] feat: Release backlinks feature --- .../python/_internal/handler.py | 22 ++++++++- .../material/_base/backlinks.html.jinja | 49 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/mkdocstrings_handlers/python/_internal/handler.py b/src/mkdocstrings_handlers/python/_internal/handler.py index fbed2b8e..5945455d 100644 --- a/src/mkdocstrings_handlers/python/_internal/handler.py +++ b/src/mkdocstrings_handlers/python/_internal/handler.py @@ -22,15 +22,17 @@ patch_loggers, ) from mkdocs.exceptions import PluginError +from mkdocs_autorefs import BacklinkCrumb from mkdocstrings import BaseHandler, CollectionError, CollectorItem, HandlerOptions, Inventory, get_logger from mkdocstrings_handlers.python._internal import rendering from mkdocstrings_handlers.python._internal.config import PythonConfig, PythonOptions if TYPE_CHECKING: - from collections.abc import Iterator, Mapping, MutableMapping, Sequence + from collections.abc import Iterable, Iterator, Mapping, MutableMapping, Sequence from mkdocs.config.defaults import MkDocsConfig + from mkdocs_autorefs import Backlink # YORE: EOL 3.10: Replace block with line 2. @@ -306,6 +308,24 @@ def render(self, data: CollectorItem, options: PythonOptions, locale: str | None }, ) + def render_backlinks(self, backlinks: Mapping[str, Iterable[Backlink]], *, locale: str | None = None) -> str: # noqa: ARG002 + """Render the backlinks. + + Parameters: + backlinks: The backlinks to render. + + Returns: + The rendered backlinks (HTML). + """ + template = self.env.get_template("backlinks.html.jinja") + verbose_type = {key: key.capitalize().replace("-by", " by") for key in backlinks.keys()} # noqa: SIM118 + return template.render( + backlinks=backlinks, + config=self.get_options({}), + verbose_type=verbose_type, + default_crumb=BacklinkCrumb(title="", url=""), + ) + def update_env(self, config: Any) -> None: # noqa: ARG002 """Update the Jinja environment with custom filters and tests. diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja index 2ab16038..930da3e8 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/backlinks.html.jinja @@ -15,3 +15,52 @@ Context: This block can be used to log debug messages, deprecation messages, warnings, etc. -#} {% endblock logs %} + +{% macro render_crumb(crumb, last=false) %} + + {% if crumb.url and crumb.title %} + {{ crumb.title | safe }} + {% elif crumb.title %} + {{ crumb.title | safe }} + {% endif %} + +{% endmacro %} + +{% macro render_tree(tree) %} + +{% endmacro %} + +{% if config.backlinks %} + +{% endif %} From 3be14cc07bc9429d7ce01c748d825e2db1559212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 13:51:55 +0100 Subject: [PATCH 08/16] feat: Release public filter feature --- src/mkdocstrings_handlers/python/_internal/config.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mkdocstrings_handlers/python/_internal/config.py b/src/mkdocstrings_handlers/python/_internal/config.py index e02d2fe1..d3588e2d 100644 --- a/src/mkdocstrings_handlers/python/_internal/config.py +++ b/src/mkdocstrings_handlers/python/_internal/config.py @@ -1088,11 +1088,7 @@ class PythonOptions(PythonInputOptions): # type: ignore[override,unused-ignore] @classmethod def coerce(cls, **data: Any) -> MutableMapping[str, Any]: """Create an instance from a dictionary.""" - if "filters" in data: - # Non-insiders: transform back to default filters. - # Next: `if "filters" in data and not isinstance(data["filters"], str):`. - if data["filters"] == "public": - data["filters"] = _DEFAULT_FILTERS + if "filters" in data and not isinstance(data["filters"], str): # Filters are `None` or a sequence of strings (tests use tuples). data["filters"] = [ (re.compile(filtr.removeprefix("!")), filtr.startswith("!")) for filtr in data["filters"] or () From 84aaebcb4991c0245bf7ca8d7024c9d04942b0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 13:52:34 +0100 Subject: [PATCH 09/16] feat: Release `__all__` ordering feature --- .../python/_internal/rendering.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mkdocstrings_handlers/python/_internal/rendering.py b/src/mkdocstrings_handlers/python/_internal/rendering.py index 99aeb014..d95a55e4 100644 --- a/src/mkdocstrings_handlers/python/_internal/rendering.py +++ b/src/mkdocstrings_handlers/python/_internal/rendering.py @@ -62,8 +62,15 @@ def _sort_key_source(item: CollectorItem) -> float: return item.lineno if item.lineno is not None else float("inf") -def _sort__all__(item: CollectorItem) -> float: # noqa: ARG001 - raise ValueError("Not implemented in public version of mkdocstrings-python") +def _sort__all__(item: CollectorItem) -> float: + if item.parent.exports is not None: + try: + return item.parent.exports.index(item.name) + except ValueError: + # If the item is not in `__all__`, it will go to the end of the list. + return float("inf") + # No exports declared, refuse to sort (try other methods or return members as they are). + raise ValueError(f"Parent object {item.parent.path} doesn't declare exports") Order = Literal["__all__", "alphabetical", "source"] From 872afc584f33f50a133472afdc9355734a5e51ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 13:52:50 +0100 Subject: [PATCH 10/16] feat: Release scoped and relative cross-references --- .../python/_internal/rendering.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/mkdocstrings_handlers/python/_internal/rendering.py b/src/mkdocstrings_handlers/python/_internal/rendering.py index d95a55e4..ba51fcac 100644 --- a/src/mkdocstrings_handlers/python/_internal/rendering.py +++ b/src/mkdocstrings_handlers/python/_internal/rendering.py @@ -863,6 +863,33 @@ def expand_identifier(self, identifier: str) -> str: Returns: The expanded identifier. """ + # Handle leading dots in the identifier: + # - `.name` is a reference to the current object's `name` member. + # - `..name` is a reference to the parent object's `name` member. + # - etc. + # TODO: We should update the protocol to allow modifying the title too. + # In this case it would likely be better to strip dots from the title, + # when it's not explicitly specified. + if self.config.relative_crossrefs and identifier.startswith("."): # type: ignore[attr-defined] + identifier = identifier[1:] + obj = self.current_object + while identifier and identifier[0] == ".": + identifier = identifier[1:] + obj = obj.parent # type: ignore[assignment] + identifier = f"{obj.path}.{identifier}" if identifier else obj.path + + # We resolve the identifier to its full path. + # For this we take out the first name, resolve it, and then append the rest. + if self.config.scoped_crossrefs: # type: ignore[attr-defined] + if "." in identifier: + identifier, remaining = identifier.split(".", 1) + else: + remaining = "" + with suppress(Exception): + identifier = self.current_object.resolve(identifier) + if remaining: + identifier = f"{identifier}.{remaining}" + return identifier def get_context(self) -> AutorefsHookInterface.Context: From a99a5266ff3233dbca6e682805a0c4e0bb3fc5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 14:07:14 +0100 Subject: [PATCH 11/16] chore: Template upgrade --- .copier-answers.yml | 6 +- .github/workflows/ci.yml | 46 +++------ .github/workflows/release.yml | 21 +--- .github/workflows/sponsors.yml | 26 +++++ README.md | 5 + config/pytest_39.ini | 17 ---- docs/.overrides/main.html | 12 +-- docs/css/insiders.css | 124 ----------------------- docs/insiders/changelog.md | 103 -------------------- docs/insiders/goals.yml | 55 ----------- docs/insiders/index.md | 161 ------------------------------ docs/insiders/installation.md | 67 ------------- docs/js/insiders.js | 77 --------------- duties.py | 72 ++------------ mkdocs.yml | 12 +-- pyproject.toml | 3 +- scripts/insiders.py | 173 --------------------------------- scripts/make.py | 4 +- 18 files changed, 67 insertions(+), 917 deletions(-) create mode 100644 .github/workflows/sponsors.yml delete mode 100644 config/pytest_39.ini delete mode 100644 docs/css/insiders.css delete mode 100644 docs/insiders/changelog.md delete mode 100644 docs/insiders/goals.yml delete mode 100644 docs/insiders/index.md delete mode 100644 docs/insiders/installation.md delete mode 100644 docs/js/insiders.js delete mode 100644 scripts/insiders.py diff --git a/.copier-answers.yml b/.copier-answers.yml index 0d9a98c3..39641f11 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier. -_commit: 1.5.1 +_commit: 1.6.0 _src_path: gh:mkdocstrings/handler-template author_email: dev@pawamoy.fr author_fullname: Timothée Mazzucotelli @@ -8,13 +8,9 @@ copyright_date: '2021' copyright_holder: Timothée Mazzucotelli copyright_holder_email: dev@pawamoy.fr copyright_license: ISC -insiders: true -insiders_email: insiders@pawamoy.fr -insiders_repository_name: mkdocstrings-python language: Python project_description: A Python handler for mkdocstrings. project_name: mkdocstrings-python -public_release: true python_package_distribution_name: mkdocstrings-python python_package_import_name: python repository_name: python diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2399abb9..cde0a41b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,15 +34,15 @@ jobs: - macos-latest - windows-latest python-version: - - "3.9" - - "3.13" + - "3.10" + - "3.14" include: - - os: ubuntu-latest - python-version: "3.10" - os: ubuntu-latest python-version: "3.11" - os: ubuntu-latest python-version: "3.12" + - os: ubuntu-latest + python-version: "3.13" runs-on: ${{ matrix.os }} @@ -54,7 +54,7 @@ jobs: fetch-tags: true - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} @@ -81,39 +81,15 @@ jobs: - name: Store objects inventory for tests uses: actions/upload-artifact@v4 + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' }} with: name: objects.inv path: site/objects.inv - exclude-test-jobs: - runs-on: ubuntu-latest - outputs: - jobs: ${{ steps.exclude-jobs.outputs.jobs }} - steps: - - id: exclude-jobs - run: | - if ${{ github.repository_owner == 'pawamoy-insiders' }}; then - echo 'jobs=[ - {"os": "macos-latest"}, - {"os": "windows-latest"}, - {"python-version": "3.10"}, - {"python-version": "3.11"}, - {"python-version": "3.12"}, - {"python-version": "3.13"}, - {"python-version": "3.14"} - ]' | tr -d '[:space:]' >> $GITHUB_OUTPUT - else - echo 'jobs=[ - {"os": "macos-latest", "resolution": "lowest-direct"}, - {"os": "windows-latest", "resolution": "lowest-direct"} - ]' | tr -d '[:space:]' >> $GITHUB_OUTPUT - fi - tests: needs: - quality - - exclude-test-jobs strategy: max-parallel: 4 matrix: @@ -122,16 +98,20 @@ jobs: - macos-latest - windows-latest python-version: - - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" - "3.14" + - "3.15" resolution: - highest - lowest-direct - exclude: ${{ fromJSON(needs.exclude-test-jobs.outputs.jobs) }} + exclude: + - os: macos-latest + resolution: lowest-direct + - os: windows-latest + resolution: lowest-direct runs-on: ${{ matrix.os }} continue-on-error: true @@ -143,7 +123,7 @@ jobs: fetch-tags: true - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} allow-prereleases: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ef68f27..1c7cda36 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,30 +15,15 @@ jobs: fetch-depth: 0 fetch-tags: true - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: "3.12" + python-version: "3.13" - name: Setup uv uses: astral-sh/setup-uv@v5 - - name: Build dists - if: github.repository_owner == 'pawamoy-insiders' - run: uv tool run --from build pyproject-build - - name: Upload dists artifact - uses: actions/upload-artifact@v4 - if: github.repository_owner == 'pawamoy-insiders' - with: - name: python-insiders - path: ./dist/* - name: Prepare release notes - if: github.repository_owner != 'pawamoy-insiders' run: uv tool run git-changelog --release-notes > release-notes.md - - name: Create release with assets - uses: softprops/action-gh-release@v2 - if: github.repository_owner == 'pawamoy-insiders' - with: - files: ./dist/* - name: Create release uses: softprops/action-gh-release@v2 - if: github.repository_owner != 'pawamoy-insiders' with: body_path: release-notes.md + diff --git a/.github/workflows/sponsors.yml b/.github/workflows/sponsors.yml new file mode 100644 index 00000000..8dd9150f --- /dev/null +++ b/.github/workflows/sponsors.yml @@ -0,0 +1,26 @@ +name: Update sponsors + +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + update-readme: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Update README and create PR + uses: pawamoy/readme-insert@main + with: + markup-url: https://pawamoy.github.io/sponsors.txt + start-marker: '' + end-marker: '' + commit-message: 'chore: Update sponsors section in README' + pr-title: 'chore: Update sponsors section in README' + pr-body: 'This PR updates the sponsors section in the README file.' diff --git a/README.md b/README.md index 44507e72..485a1c0d 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,8 @@ dependencies = [ - **Source code display:** *mkdocstrings* can add a collapsible div containing the highlighted source code of the Python object. + +## Sponsors + + + diff --git a/config/pytest_39.ini b/config/pytest_39.ini deleted file mode 100644 index a876e994..00000000 --- a/config/pytest_39.ini +++ /dev/null @@ -1,17 +0,0 @@ -# YORE: EOL 3.9: Remove file. -# This file is used on 3.9 due to forward compatibility issue with filterwarnings. -# See https://github.com/pytest-dev/pytest/issues/11101. -[pytest] -python_files = - test_*.py -addopts = - --cov - --cov-config config/coverage.ini -testpaths = - tests - -# action:message_regex:warning_class:module_regex:line -filterwarnings = - error - # TODO: remove once pytest-xdist 4 is released - ignore:.*rsyncdir:DeprecationWarning:xdist diff --git a/docs/.overrides/main.html b/docs/.overrides/main.html index 5bedfd03..c702362f 100644 --- a/docs/.overrides/main.html +++ b/docs/.overrides/main.html @@ -1,13 +1,11 @@ {% extends "base.html" %} {% block announce %} - - Fund this project through - sponsorship - - {% include ".icons/octicons/heart-fill-16.svg" %} - — - + Fund this project through + sponsorship + + {% include ".icons/octicons/heart-fill-16.svg" %} + — Follow @pawamoy on diff --git a/docs/css/insiders.css b/docs/css/insiders.css deleted file mode 100644 index e7b9c74f..00000000 --- a/docs/css/insiders.css +++ /dev/null @@ -1,124 +0,0 @@ -@keyframes heart { - - 0%, - 40%, - 80%, - 100% { - transform: scale(1); - } - - 20%, - 60% { - transform: scale(1.15); - } -} - -@keyframes vibrate { - 0%, 2%, 4%, 6%, 8%, 10%, 12%, 14%, 16%, 18% { - -webkit-transform: translate3d(-2px, 0, 0); - transform: translate3d(-2px, 0, 0); - } - 1%, 3%, 5%, 7%, 9%, 11%, 13%, 15%, 17%, 19% { - -webkit-transform: translate3d(2px, 0, 0); - transform: translate3d(2px, 0, 0); - } - 20%, 100% { - -webkit-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0); - } -} - -.heart { - color: #e91e63; -} - -.pulse { - animation: heart 1000ms infinite; -} - -.vibrate { - animation: vibrate 2000ms infinite; -} - -.new-feature svg { - fill: var(--md-accent-fg-color) !important; -} - -a.insiders { - color: #e91e63; -} - -.sponsorship-list { - width: 100%; -} - -.sponsorship-item { - border-radius: 100%; - display: inline-block; - height: 1.6rem; - margin: 0.1rem; - overflow: hidden; - width: 1.6rem; -} - -.sponsorship-item:focus, .sponsorship-item:hover { - transform: scale(1.1); -} - -.sponsorship-item img { - filter: grayscale(100%) opacity(75%); - height: auto; - width: 100%; -} - -.sponsorship-item:focus img, .sponsorship-item:hover img { - filter: grayscale(0); -} - -.sponsorship-item.private { - background: var(--md-default-fg-color--lightest); - color: var(--md-default-fg-color); - font-size: .6rem; - font-weight: 700; - line-height: 1.6rem; - text-align: center; -} - -.mastodon { - color: #897ff8; - border-radius: 100%; - box-shadow: inset 0 0 0 .05rem currentcolor; - display: inline-block; - height: 1.2rem !important; - padding: .25rem; - transition: all .25s; - vertical-align: bottom !important; - width: 1.2rem; -} - -.premium-sponsors { - text-align: center; -} - -#silver-sponsors img { - height: 140px; -} - -#bronze-sponsors img { - height: 140px; -} - -#bronze-sponsors p { - display: flex; - flex-wrap: wrap; - justify-content: center; -} - -#bronze-sponsors a { - display: block; - flex-shrink: 0; -} - -.sponsors-total { - font-weight: bold; -} \ No newline at end of file diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md deleted file mode 100644 index 7898983c..00000000 --- a/docs/insiders/changelog.md +++ /dev/null @@ -1,103 +0,0 @@ -# Changelog - -## mkdocstrings-python Insiders - -### 1.12.1 May 24, 2025 { id="1.12.1" } - -- Visually-lighter admonitions for source code blocks - -### 1.12.0 March 24, 2025 { id="1.12.0" } - -- [Ordering method: `__all__`][option-members_order] - -### 1.11.0 March 20, 2025 { id="1.11.0" } - -- [Filtering method: `public`][option-filters-public] - -### 1.10.0 March 10, 2025 { id="1.10.0" } - -- [Backlinks][backlinks] - -### 1.9.1 December 26, 2024 { id="1.9.1" } - -- Re-add class template for RTD theme -- Make inheritance diagrams rendering more robust - -### 1.9.0 September 03, 2024 { id="1.9.0" } - -- [Relative cross-references][relative_crossrefs] -- [Scoped cross-references][scoped_crossrefs] - -### 1.8.3 June 19, 2024 { id="1.8.3" } - -- Update code for Griffe 0.46+ to avoid deprecation warnings - -### 1.8.2 May 09, 2024 { id="1.8.2" } - -- Don't render cross-refs for default values when signatures aren't separated - -### 1.8.1 April 19, 2024 { id="1.8.1" } - -- Render enumeration instance name instead of just "value", allowing proper cross-reference - -### 1.8.0 March 24, 2024 { id="1.8.0" } - -- [Annotations modernization][modernize_annotations] - -### 1.7.0 March 24, 2024 { id="1.7.0" } - -- [Class inheritance diagrams with Mermaid][show_inheritance_diagram] - -### 1.6.0 January 30, 2024 { id="1.6.0" } - -- Render cross-references to parameters documentation in signatures and attribute values. -- Add [`parameter_headings`][parameter_headings] option to render headings for parameters (enabling permalinks and ToC/inventory entries). -- Render cross-references for default parameter values in signatures. - -### 1.5.1 September 12, 2023 { id="1.5.1" } - -- Prevent empty auto-summarized Methods section. - -### 1.5.0 September 05, 2023 { id="1.5.0" } - -- Render function signature overloads. - -### 1.4.0 August 27, 2023 { id="1.4.0" } - -- Render cross-references in attribute signatures. - -### 1.3.0 August 24, 2023 { id="1.3.0" } - -- Add "method" symbol type. - -### 1.2.0 August 20, 2023 { id="1.2.0" } - -- Add [member auto-summaries](../usage/configuration/members.md#summary). - -### 1.1.4 July 17, 2023 { id="1.1.4" } - -- Fix heading level increment for class members. - -### 1.1.3 July 17, 2023 { id="1.1.3" } - -- Fix heading level (avoid with clause preventing to decrease it). - -### 1.1.2 July 15, 2023 { id="1.1.2" } - -- Use non-breaking spaces after symbol types. - -### 1.1.1 June 27, 2023 { id="1.1.1" } - -- Correctly escape expressions in signatures and other rendered types. - -### 1.1.0 June 4, 2023 { id="1.1.0" } - -- Add [Symbol types in headings and table of contents](../usage/configuration/headings.md#show_symbol_type_toc). - -### 1.0.0 May 10, 2023 { id="1.0.0" } - -- Add [cross-references for type annotations in signatures](../usage/configuration/signatures.md#signature_crossrefs). - Make sure to update your local templates as the signature of the - [`format_signature` filter][mkdocstrings_handlers.python.do_format_signature] - has changed. The templates that must be updated: - `class.html`, `expression.html`, `function.html` and `signature.html`. diff --git a/docs/insiders/goals.yml b/docs/insiders/goals.yml deleted file mode 100644 index 313322fd..00000000 --- a/docs/insiders/goals.yml +++ /dev/null @@ -1,55 +0,0 @@ -goals: - 500: - name: PlasmaVac User Guide - features: - - name: Cross-references for type annotations in signatures - ref: /usage/configuration/signatures/#signature_crossrefs - since: 2023/05/10 - - name: Symbol types in headings and table of contents - ref: /usage/configuration/headings/#show_symbol_type_toc - since: 2023/06/04 - 1000: - name: GraviFridge Fluid Renewal - features: - - name: Auto-summary of object members - ref: /usage/configuration/members/#summary - since: 2023/08/20 - - name: Automatic rendering of function signature overloads - since: 2023/09/05 - - name: Parameter headings - ref: /usage/configuration/headings/#parameter_headings - since: 2024/01/30 - - name: Automatic cross-references to parameters - ref: /usage/configuration/headings/#parameter_headings - since: 2024/01/30 - - name: Automatic cross-references for default parameter values in signatures - since: 2024/01/30 - 1500: - name: HyperLamp Navigation Tips - features: - - name: Class inheritance diagrams with Mermaid - ref: /usage/configuration/general/#show_inheritance_diagram - since: 2024/03/24 - - name: Annotations modernization - ref: /usage/configuration/signatures/#modernize_annotations - since: 2024/03/24 - 2000: - name: FusionDrive Ejection Configuration - features: - - name: Relative cross-references - ref: /usage/configuration/docstrings/#relative_crossrefs - since: 2024/09/03 - - name: Scoped cross-references - ref: /usage/configuration/docstrings/#scoped_crossrefs - since: 2024/09/03 - - name: Backlinks - ref: /usage/configuration/general/#backlinks - since: 2025/03/10 - - name: "Filtering method: `public`" - ref: /usage/configuration/members/#option-filters-public - since: 2025/03/20 - - name: "Ordering method: `__all__`" - ref: /usage/configuration/members/#option-members_order - since: 2025/03/24 - - name: "Visually-lighter source code blocks" - since: 2025/05/24 diff --git a/docs/insiders/index.md b/docs/insiders/index.md deleted file mode 100644 index f184961f..00000000 --- a/docs/insiders/index.md +++ /dev/null @@ -1,161 +0,0 @@ ---- -title: Insiders ---- - -# Insiders - -*mkdocstrings-python* follows the **sponsorware** release strategy, which means that new features are first exclusively released to sponsors as part of [Insiders][]. Read on to learn [what sponsorships achieve][sponsorship], [how to become a sponsor][sponsors] to get access to Insiders, and [what's in it for you][features]! - -## What is Insiders? - -*mkdocstrings-python Insiders* is a private fork of *mkdocstrings-python*, hosted as a private GitHub repository. Almost[^1] [all new features][features] are developed as part of this fork, which means that they are immediately available to all eligible sponsors, as they are granted access to this private repository. - -[^1]: In general, every new feature is first exclusively released to sponsors, but sometimes upstream dependencies enhance existing features that must be supported by *mkdocstrings-python*. - -Every feature is tied to a [funding goal][funding] in monthly subscriptions. When a funding goal is hit, the features that are tied to it are merged back into *mkdocstrings-python* and released for general availability, making them available to all users. Bugfixes are always released in tandem. - -Sponsorships start as low as [**$10 a month**][sponsors].[^2] - -[^2]: Note that $10 a month is the minimum amount to become eligible for Insiders. While GitHub Sponsors also allows to sponsor lower amounts or one-time amounts, those can't be granted access to Insiders due to technical reasons. Such contributions are still very much welcome as they help ensuring the project's sustainability. - -## What sponsorships achieve - -Sponsorships make this project sustainable, as they buy the maintainers of this project time – a very scarce resource – which is spent on the development of new features, bug fixing, stability improvement, issue triage and general support. The biggest bottleneck in Open Source is time.[^3] - -[^3]: Making an Open Source project sustainable is exceptionally hard: maintainers burn out, projects are abandoned. That's not great and very unpredictable. The sponsorware model ensures that if you decide to use *mkdocstrings-python*, you can be sure that bugs are fixed quickly and new features are added regularly. - -If you're unsure if you should sponsor this project, check out the list of [completed funding goals][goals completed] to learn whether you're already using features that were developed with the help of sponsorships. You're most likely using at least a handful of them, [thanks to our awesome sponsors][sponsors]! - -## What's in it for me? - -```python exec="1" session="insiders" -data_source = [ - "docs/insiders/goals.yml", - ("griffe-inherited-docstrings", "https://mkdocstrings.github.io/griffe-inherited-docstrings/", "insiders/goals.yml"), - ("griffe-pydantic", "https://mkdocstrings.github.io/griffe-pydantic/", "insiders/goals.yml"), - ("griffe-warnings-deprecated", "https://mkdocstrings.github.io/griffe-warnings-deprecated/", "insiders/goals.yml"), -] -``` - - -```python exec="1" session="insiders" idprefix="" ---8<-- "scripts/insiders.py" - -if unreleased_features: - print( - "The moment you [become a sponsor](#how-to-become-a-sponsor), you'll get **immediate " - f"access to {len(unreleased_features)} additional features** that you can start using right away, and " - "which are currently exclusively available to sponsors:\n" - ) - - for feature in unreleased_features: - feature.render(badge=True) - - print( - "\n\nThese are just the features related to this project. " - "[See the complete feature list on the author's main Insiders page](https://pawamoy.github.io/insiders/#whats-in-it-for-me)." - ) -else: - print( - "The moment you [become a sponsor](#how-to-become-a-sponsor), you'll get immediate " - "access to all released features that you can start using right away, and " - "which are exclusively available to sponsors. At this moment, there are no " - "Insiders features for this project, but checkout the [next funding goals](#goals) " - "to see what's coming, as well as **[the feature list for all Insiders projects](https://pawamoy.github.io/insiders/#whats-in-it-for-me).**" - ) -``` - - -Additionally, your sponsorship will give more weight to your upvotes on issues, helping us prioritize work items in our backlog. For more information on how we prioritize work, see this page: [Backlog management][backlog]. - -## How to become a sponsor - -Thanks for your interest in sponsoring! In order to become an eligible sponsor with your GitHub account, visit [pawamoy's sponsor profile][github sponsor profile], and complete a sponsorship of **$10 a month or more**. You can use your individual or organization GitHub account for sponsoring. - -Sponsorships lower than $10 a month are also very much appreciated, and useful. They won't grant you access to Insiders, but they will be counted towards reaching sponsorship goals. Every sponsorship helps us implementing new features and releasing them to the public. - -**Important:** By default, when you're sponsoring **[@pawamoy][github sponsor profile]** through a GitHub organization, all the publicly visible members of the organization will be invited to join our private repositories. If you wish to only grant access to a subset of users, please send a short email to insiders@pawamoy.fr with the name of your organization and the GitHub accounts of the users that should be granted access. - -**Tip:** to ensure that access is not tied to a particular individual GitHub account, you can create a bot account (i.e. a GitHub account that is not tied to a specific individual), and use this account for the sponsoring. After being granted access to our private repositories, the bot account can create private forks of our private repositories into your own organization, which all members of your organization will have access to. - -You can cancel your sponsorship anytime.[^5] - -[^5]: If you cancel your sponsorship, GitHub schedules a cancellation request which will become effective at the end of the billing cycle. This means that even though you cancel your sponsorship, you will keep your access to Insiders as long as your cancellation isn't effective. All charges are processed by GitHub through Stripe. As we don't receive any information regarding your payment, and GitHub doesn't offer refunds, sponsorships are non-refundable. - -[:octicons-heart-fill-24:{ .pulse }   Join our awesome sponsors][github sponsor profile]{ .md-button .md-button--primary } - -
-
-
-
-
-
-
- -
- - - If you sponsor publicly, you're automatically added here with a link to your profile and avatar to show your support for *mkdocstrings-python*. Alternatively, if you wish to keep your sponsorship private, you'll be a silent +1. You can select visibility during checkout and change it afterwards. - - -## Funding - -### Goals - -The following section lists all funding goals. Each goal contains a list of features prefixed with a checkmark symbol, denoting whether a feature is :octicons-check-circle-fill-24:{ style="color: #00e676" } already available or :octicons-check-circle-fill-24:{ style="color: var(--md-default-fg-color--lightest)" } planned, but not yet implemented. When the funding goal is hit, the features are released for general availability. - -```python exec="1" session="insiders" idprefix="" -for goal in goals.values(): - if not goal.complete: - goal.render() -``` - -### Goals completed - -This section lists all funding goals that were previously completed, which means that those features were part of Insiders, but are now generally available and can be used by all users. - -```python exec="1" session="insiders" idprefix="" -for goal in goals.values(): - if goal.complete: - goal.render() -``` - -## Frequently asked questions - -### Compatibility - -> We're building an open source project and want to allow outside collaborators to use *mkdocstrings-python* locally without having access to Insiders. Is this still possible? - -Yes. Insiders is compatible with *mkdocstrings-python*. Almost all new features and configuration options are either backward-compatible or implemented behind feature flags. Most Insiders features enhance the overall experience, though while these features add value for the users of your project, they shouldn't be necessary for previewing when making changes to content. - -### Payment - -> We don't want to pay for sponsorship every month. Are there any other options? - -Yes. You can sponsor on a yearly basis by [switching your GitHub account to a yearly billing cycle][billing cycle]. If for some reason you cannot do that, you could also create a dedicated GitHub account with a yearly billing cycle, which you only use for sponsoring (some sponsors already do that). - -If you have any problems or further questions, please reach out to insiders@pawamoy.fr. - -### Terms - -> Are we allowed to use Insiders under the same terms and conditions as *mkdocstrings-python*? - -Yes. Whether you're an individual or a company, you may use *mkdocstrings-python Insiders* precisely under the same terms as *mkdocstrings-python*, which are given by the [ISC license][license]. However, we kindly ask you to respect our **fair use policy**: - -- Please **don't distribute the source code** of Insiders. You may freely use it for public, private or commercial projects, privately fork or mirror it, but please don't make the source code public, as it would counteract the sponsorware strategy. -- If you cancel your subscription, your access to the private repository is revoked, and you will miss out on all future updates of Insiders. However, you may **use the latest version** that's available to you **as long as you like**. Just remember that [GitHub deletes private forks][private forks]. - -[backlog]: https://pawamoy.github.io/backlog/ -[insiders]: #what-is-insiders -[sponsorship]: #what-sponsorships-achieve -[sponsors]: #how-to-become-a-sponsor -[features]: #whats-in-it-for-me -[funding]: #funding -[goals completed]: #goals-completed -[github sponsor profile]: https://github.com/sponsors/pawamoy -[billing cycle]: https://docs.github.com/en/github/setting-up-and-managing-billing-and-payments-on-github/changing-the-duration-of-your-billing-cycle -[license]: ../license.md -[private forks]: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/removing-a-collaborator-from-a-personal-repository - - - diff --git a/docs/insiders/installation.md b/docs/insiders/installation.md deleted file mode 100644 index 3e20e5d7..00000000 --- a/docs/insiders/installation.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -title: Getting started with Insiders ---- - -# Getting started with Insiders - -*mkdocstrings-python Insiders* is a compatible drop-in replacement for *mkdocstrings-python*, and can be installed similarly using `pip` or `git`. Note that in order to access the Insiders repository, you need to [become an eligible sponsor][] of @pawamoy on GitHub. - -## Installation - -### with the `insiders` tool - -[`insiders`][insiders-tool] is a tool that helps you keep up-to-date versions of Insiders projects in the PyPI index of your choice (self-hosted, Google registry, Artifactory, etc.). - -**We kindly ask that you do not upload the distributions to public registries, as it is against our [Terms of use][].** - -### with pip (ssh/https) - -*mkdocstrings-python Insiders* can be installed with `pip` [using SSH][install-pip-ssh]: - -```bash -pip install git+ssh://git@github.com/pawamoy-insiders/mkdocstrings-python.git -``` - -Or using HTTPS: - -```bash -pip install git+https://${GH_TOKEN}@github.com/pawamoy-insiders/mkdocstrings-python.git -``` - ->? NOTE: **How to get a GitHub personal access token?** The `GH_TOKEN` environment variable is a GitHub token. It can be obtained by creating a [personal access token][github-pat] for your GitHub account. It will give you access to the Insiders repository, programmatically, from the command line or GitHub Actions workflows: -> -> 1. Go to https://github.com/settings/tokens -> 2. Click on [Generate a new token][github-pat-new] -> 3. Enter a name and select the [`repo`][scopes] scope -> 4. Generate the token and store it in a safe place -> -> Note that the personal access token must be kept secret at all times, as it allows the owner to access your private repositories. - -### with Git - -Of course, you can use *mkdocstrings-python Insiders* directly using Git: - -``` -git clone git@github.com:pawamoy-insiders/mkdocstrings-python -``` - -When cloning with Git, the package must be installed: - -``` -pip install -e mkdocstrings-python -``` - -## Upgrading - -When upgrading Insiders, you should always check the version of *mkdocstrings-python* which makes up the first part of the version qualifier. For example, a version like `8.x.x.4.x.x` means that Insiders `4.x.x` is currently based on `8.x.x`. - -If the major version increased, it's a good idea to consult the [changelog][] and go through the steps to ensure your configuration is up to date and all necessary changes have been made. - -[become an eligible sponsor]: ./index.md#how-to-become-a-sponsor -[changelog]: ./changelog.md -[github-pat]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token -[github-pat-new]: https://github.com/settings/tokens/new -[insiders-tool]: https://pawamoy.github.io/insiders-project/ -[install-pip-ssh]: https://docs.github.com/en/authentication/connecting-to-github-with-ssh -[scopes]: https://docs.github.com/en/developers/apps/scopes-for-oauth-apps#available-scopes -[terms of use]: ./index.md#terms diff --git a/docs/js/insiders.js b/docs/js/insiders.js deleted file mode 100644 index a86a0918..00000000 --- a/docs/js/insiders.js +++ /dev/null @@ -1,77 +0,0 @@ -function humanReadableAmount(amount) { - const strAmount = String(amount); - if (strAmount.length >= 4) { - return `${strAmount.slice(0, strAmount.length - 3)},${strAmount.slice(-3)}`; - } - return strAmount; -} - -function getJSON(url, callback) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.responseType = 'json'; - xhr.onload = function () { - var status = xhr.status; - if (status === 200) { - callback(null, xhr.response); - } else { - callback(status, xhr.response); - } - }; - xhr.send(); -} - -function updatePremiumSponsors(dataURL, rank) { - let capRank = rank.charAt(0).toUpperCase() + rank.slice(1); - getJSON(dataURL + `/sponsors${capRank}.json`, function (err, sponsors) { - const sponsorsDiv = document.getElementById(`${rank}-sponsors`); - if (sponsors.length > 0) { - let html = ''; - html += `${capRank} sponsors

` - sponsors.forEach(function (sponsor) { - html += `` - if (sponsor.image) { - html += `${sponsor.name}` - } else if (sponsor.imageLight && sponsor.imageDark) { - html += `${sponsor.name}` - html += `${sponsor.name}` - } - html += ''; - }); - html += '

' - sponsorsDiv.innerHTML = html; - } - }); -} - -function updateInsidersPage(author_username) { - const sponsorURL = `https://github.com/sponsors/${author_username}` - const dataURL = `https://raw.githubusercontent.com/${author_username}/sponsors/main`; - getJSON(dataURL + '/numbers.json', function (err, numbers) { - document.getElementById('sponsors-count').innerHTML = numbers.count; - Array.from(document.getElementsByClassName('sponsors-total')).forEach(function (element) { - element.innerHTML = '$ ' + humanReadableAmount(numbers.total); - }); - getJSON(dataURL + '/sponsors.json', function (err, sponsors) { - const sponsorsElem = document.getElementById('sponsors'); - const privateSponsors = numbers.count - sponsors.length; - sponsors.forEach(function (sponsor) { - sponsorsElem.innerHTML += ` - - - - `; - }); - if (privateSponsors > 0) { - sponsorsElem.innerHTML += ` - - +${privateSponsors} - - `; - } - }); - }); - updatePremiumSponsors(dataURL, "gold"); - updatePremiumSponsors(dataURL, "silver"); - updatePremiumSponsors(dataURL, "bronze"); -} diff --git a/duties.py b/duties.py index 41df37b6..a21c3b8e 100644 --- a/duties.py +++ b/duties.py @@ -6,10 +6,9 @@ import re import sys from contextlib import contextmanager -from functools import wraps from importlib.metadata import version as pkgversion from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable +from typing import TYPE_CHECKING from duty import duty, tools @@ -37,21 +36,6 @@ def pyprefix(title: str) -> str: return title -def not_from_insiders(func: Callable) -> Callable: - @wraps(func) - def wrapper(ctx: Context, *args: Any, **kwargs: Any) -> None: - origin = ctx.run("git config --get remote.origin.url", silent=True) - if "pawamoy-insiders/griffe" in origin: - ctx.run( - lambda: False, - title="Not running this task from insiders repository (do that from public repo instead!)", - ) - return - func(ctx, *args, **kwargs) - - return wrapper - - @contextmanager def material_insiders() -> Iterator[bool]: if "+insiders" in pkgversion("mkdocs-material"): @@ -147,39 +131,13 @@ def docs(ctx: Context, *cli_args: str, host: str = "127.0.0.1", port: int = 8000 @duty(skip_if=sys.version_info < (3, 13), skip_reason=pyprefix("Skipped: docs require modern generics syntax")) -def docs_deploy(ctx: Context, *, force: bool = False) -> None: - """Deploy the documentation to GitHub pages. - - Parameters: - force: Whether to force deployment, even from non-Insiders version. - """ +def docs_deploy(ctx: Context) -> None: + """Deploy the documentation to GitHub pages.""" os.environ["DEPLOY"] = "true" with material_insiders() as insiders: if not insiders: ctx.run(lambda: False, title="Not deploying docs without Material for MkDocs Insiders!") - origin = ctx.run("git config --get remote.origin.url", silent=True, allow_overrides=False) - if "pawamoy-insiders/mkdocstrings-python" in origin: - ctx.run( - "git remote add upstream git@github.com:mkdocstrings/python", - silent=True, - nofail=True, - allow_overrides=False, - ) - ctx.run( - tools.mkdocs.gh_deploy(remote_name="upstream", force=True), - title="Deploying documentation", - ) - elif force: - ctx.run( - tools.mkdocs.gh_deploy(force=True), - title="Deploying documentation", - ) - else: - ctx.run( - lambda: False, - title="Not deploying docs from public repository (do that from insiders instead!)", - nofail=True, - ) + ctx.run(tools.mkdocs.gh_deploy(force=True), title="Deploying documentation") @duty @@ -203,7 +161,6 @@ def build(ctx: Context) -> None: @duty -@not_from_insiders def publish(ctx: Context) -> None: """Publish source and wheel distributions to PyPI.""" if not Path("dist").exists(): @@ -217,7 +174,6 @@ def publish(ctx: Context) -> None: @duty(post=["build", "publish", "docs-deploy"]) -@not_from_insiders def release(ctx: Context, version: str = "") -> None: """Release a new Python package. @@ -228,7 +184,7 @@ def release(ctx: Context, version: str = "") -> None: ctx.run("false", title="A version must be provided") ctx.run("git add pyproject.toml CHANGELOG.md", title="Staging files", pty=PTY) ctx.run(["git", "commit", "-m", f"chore: Prepare release {version}"], title="Committing changes", pty=PTY) - ctx.run(f"git tag {version}", title="Tagging commit", pty=PTY) + ctx.run(f"git tag -m '' -a {version}", title="Tagging commit", pty=PTY) ctx.run("git push", title="Pushing commits", pty=False) ctx.run("git push --tags", title="Pushing tags", pty=False) @@ -242,13 +198,8 @@ def coverage(ctx: Context) -> None: @duty(nofail=PY_VERSION == PY_DEV) -def test(ctx: Context, *cli_args: str, match: str = "", snapshot: str = "report") -> None: # noqa: PT028 - """Run the test suite. - - Parameters: - match: A pytest expression to filter selected tests. - snapshot: Whether to "create", "fix", "trim", or "update" snapshots. - """ +def test(ctx: Context, *cli_args: str, snapshot: str = "report") -> None: + """Run the test suite.""" os.environ["COVERAGE_FILE"] = f".coverage.{PY_VERSION}" os.environ["PYTHONWARNDEFAULTENCODING"] = "1" args = list(cli_args) @@ -256,17 +207,10 @@ def test(ctx: Context, *cli_args: str, match: str = "", snapshot: str = "report" args = ["-n", "auto", "--inline-snapshot=disable"] else: args = [f"--inline-snapshot={snapshot}"] - - config_file = "config/pytest.ini" - # YORE: EOL 3.9: Remove block. - if sys.version_info[:2] < (3, 10): - config_file = "config/pytest_39.ini" - ctx.run( tools.pytest( "tests", - config_file=config_file, - select=match, + config_file="config/pytest.ini", color="yes", ).add_args(*args), title=pyprefix("Running tests"), diff --git a/mkdocs.yml b/mkdocs.yml index 0796e003..f7b3b7a2 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -41,13 +41,8 @@ nav: - Development: - Contributing: contributing.md - Code of Conduct: code_of_conduct.md - # - Coverage report: coverage.md -- Insiders: - - insiders/index.md - - Getting started: - - Installation: insiders/installation.md - - Changelog: insiders/changelog.md -- mkdocstrings: https://mkdocstrings.github.io/ + - Coverage report: coverage.md + - mkdocstrings: https://mkdocstrings.github.io/ theme: name: material @@ -93,7 +88,6 @@ theme: extra_css: - css/material.css - css/mkdocstrings.css -- css/insiders.css extra_javascript: - js/feedback.js @@ -177,7 +171,7 @@ plugins: show_root_full_path: false show_signature_annotations: true show_signature_type_parameters: true - show_source: false + show_source: true show_symbol_type_heading: true show_symbol_type_toc: true signature_crossrefs: true diff --git a/pyproject.toml b/pyproject.toml index ad0c852c..2d6c7188 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ authors = [{name = "Timothée Mazzucotelli", email = "dev@pawamoy.fr"}] license = "ISC" license-files = ["LICENSE"] readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.10" keywords = [] dynamic = ["version"] classifiers = [ @@ -18,7 +18,6 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", diff --git a/scripts/insiders.py b/scripts/insiders.py deleted file mode 100644 index 4cd438d4..00000000 --- a/scripts/insiders.py +++ /dev/null @@ -1,173 +0,0 @@ -# Functions related to Insiders funding goals. - -from __future__ import annotations - -import json -import logging -import os -import posixpath -from dataclasses import dataclass -from datetime import date, datetime, timedelta -from itertools import chain -from pathlib import Path -from typing import TYPE_CHECKING, cast -from urllib.error import HTTPError -from urllib.parse import urljoin -from urllib.request import urlopen - -import yaml - -if TYPE_CHECKING: - from collections.abc import Iterable - -logger = logging.getLogger(f"mkdocs.logs.{__name__}") - - -def human_readable_amount(amount: int) -> str: - str_amount = str(amount) - if len(str_amount) >= 4: # noqa: PLR2004 - return f"{str_amount[: len(str_amount) - 3]},{str_amount[-3:]}" - return str_amount - - -@dataclass -class Project: - name: str - url: str - - -@dataclass -class Feature: - name: str - ref: str | None - since: date | None - project: Project | None - - def url(self, rel_base: str = "..") -> str | None: # noqa: D102 - if not self.ref: - return None - if self.project: - rel_base = self.project.url - return posixpath.join(rel_base, self.ref.lstrip("/")) - - def render(self, rel_base: str = "..", *, badge: bool = False) -> None: # noqa: D102 - new = "" - if badge: - recent = self.since and date.today() - self.since <= timedelta(days=60) # noqa: DTZ011 - if recent: - ft_date = self.since.strftime("%B %d, %Y") # type: ignore[union-attr] - new = f' :material-alert-decagram:{{ .new-feature .vibrate title="Added on {ft_date}" }}' - project = f"[{self.project.name}]({self.project.url}) — " if self.project else "" - feature = f"[{self.name}]({self.url(rel_base)})" if self.ref else self.name - print(f"- [{'x' if self.since else ' '}] {project}{feature}{new}") - - -@dataclass -class Goal: - name: str - amount: int - features: list[Feature] - complete: bool = False - - @property - def human_readable_amount(self) -> str: # noqa: D102 - return human_readable_amount(self.amount) - - def render(self, rel_base: str = "..") -> None: # noqa: D102 - print(f"#### $ {self.human_readable_amount} — {self.name}\n") - if self.features: - for feature in self.features: - feature.render(rel_base) - print("") - else: - print("There are no features in this goal for this project. ") - print( - "[See the features in this goal **for all Insiders projects.**]" - f"(https://pawamoy.github.io/insiders/#{self.amount}-{self.name.lower().replace(' ', '-')})", - ) - - -def load_goals(data: str, funding: int = 0, project: Project | None = None) -> dict[int, Goal]: - goals_data = yaml.safe_load(data)["goals"] - return { - amount: Goal( - name=goal_data["name"], - amount=amount, - complete=funding >= amount, - features=[ - Feature( - name=feature_data["name"], - ref=feature_data.get("ref"), - since=feature_data.get("since") and datetime.strptime(feature_data["since"], "%Y/%m/%d").date(), # noqa: DTZ007 - project=project, - ) - for feature_data in goal_data["features"] - ], - ) - for amount, goal_data in goals_data.items() - } - - -def _load_goals_from_disk(path: str, funding: int = 0) -> dict[int, Goal]: - project_dir = os.getenv("MKDOCS_CONFIG_DIR", ".") - try: - data = Path(project_dir, path).read_text() - except OSError as error: - raise RuntimeError(f"Could not load data from disk: {path}") from error - return load_goals(data, funding) - - -def _load_goals_from_url(source_data: tuple[str, str, str], funding: int = 0) -> dict[int, Goal]: - project_name, project_url, data_fragment = source_data - data_url = urljoin(project_url, data_fragment) - try: - with urlopen(data_url) as response: # noqa: S310 - data = response.read() - except HTTPError as error: - raise RuntimeError(f"Could not load data from network: {data_url}") from error - return load_goals(data, funding, project=Project(name=project_name, url=project_url)) - - -def _load_goals(source: str | tuple[str, str, str], funding: int = 0) -> dict[int, Goal]: - if isinstance(source, str): - return _load_goals_from_disk(source, funding) - return _load_goals_from_url(source, funding) - - -def funding_goals(source: str | list[str | tuple[str, str, str]], funding: int = 0) -> dict[int, Goal]: - if isinstance(source, str): - return _load_goals_from_disk(source, funding) - goals = {} - for src in source: - source_goals = _load_goals(src, funding) - for amount, goal in source_goals.items(): - if amount not in goals: - goals[amount] = goal - else: - goals[amount].features.extend(goal.features) - return {amount: goals[amount] for amount in sorted(goals)} - - -def feature_list(goals: Iterable[Goal]) -> list[Feature]: - return list(chain.from_iterable(goal.features for goal in goals)) - - -def load_json(url: str) -> str | list | dict: - with urlopen(url) as response: # noqa: S310 - return json.loads(response.read().decode()) - - -data_source = globals()["data_source"] -sponsor_url = "https://github.com/sponsors/pawamoy" -data_url = "https://raw.githubusercontent.com/pawamoy/sponsors/main" -numbers: dict[str, int] = load_json(f"{data_url}/numbers.json") # type: ignore[assignment] -sponsors: list[dict] = load_json(f"{data_url}/sponsors.json") # type: ignore[assignment] -current_funding = numbers["total"] -sponsors_count = numbers["count"] -goals = funding_goals(data_source, funding=current_funding) -ongoing_goals = [goal for goal in goals.values() if not goal.complete] -unreleased_features = sorted( - (ft for ft in feature_list(ongoing_goals) if ft.since), - key=lambda ft: cast("date", ft.since), - reverse=True, -) diff --git a/scripts/make.py b/scripts/make.py index 1e697bcc..b741a366 100755 --- a/scripts/make.py +++ b/scripts/make.py @@ -14,8 +14,8 @@ from collections.abc import Iterator -PYTHON_VERSIONS = os.getenv("PYTHON_VERSIONS", "3.9 3.10 3.11 3.12 3.13 3.14").split() -PYTHON_DEV = "3.14" +PYTHON_VERSIONS = os.getenv("PYTHON_VERSIONS", "3.10 3.11 3.12 3.13 3.14 3.15").split() +PYTHON_DEV = "3.15" def shell(cmd: str, *, capture_output: bool = False, **kwargs: Any) -> str | None: From 3bc2d7b0c59f687434e6daba4ccf0b755509dcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 14:09:38 +0100 Subject: [PATCH 12/16] style: Format --- duties.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/duties.py b/duties.py index a21c3b8e..21f7c7dc 100644 --- a/duties.py +++ b/duties.py @@ -79,7 +79,11 @@ def check_quality(ctx: Context) -> None: ) -@duty(nofail=PY_VERSION == PY_DEV, skip_if=sys.version_info < (3, 13), skip_reason=pyprefix("Skipped: docs require modern generics syntax")) +@duty( + nofail=PY_VERSION == PY_DEV, + skip_if=sys.version_info < (3, 13), + skip_reason=pyprefix("Skipped: docs require modern generics syntax"), +) def check_docs(ctx: Context) -> None: """Check if the documentation builds correctly.""" Path("htmlcov").mkdir(parents=True, exist_ok=True) From c086b036f7900578a13a56cc77228b442b5a3359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 14:10:51 +0100 Subject: [PATCH 13/16] chore: Ignore lint --- duties.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duties.py b/duties.py index 21f7c7dc..a48e743f 100644 --- a/duties.py +++ b/duties.py @@ -202,7 +202,7 @@ def coverage(ctx: Context) -> None: @duty(nofail=PY_VERSION == PY_DEV) -def test(ctx: Context, *cli_args: str, snapshot: str = "report") -> None: +def test(ctx: Context, *cli_args: str, snapshot: str = "report") -> None: # noqa: PT028 """Run the test suite.""" os.environ["COVERAGE_FILE"] = f".coverage.{PY_VERSION}" os.environ["PYTHONWARNDEFAULTENCODING"] = "1" From 63546221bd5e4b7127c9745774d10a55176a4ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 14:19:55 +0100 Subject: [PATCH 14/16] docs: Remove Insiders links --- CHANGELOG.md | 3 --- docs/usage/configuration/docstrings.md | 6 ------ docs/usage/configuration/general.md | 6 ------ docs/usage/configuration/headings.md | 6 ------ docs/usage/configuration/members.md | 7 +------ docs/usage/configuration/signatures.md | 8 -------- mkdocs.yml | 2 +- src/mkdocstrings_handlers/python/_internal/config.py | 3 --- 8 files changed, 2 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ac6e8ec..e398e9ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -487,9 +487,6 @@ Importing from submodules is now deprecated: the public API is fully exposed und - [`griffe-inherited-docstrings`](https://mkdocstrings.github.io/griffe-inherited-docstrings/), a Griffe extension for inheriting docstrings - [`griffe2md`](https://mkdocstrings.github.io/griffe2md/), a tool to output API docs to Markdown using Griffe - See the complete list of features and projects here: - https://pawamoy.github.io/insiders/#500-plasmavac-user-guide. - ## [1.7.5](https://github.com/mkdocstrings/python/releases/tag/1.7.5) - 2023-11-21 [Compare with 1.7.4](https://github.com/mkdocstrings/python/compare/1.7.4...1.7.5) diff --git a/docs/usage/configuration/docstrings.md b/docs/usage/configuration/docstrings.md index f864d102..95f9032f 100644 --- a/docs/usage/configuration/docstrings.md +++ b/docs/usage/configuration/docstrings.md @@ -327,9 +327,6 @@ class Thing: [](){#option-relative_crossrefs} ## `relative_crossrefs` -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — -[:octicons-tag-24: Insiders 1.9.0](../../insiders/changelog.md#1.9.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** @@ -440,9 +437,6 @@ INFO: **There is an alternative, third-party Python handler that handles relativ [](){#option-scoped_crossrefs} ## `scoped_crossrefs` -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — -[:octicons-tag-24: Insiders 1.9.0](../../insiders/changelog.md#1.9.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** diff --git a/docs/usage/configuration/general.md b/docs/usage/configuration/general.md index 7d7b71e1..921f3b27 100644 --- a/docs/usage/configuration/general.md +++ b/docs/usage/configuration/general.md @@ -63,9 +63,6 @@ plugins: [](){#option-backlinks} ## `backlinks` -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — -[:octicons-tag-24: Insiders 1.10.0](../../insiders/changelog.md#1.10.0) - - **:octicons-package-24: Type Literal["flat", "tree", False] :material-equal: `False`{ title="default value" }** The `backlinks` option enables rendering of backlinks within your API documentation. @@ -503,9 +500,6 @@ plugins: [](){#option-show_inheritance_diagram} ## `show_inheritance_diagram` -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — -[:octicons-tag-24: Insiders 1.7.0](../../insiders/changelog.md#1.7.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** diff --git a/docs/usage/configuration/headings.md b/docs/usage/configuration/headings.md index 8e904e5f..593b6fb0 100644 --- a/docs/usage/configuration/headings.md +++ b/docs/usage/configuration/headings.md @@ -77,8 +77,6 @@ plugins: [](){#option-parameter_headings} ## `parameter_headings` -[:octicons-tag-24: Insiders 1.6.0](../../insiders/changelog.md#1.6.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** @@ -537,8 +535,6 @@ plugins: [](){#option-show_symbol_type_heading} ## `show_symbol_type_heading` -[:octicons-tag-24: Insiders 1.1.0](../../insiders/changelog.md#1.1.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** @@ -602,8 +598,6 @@ plugins: [](){#option-show_symbol_type_toc} ## `show_symbol_type_toc` -[:octicons-tag-24: Insiders 1.1.0](../../insiders/changelog.md#1.1.0) - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** diff --git a/docs/usage/configuration/members.md b/docs/usage/configuration/members.md index 3c344221..53d955fa 100644 --- a/docs/usage/configuration/members.md +++ b/docs/usage/configuration/members.md @@ -269,7 +269,7 @@ class Main(Base): The members ordering to use. Possible values: -- `__all__` ([:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — [:octicons-tag-24: Insiders 1.12.0](../../insiders/changelog.md#1.12.0)): Order according to `__all__` attributes. Since classes do not define `__all__` attributes, you can specify a second ordering method by using a list. +- `__all__`: Order according to `__all__` attributes. Since classes do not define `__all__` attributes, you can specify a second ordering method by using a list. - `alphabetical`: Order by the members names. - `source`: Order members as they appear in the source file. @@ -351,9 +351,6 @@ A list of filters, or `"public"`. [](){#option-filters-public} -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — -[:octicons-tag-24: Insiders 1.11.0](../../insiders/changelog.md#1.11.0) - The `public` filtering method will include only public objects: those added to the `__all__` attribute of modules, or not starting with a single underscore. Special methods and attributes ("dunder" methods/attributes, starting and ending with two underscores), like `__init__`, `__call__`, `__mult__`, etc., are always considered public. **List of filters** @@ -577,8 +574,6 @@ package [](){#option-summary} ## `summary` -[:octicons-tag-24: Insiders 1.2.0](../../insiders/changelog.md#1.2.0) - - **:octicons-package-24: Type bool | dict[str, bool] :material-equal: `False`{ title="default value" }** diff --git a/docs/usage/configuration/signatures.md b/docs/usage/configuration/signatures.md index 16ac218b..109362e3 100644 --- a/docs/usage/configuration/signatures.md +++ b/docs/usage/configuration/signatures.md @@ -203,12 +203,6 @@ plugins: [](){#option-modernize_annotations} ## `modernize_annotations` -[:octicons-heart-fill-24:{ .pulse } Sponsors only](../../insiders/index.md){ .insiders } — -[:octicons-tag-24: Insiders 1.8.0](../../insiders/changelog.md#1.8.0) — -**This feature also requires -[Griffe Insiders](https://mkdocstrings.github.io/griffe/insiders/) -to be installed.** - - **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** @@ -637,8 +631,6 @@ Function docstring. [](){#option-signature_crossrefs} ## `signature_crossrefs` -[:octicons-tag-24: Insiders 1.0.0](../../insiders/changelog.md#1.0.0) - Whether to render cross-references for type annotations in signatures. When signatures are separated from headings with the [`separate_signature`][] option diff --git a/mkdocs.yml b/mkdocs.yml index f7b3b7a2..30a806d1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -137,7 +137,7 @@ plugins: - autorefs - markdown-exec - section-index -# - coverage +- coverage - mkdocstrings: handlers: python: diff --git a/src/mkdocstrings_handlers/python/_internal/config.py b/src/mkdocstrings_handlers/python/_internal/config.py index d3588e2d..ad461c42 100644 --- a/src/mkdocstrings_handlers/python/_internal/config.py +++ b/src/mkdocstrings_handlers/python/_internal/config.py @@ -519,9 +519,6 @@ class PythonInputOptions: **Filtering methods** - [:octicons-heart-fill-24:{ .pulse } Sponsors only](../insiders/index.md){ .insiders } — - [:octicons-tag-24: Insiders 1.11.0](../insiders/changelog.md#1.11.0) - The `public` method will include only public objects: those added to `__all__` or not starting with an underscore (except for special methods/attributes). """, From b696ed2224756472a3617fa3cc18b69d0418ed71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 14:21:55 +0100 Subject: [PATCH 15/16] refactor: Update code base for Python 3.10 --- .../python/_internal/config.py | 51 ++++--------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/src/mkdocstrings_handlers/python/_internal/config.py b/src/mkdocstrings_handlers/python/_internal/config.py index ad461c42..79ba87f9 100644 --- a/src/mkdocstrings_handlers/python/_internal/config.py +++ b/src/mkdocstrings_handlers/python/_internal/config.py @@ -39,18 +39,6 @@ if getattr(pydantic, "__version__", "1.").startswith("1."): raise ImportError # noqa: TRY301 - # YORE: EOL 3.9: Remove block. - if sys.version_info < (3, 10): - try: - import eval_type_backport # noqa: F401 - except ImportError: - _logger.debug( - "Pydantic needs the `eval-type-backport` package to be installed " - "for modern type syntax to work on Python 3.9. " - "Deactivating Pydantic validation for Python handler options.", - ) - raise - from inspect import cleandoc from pydantic import Field as BaseField @@ -87,14 +75,7 @@ def _Field(*args: Any, **kwargs: Any) -> None: # type: ignore[misc] # noqa: N8 from collections.abc import MutableMapping -# YORE: EOL 3.9: Remove block. -_dataclass_options = {"frozen": True} -if sys.version_info >= (3, 10): - _dataclass_options["kw_only"] = True - - -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class GoogleStyleOptions: """Google style docstring options.""" @@ -205,8 +186,7 @@ class GoogleStyleOptions: ] = True -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class NumpyStyleOptions: """Numpy style docstring options.""" @@ -256,8 +236,7 @@ class NumpyStyleOptions: ] = True -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class SphinxStyleOptions: """Sphinx style docstring options.""" @@ -289,8 +268,7 @@ class SphinxStyleOptions: ] = True -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class PerStyleOptions: """Per style options.""" @@ -333,8 +311,7 @@ def from_data(cls, **data: Any) -> Self: return cls(**data) -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class AutoStyleOptions: """Auto style docstring options.""" @@ -382,8 +359,7 @@ def from_data(cls, **data: Any) -> Self: return cls(**data) -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class SummaryOption: """Summary option.""" @@ -433,8 +409,7 @@ class SummaryOption: ] = False -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class PythonInputOptions: """Accepted input options.""" @@ -1067,8 +1042,7 @@ def from_data(cls, **data: Any) -> Self: return cls(**cls.coerce(**data)) -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class PythonOptions(PythonInputOptions): # type: ignore[override,unused-ignore] """Final options passed as template context.""" @@ -1093,8 +1067,7 @@ def coerce(cls, **data: Any) -> MutableMapping[str, Any]: return super().coerce(**data) -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class Inventory: """An inventory.""" @@ -1127,8 +1100,7 @@ def _config(self) -> dict[str, Any]: return {"base_url": self.base_url, "domains": self.domains} -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class PythonInputConfig: """Python handler configuration.""" @@ -1170,8 +1142,7 @@ def from_data(cls, **data: Any) -> Self: return cls(**cls.coerce(**data)) -# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line. -@dataclass(**_dataclass_options) # type: ignore[call-overload] +@dataclass(frozen=True, kw_only=True) class PythonConfig(PythonInputConfig): # type: ignore[override,unused-ignore] """Python handler configuration.""" From e07c882ac52494ea7689df2605355eef869491e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 10 Nov 2025 14:30:15 +0100 Subject: [PATCH 16/16] chore: Prepare release 1.19.0 --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e398e9ae..179b9a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.19.0](https://github.com/mkdocstrings/python/releases/tag/1.19.0) - 2025-11-10 + +[Compare with 1.18.2](https://github.com/mkdocstrings/python/compare/1.18.2...1.19.0) + +### Features + +- Release scoped and relative cross-references ([872afc5](https://github.com/mkdocstrings/python/commit/872afc584f33f50a133472afdc9355734a5e51ec) by Timothée Mazzucotelli). +- Release `__all__` ordering feature ([84aaebc](https://github.com/mkdocstrings/python/commit/84aaebcb4991c0245bf7ca8d7024c9d04942b0c1) by Timothée Mazzucotelli). +- Release public filter feature ([3be14cc](https://github.com/mkdocstrings/python/commit/3be14cc07bc9429d7ce01c748d825e2db1559212) by Timothée Mazzucotelli). +- Release backlinks feature ([ae7cc2d](https://github.com/mkdocstrings/python/commit/ae7cc2d7d8ea5711d8ce06620edd534a3e2b47aa) by Timothée Mazzucotelli). +- Release expression modernization feature ([dbadd1e](https://github.com/mkdocstrings/python/commit/dbadd1e898bb2e67515077d152890bdbbf0b3eb1) by Timothée Mazzucotelli). +- Release visually-lighter admonitions for source code blocks ([fdaeb48](https://github.com/mkdocstrings/python/commit/fdaeb48a0f2208bafd14f2f7ead42bca37bea665) by Timothée Mazzucotelli). +- Release inheritance diagram features ([669b42e](https://github.com/mkdocstrings/python/commit/669b42ebd7c154c81764fa98c052cf857f7aa406) by Timothée Mazzucotelli). + +### Code Refactoring + +- Update code base for Python 3.10 ([b696ed2](https://github.com/mkdocstrings/python/commit/b696ed2224756472a3617fa3cc18b69d0418ed71) by Timothée Mazzucotelli). + ## [1.18.2](https://github.com/mkdocstrings/python/releases/tag/1.18.2) - 2025-08-28 [Compare with 1.18.1](https://github.com/mkdocstrings/python/compare/1.18.1...1.18.2)