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 10:52, Akira Yokosawa wrote:
Hi Vegard,

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 don't mean the translations extension is doing anything wrong.

Repro:

     make cleandocs
     make SPHINXDIRS=doc-guide htmldocs  # for yaml -> rst conversion
     make SPHINXDIRS=doc-guide latexdocs

At current docs-next, Fedora 39's Sphinx ends up in the error:

     Exception occurred:
       File "/usr/lib/python3.12/site-packages/sphinx/util/nodes.py", line 624, in _copy_except__document
         newnode = self.__class__(rawsource=self.rawsource, **self.attributes)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     TypeError: LanguagesNode.__init__() missing 1 required positional argument: 'current_language'
     The full traceback has been saved in /tmp/sphinx-err-7xmwytuu.log, if you want to report the issue to the developers.

Thanks, with all your info it was quick and easy to reproduce.

I think we can solve it by making 'current_language' a true element
attribute:

diff --git a/Documentation/sphinx/translations.py b/Documentation/sphinx/translations.py
index 47161e6eba99..f20c30599ceb 100644
--- a/Documentation/sphinx/translations.py
+++ b/Documentation/sphinx/translations.py
@@ -32,7 +32,7 @@ class LanguagesNode(nodes.Element):
     def __init__(self, current_language, *args, **kwargs):
         super().__init__(*args, **kwargs)

-        self.current_language = current_language
+        self['current_language'] = current_language

 class TranslationsTransform(Transform):
     default_priority = 900
@@ -84,7 +84,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,
             })

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.

Thanks,


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