From 082bcad2d7f2443e1777e7b020cdf96feaffd956 Mon Sep 17 00:00:00 2001 From: memsharded Date: Tue, 4 Jun 2024 10:05:52 +0200 Subject: [PATCH 1/3] fix generation of epub (sphinx bug) --- conf.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/conf.py b/conf.py index ace986c2711..aa9562c58ff 100644 --- a/conf.py +++ b/conf.py @@ -457,3 +457,23 @@ def copy_legacy_redirects(app, docname): # Sphinx expects two arguments def setup(app): app.connect('build-finished', copy_legacy_redirects) + + +def monkeypatch_method(cls, fname=None): + def decorator(func): + local_fname = fname + if local_fname is None: + local_fname = func.__name__ + setattr(func, "orig", getattr(cls, local_fname, None)) + setattr(cls, local_fname, func) + return func + return decorator + +import sphinx.application + + +@monkeypatch_method(sphinx.application.Sphinx) +def add_node(self, node, override=False, **kwds): + if 'html' in kwds and 'epub' not in kwds: + kwds['epub'] = kwds['html'] + return add_node.orig(self, node, override, **kwds) From be0451307478ee244cb235c1d0108ed2cef0c488 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 8 Jul 2024 16:56:07 +0200 Subject: [PATCH 2/3] Update conf.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Abril Rincón Blanco --- conf.py | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/conf.py b/conf.py index aa9562c58ff..f7744f444b7 100644 --- a/conf.py +++ b/conf.py @@ -454,26 +454,11 @@ def copy_legacy_redirects(app, docname): # Sphinx expects two arguments os.makedirs(os.path.dirname(target_path)) with open(target_path, "w") as f: f.write(html) - +def fix_epub_generation(app): + # Ensure there's an epub handler + if "html" in app.registry.translation_handlers + app.registry.translation_handlers["epub"] = app.registry.translation_handlers["html"] + def setup(app): app.connect('build-finished', copy_legacy_redirects) - - -def monkeypatch_method(cls, fname=None): - def decorator(func): - local_fname = fname - if local_fname is None: - local_fname = func.__name__ - setattr(func, "orig", getattr(cls, local_fname, None)) - setattr(cls, local_fname, func) - return func - return decorator - -import sphinx.application - - -@monkeypatch_method(sphinx.application.Sphinx) -def add_node(self, node, override=False, **kwds): - if 'html' in kwds and 'epub' not in kwds: - kwds['epub'] = kwds['html'] - return add_node.orig(self, node, override, **kwds) + fix_epub_generation(app) From aa82282eacfaa743d33ecaaaa50fff1106ff2e05 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 13 Nov 2024 11:26:10 +0100 Subject: [PATCH 3/3] Update conf.py --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index f7744f444b7..e09892392a9 100644 --- a/conf.py +++ b/conf.py @@ -456,7 +456,7 @@ def copy_legacy_redirects(app, docname): # Sphinx expects two arguments f.write(html) def fix_epub_generation(app): # Ensure there's an epub handler - if "html" in app.registry.translation_handlers + if "html" in app.registry.translation_handlers: app.registry.translation_handlers["epub"] = app.registry.translation_handlers["html"] def setup(app):