Re: docs: "translations" extension breaks "make latexdocs" with 6.1.3<=Sphinx<7.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 12/02/2024 11:28, Vegard Nossum wrote:
On 12/02/2024 10:52, Akira Yokosawa wrote:
While testing update of sphinx_pre_install WRT pyyaml, I noticed build
errors in "make latexdocs" against Fedora 39's distro Sphinx (v6.2.1).

I think we can solve it by making 'current_language' a true element
attribute:
[...]
This is probably more correct anyway.

I'll test this more thoroughly with a full build as I think translations
won't show up when using SPHINXDIRS= (because the translation is outside
the source tree) as well as with older/newer Sphinx versions.

In the end, that first patch caused errors on Sphinx 4.x
("TypeError: LanguagesNode.__init__() got multiple values for argument
'current_language'").

This seems to work across 2.x/3.x/6.x/7.x for me:

diff --git a/Documentation/sphinx/translations.py b/Documentation/sphinx/translations.py
index 47161e6eba99..32c2b32b2b5e 100644
--- a/Documentation/sphinx/translations.py
+++ b/Documentation/sphinx/translations.py
@@ -29,10 +29,7 @@ all_languages = {
 }

 class LanguagesNode(nodes.Element):
-    def __init__(self, current_language, *args, **kwargs):
-        super().__init__(*args, **kwargs)
-
-        self.current_language = current_language
+    pass

 class TranslationsTransform(Transform):
     default_priority = 900
@@ -49,7 +46,8 @@ class TranslationsTransform(Transform):
             # normalize docname to be the untranslated one
             docname = os.path.join(*components[2:])

-        new_nodes = LanguagesNode(all_languages[this_lang_code])
+        new_nodes = LanguagesNode()
+        new_nodes['current_language'] = all_languages[this_lang_code]

         for lang_code, lang_name in all_languages.items():
             if lang_code == this_lang_code:
@@ -84,7 +82,7 @@ def process_languages(app, doctree, docname):

         html_content = app.builder.templates.render('translations.html',
             context={
-                'current_language': node.current_language,
+                'current_language': node['current_language'],
                 'languages': languages,
             })


I'll test a bit more and submit a proper patch if this works.


Vegard




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux