From 7d11a82ab4b462b069e76e0effe69ad4324c4cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 3 Jul 2025 00:58:02 +0200 Subject: [PATCH 1/3] wip --- docs/usage/index.md | 6 ++++-- src/mkdocstrings_handlers/python/_internal/config.py | 4 +++- src/mkdocstrings_handlers/python/_internal/handler.py | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/usage/index.md b/docs/usage/index.md index b2a00955..e1fa457f 100644 --- a/docs/usage/index.md +++ b/docs/usage/index.md @@ -150,9 +150,11 @@ plugins: [__all__]: https://docs.python.org/3/tutorial/modules.html#importing-from-a-package [](){#setting-locale} -#### `locale` +#### ~~`locale`~~ -The locale to use when translating template strings. The translation system is not fully ready yet, so we don't recommend setting the option for now. +**Deprecated.** Use mkdocstrings' own `locale` setting. + +~~The locale to use when translating template strings.~~ [](){#setting-paths} #### `paths` diff --git a/src/mkdocstrings_handlers/python/_internal/config.py b/src/mkdocstrings_handlers/python/_internal/config.py index 210f8fe2..28d6549a 100644 --- a/src/mkdocstrings_handlers/python/_internal/config.py +++ b/src/mkdocstrings_handlers/python/_internal/config.py @@ -1019,7 +1019,9 @@ class PythonInputConfig: locale: Annotated[ str | None, - _Field(description="The locale to use when translating template strings."), + _Field( + description="Deprecated. Use mkdocstrings' own `locale` setting instead. The locale to use when translating template strings.", + ), ] = None @classmethod diff --git a/src/mkdocstrings_handlers/python/_internal/handler.py b/src/mkdocstrings_handlers/python/_internal/handler.py index 158d7ddc..dfd8ea7a 100644 --- a/src/mkdocstrings_handlers/python/_internal/handler.py +++ b/src/mkdocstrings_handlers/python/_internal/handler.py @@ -278,7 +278,7 @@ def collect(self, identifier: str, options: PythonOptions) -> CollectorItem: return doc_object - def render(self, data: CollectorItem, options: PythonOptions) -> str: + def render(self, data: CollectorItem, options: PythonOptions, locale: str | None = None) -> str: """Render the collected data. Parameters: @@ -300,7 +300,8 @@ def render(self, data: CollectorItem, options: PythonOptions) -> str: # than as an item in a dictionary. "heading_level": options.heading_level, "root": True, - "locale": self.config.locale, + # YORE: Bump 2: Regex-replace ` or .+` with `,` within line. + "locale": locale or self.config.locale, }, ) @@ -401,6 +402,7 @@ def get_handler( Parameters: handler_config: The handler configuration. tool_config: The tool (SSG) configuration. + **kwargs: Additional arguments to pass to the handler. Returns: An instance of `PythonHandler`. From a8e83bc4453c76a8f49c82e85125c99873bf7289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Wed, 23 Jul 2025 19:54:09 +0200 Subject: [PATCH 2/3] Apply suggestion from @pawamoy --- src/mkdocstrings_handlers/python/_internal/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mkdocstrings_handlers/python/_internal/handler.py b/src/mkdocstrings_handlers/python/_internal/handler.py index dfd8ea7a..12d27c71 100644 --- a/src/mkdocstrings_handlers/python/_internal/handler.py +++ b/src/mkdocstrings_handlers/python/_internal/handler.py @@ -300,7 +300,7 @@ def render(self, data: CollectorItem, options: PythonOptions, locale: str | None # than as an item in a dictionary. "heading_level": options.heading_level, "root": True, - # YORE: Bump 2: Regex-replace ` or .+` with `,` within line. + # YORE: Bump 2: Regex-replace ` or .+` with ` or "en",` within line. "locale": locale or self.config.locale, }, ) From c3d0477e9151d1f177bdb68f4ba94345492193ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Wed, 23 Jul 2025 19:55:38 +0200 Subject: [PATCH 3/3] wip --- src/mkdocstrings_handlers/python/_internal/handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mkdocstrings_handlers/python/_internal/handler.py b/src/mkdocstrings_handlers/python/_internal/handler.py index 12d27c71..8bc40d27 100644 --- a/src/mkdocstrings_handlers/python/_internal/handler.py +++ b/src/mkdocstrings_handlers/python/_internal/handler.py @@ -284,6 +284,7 @@ def render(self, data: CollectorItem, options: PythonOptions, locale: str | None Parameters: data: The collected data. options: The options to use for rendering. + locale: The locale to use for rendering (default is "en"). Returns: The rendered data (HTML). pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy