diff --git a/.copier-answers.yml b/.copier-answers.yml index 39641f11..d2a2b345 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier. -_commit: 1.6.0 +_commit: 1.6.1 _src_path: gh:mkdocstrings/handler-template author_email: dev@pawamoy.fr author_fullname: Timothée Mazzucotelli diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c0d416a..29729f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ 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). +## [2.0.1](https://github.com/mkdocstrings/python/releases/tag/2.0.1) - 2025-12-03 + +[Compare with 2.0.0](https://github.com/mkdocstrings/python/compare/2.0.0...2.0.1) + +### Bug Fixes + +- Don't ignore filters when category grouping is disabled ([63aa1b0](https://github.com/mkdocstrings/python/commit/63aa1b0af0d14912ebf83a4e3c2cd0c7f2a19dae) by Timothée Mazzucotelli). [Issue-324](https://github.com/mkdocstrings/python/issues/324) + +### Code Refactoring + +- Localize more contents in templates ([854b6a6](https://github.com/mkdocstrings/python/commit/854b6a601bd334fe544285aa9eae11482388a583) by Zhikang Yan). [PR-321](https://github.com/mkdocstrings/python/pull/321) +- Improve ja/zh translations ([b83107c](https://github.com/mkdocstrings/python/commit/b83107c8e86d9650fe4544e569f6da16a46b8472) by Zhikang Yan). [PR-322](https://github.com/mkdocstrings/python/pull/322) + ## [2.0.0](https://github.com/mkdocstrings/python/releases/tag/2.0.0) - 2025-11-27 [Compare with 1.19.0](https://github.com/mkdocstrings/python/compare/1.19.0...2.0.0) diff --git a/duties.py b/duties.py index a48e743f..3aa9b662 100644 --- a/duties.py +++ b/duties.py @@ -5,16 +5,12 @@ import os import re import sys -from contextlib import contextmanager -from importlib.metadata import version as pkgversion from pathlib import Path from typing import TYPE_CHECKING from duty import duty, tools if TYPE_CHECKING: - from collections.abc import Iterator - from duty.context import Context @@ -36,18 +32,6 @@ def pyprefix(title: str) -> str: return title -@contextmanager -def material_insiders() -> Iterator[bool]: - if "+insiders" in pkgversion("mkdocs-material"): - os.environ["MATERIAL_INSIDERS"] = "true" - try: - yield True - finally: - os.environ.pop("MATERIAL_INSIDERS") - else: - yield False - - def _get_changelog_version() -> str: changelog_version_re = re.compile(r"^## \[(\d+\.\d+\.\d+)\].*$") with Path(__file__).parent.joinpath("CHANGELOG.md").open("r", encoding="utf8") as file: @@ -88,11 +72,10 @@ def check_docs(ctx: Context) -> None: """Check if the documentation builds correctly.""" Path("htmlcov").mkdir(parents=True, exist_ok=True) Path("htmlcov/index.html").touch(exist_ok=True) - with material_insiders(): - ctx.run( - tools.mkdocs.build(strict=True, verbose=True), - title=pyprefix("Building documentation"), - ) + ctx.run( + tools.mkdocs.build(strict=True, verbose=True), + title=pyprefix("Building documentation"), + ) @duty(nofail=PY_VERSION == PY_DEV) @@ -126,22 +109,18 @@ def docs(ctx: Context, *cli_args: str, host: str = "127.0.0.1", port: int = 8000 host: The host to serve the docs from. port: The port to serve the docs on. """ - with material_insiders(): - ctx.run( - tools.mkdocs.serve(dev_addr=f"{host}:{port}").add_args(*cli_args), - title="Serving documentation", - capture=False, - ) + ctx.run( + tools.mkdocs.serve(dev_addr=f"{host}:{port}").add_args(*cli_args), + title="Serving documentation", + capture=False, + ) @duty(skip_if=sys.version_info < (3, 13), skip_reason=pyprefix("Skipped: docs require modern generics syntax")) 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!") - ctx.run(tools.mkdocs.gh_deploy(force=True), title="Deploying documentation") + ctx.run(tools.mkdocs.gh_deploy(force=True), title="Deploying documentation") @duty diff --git a/mkdocs.yml b/mkdocs.yml index 30a806d1..64d0de3a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -197,11 +197,7 @@ plugins: reference/mkdocstrings_handlers/python/debug.md: reference/api.md#mkdocstrings_handlers.python.debug reference/mkdocstrings_handlers/python/handler.md: reference/api.md#mkdocstrings_handlers.python.handler reference/mkdocstrings_handlers/python/rendering.md: reference/api.md#mkdocstrings_handlers.python.rendering - -- group: - enabled: !ENV [MATERIAL_INSIDERS, false] - plugins: - - typeset +- typeset extra: social: diff --git a/src/mkdocstrings_handlers/python/_internal/handler.py b/src/mkdocstrings_handlers/python/_internal/handler.py index abab532c..bd95023f 100644 --- a/src/mkdocstrings_handlers/python/_internal/handler.py +++ b/src/mkdocstrings_handlers/python/_internal/handler.py @@ -139,7 +139,7 @@ def load_inventory( ) -> Iterator[tuple[str, str]]: """Yield items and their URLs from an inventory file streamed from `in_file`. - This implements mkdocstrings' `load_inventory` "protocol" (see [`mkdocstrings.plugin`][]). + This implements mkdocstrings' `load_inventory` "protocol" (see [`mkdocstrings.BaseHandler.load_inventory`][]). Arguments: in_file: The binary file-like object to read the inventory from. diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja index 3be0a33a..63f3b1a6 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja @@ -19,6 +19,9 @@ Context: {{ log.debug("Rendering children of " + obj.path) }} {% endblock logs %} + {% import "language.html.jinja" as lang with context %} + {#- Language module providing the `t` translation method. -#} +
+ {{ lang.t("Source code in") }}
{%- if init.relative_filepath.is_absolute() -%}
{{ init.relative_package_filepath }}
{%- else -%}
@@ -259,7 +262,7 @@ Context:
{% endif %}
{% elif class.source %}
- Source code in
+ {{ lang.t("Source code in") }}
{%- if class.relative_filepath.is_absolute() -%}
{{ class.relative_package_filepath }}
{%- else -%}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja
index 9e0add3f..894639a7 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja
@@ -93,7 +93,7 @@ Context:
{% if attribute.annotation %}
- TYPE:
+ {{ lang.t("TYPE:") }}
{% with expression = attribute.annotation %}
{% include "expression.html.jinja" with context %}
{% endwith %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja
index a2e38b7c..d2bbba03 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja
@@ -9,9 +9,11 @@
{% macro t(key) %}{{ {
"ATTRIBUTE": "ATTRIBUTE",
+ "Attributes": "Attributes",
"Attributes:": "Attributes:",
"BOUND:": "BOUND:",
"Bound or Constraints": "Bound or Constraints",
+ "Classes": "Classes",
"Classes:": "Classes:",
"Class Type Parameters:": "Class Type Parameters:",
"CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
@@ -23,12 +25,14 @@
"DESCRIPTION": "DESCRIPTION",
"Description": "Description",
"Examples:": "Examples:",
+ "Functions": "Functions",
"Functions:": "Functions:",
"FUNCTION": "FUNCTION",
"Init Type Parameters:": "Init Type Parameters:",
"INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
"Methods:": "Methods:",
"METHOD": "METHOD",
+ "Modules": "Modules",
"Modules:": "Modules:",
"MODULE": "MODULE",
"Name": "Name",
@@ -45,6 +49,7 @@
"Source code in": "Source code in",
"TYPE:": "TYPE:",
"Type": "Type",
+ "Type Aliases": "Type Aliases",
"Type Aliases:": "Type Aliases:",
"TYPE ALIAS": "TYPE ALIAS",
"Type Parameters:": "Type Parameters:",
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja
index be0dd62b..840da89c 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja
@@ -9,26 +9,30 @@
{% macro t(key) %}{{ {
"ATTRIBUTE": "属性",
+ "Attributes": "属性",
"Attributes:": "属性:",
- "BOUND:": "BOUND:",
- "Bound or Constraints": "Bound or Constraints",
+ "BOUND:": "境界:",
+ "Bound or Constraints": "境界や制約",
+ "Classes": "クラス",
"Classes:": "クラス:",
"Class Type Parameters:": "Class Type Parameters:",
"CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
- "CLASS": "CLASS",
- "CONSTRAINTS:": "CONSTRAINTS:",
+ "CLASS": "クラス",
+ "CONSTRAINTS:": "制約:",
"DEFAULT:": "デフォルト:",
"Default": "デフォルト",
"default:": "デフォルト:",
"DESCRIPTION": "デスクリプション",
"Description": "デスクリプション",
"Examples:": "例:",
+ "Functions": "関数",
"Functions:": "関数:",
"FUNCTION": "関数",
"Init Type Parameters:": "Init Type Parameters:",
"INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
"Methods:": "メソッド:",
"METHOD": "メソッド",
+ "Modules": "モジュール",
"Modules:": "モジュール:",
"MODULE": "モジュール",
"Name": "名前",
@@ -45,10 +49,11 @@
"Source code in": "ソースコード位置:",
"TYPE:": "タイプ:",
"Type": "タイプ",
- "Type Aliases:": "Type Aliases:",
- "TYPE ALIAS": "TYPE ALIAS",
- "Type Parameters:": "Type Parameters:",
- "TYPE PARAMETER": "TYPE PARAMETER",
+ "Type Aliases": "型エイリアス",
+ "Type Aliases:": "型エイリアス:",
+ "TYPE ALIAS": "型エイリアス",
+ "Type Parameters:": "型パラメータ:",
+ "TYPE PARAMETER": "型パラメータ",
"WARNS": "警告",
"Warns:": "警告:",
"YIELDS": "返す",
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja
index 3f1e3481..53888779 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja
@@ -9,26 +9,30 @@
{% macro t(key) %}{{ {
"ATTRIBUTE": "属性",
+ "Attributes": "属性",
"Attributes:": "属性:",
- "BOUND:": "BOUND:",
- "Bound or Constraints": "Bound or Constraints",
+ "BOUND:": "边界:",
+ "Bound or Constraints": "边界或约束",
+ "Classes": "类",
"Classes:": "类:",
"Class Type Parameters:": "Class Type Parameters:",
"CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
- "CLASS": "CLASS",
- "CONSTRAINTS:": "CONSTRAINTS:",
+ "CLASS": "类",
+ "CONSTRAINTS:": "约束:",
"DEFAULT:": "默认:",
"Default": "默认",
"default:": "默认:",
"DESCRIPTION": "描述",
"Description": "描述",
"Examples:": "示例:",
+ "Functions": "函数",
"Functions:": "函数:",
"FUNCTION": "函数",
"Init Type Parameters:": "Init Type Parameters:",
"INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
"Methods:": "方法:",
"METHOD": "方法",
+ "Modules": "模块",
"Modules:": "模块:",
"MODULE": "模块",
"Name": "名称",
@@ -45,10 +49,11 @@
"Source code in": "源代码位于:",
"TYPE:": "类型:",
"Type": "类型",
- "Type Aliases:": "Type Aliases:",
- "TYPE ALIAS": "TYPE ALIAS",
- "Type Parameters:": "Type Parameters:",
- "TYPE PARAMETER": "TYPE PARAMETER",
+ "Type Aliases": "类型别名",
+ "Type Aliases:": "类型别名:",
+ "TYPE ALIAS": "类型别名",
+ "Type Parameters:": "类型形参:",
+ "TYPE PARAMETER": "类型形参",
"Warns:": "警告:",
"WARNS": "警告",
"YIELDS": "产生",