Copilot commented on code in PR #2951:
URL: https://github.com/apache/sedona/pull/2951#discussion_r3223779634


##########
docs-overrides/hooks/i18n_blog_passthrough.py:
##########
@@ -0,0 +1,72 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Works around the known incompatibility between mkdocs-material's blog plugin
+# and mkdocs-static-i18n: the blog plugin generates archive/pagination files
+# under a tempfile.mkdtemp() directory, which mkdocs-static-i18n's
+# reconfigure_files drops because they live outside docs_dir. Result: the
+# rendered /blog/ index has no individual posts.
+#
+# This hook removes blog files from the Files collection before i18n's on_files
+# (priority -100) processes them, then re-adds them after. Net effect: the blog
+# is rendered once in the default language and served identically under every
+# language version.
+#
+# Source: https://github.com/ultrabug/mkdocs-static-i18n/issues/283
+
+from mkdocs import plugins
+from mkdocs.structure.files import File, Files
+
+BLOG_FILES: list = []
+
+
[email protected]_priority(-95)
+def _on_files_disconnect_blog_files(files: Files, config, *_, **__):
+    """Remove blog files after the blog plugin's on_files (-50), before i18n's 
(-100)."""
+    global BLOG_FILES
+    BLOG_FILES = []
+    non_blog_files: list[File] = []

Review Comment:
   `BLOG_FILES` is declared as an untyped `list` but is used as a list of 
`mkdocs.structure.files.File`. Consider typing it as `list[File]` (and 
optionally avoiding `global` by storing it on `config` or a small helper 
object) to make the hook easier to maintain.



##########
docs-overrides/hooks/i18n_blog_passthrough.py:
##########
@@ -0,0 +1,72 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Works around the known incompatibility between mkdocs-material's blog plugin
+# and mkdocs-static-i18n: the blog plugin generates archive/pagination files
+# under a tempfile.mkdtemp() directory, which mkdocs-static-i18n's
+# reconfigure_files drops because they live outside docs_dir. Result: the
+# rendered /blog/ index has no individual posts.
+#
+# This hook removes blog files from the Files collection before i18n's on_files
+# (priority -100) processes them, then re-adds them after. Net effect: the blog
+# is rendered once in the default language and served identically under every
+# language version.
+#
+# Source: https://github.com/ultrabug/mkdocs-static-i18n/issues/283
+
+from mkdocs import plugins
+from mkdocs.structure.files import File, Files
+
+BLOG_FILES: list = []
+
+
[email protected]_priority(-95)
+def _on_files_disconnect_blog_files(files: Files, config, *_, **__):
+    """Remove blog files after the blog plugin's on_files (-50), before i18n's 
(-100)."""
+    global BLOG_FILES
+    BLOG_FILES = []
+    non_blog_files: list[File] = []
+    blog_prefixes: list[str] = []
+
+    for name, instance in config.plugins.items():
+        if name.startswith("material/blog"):
+            blog_prefixes.append(instance.config.blog_dir)
+
+    blog_prefix_tuple = tuple(p.rstrip("/") + "/" for p in blog_prefixes)
+    config.extra.i18n_blog_prefixes = blog_prefix_tuple

Review Comment:
   `config.extra` is a dict in MkDocs config; assigning 
`config.extra.i18n_blog_prefixes = ...` will raise an `AttributeError` at build 
time. Use key assignment (e.g., `config.extra["i18n_blog_prefixes"] = ...`) or 
`setdefault()` instead.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to