From 7fa86a6b08cf8369c6a2ee679bf453986045a5bb Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 7 May 2024 23:48:04 +0900 Subject: [PATCH 1/2] do not create 404 page for embedded (e.g. ePub) --- notfound/extension.py | 6 +++--- tests/test_urls.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/notfound/extension.py b/notfound/extension.py index b46ccf8..1520452 100644 --- a/notfound/extension.py +++ b/notfound/extension.py @@ -31,9 +31,9 @@ def html_collect_pages(app): :param app: Sphinx Application :type app: sphinx.application.Sphinx """ - if app.config.notfound_pagename in app.env.titles: - # There is already a ``404.rst`` file rendered. - # Skip generating our default one. + if app.builder.embedded or app.config.notfound_pagename in app.env.titles: + # Building embedded (e.g. htmlhelp or ePub) or there is already a ``404.rst`` + # file rendered. Skip generating our default one. return [] return [( diff --git a/tests/test_urls.py b/tests/test_urls.py index beb93e8..cfe6477 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -46,6 +46,12 @@ def test_404_page_created(app, status, warning): path = app.outdir / '404.html' assert path.exists() +@pytest.mark.sphinx('epub', srcdir=srcdir) +def test_404_page_not_created(app, status, warning): + assert app.builder.embedded + app.build() + path = app.outdir / '404.html' + assert not path.exists() @pytest.mark.sphinx(srcdir=srcdir) def test_default_settings(app, status, warning): From 532ddded643045c3fa9cf11f46329b7de59435eb Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 7 May 2024 23:57:14 +0900 Subject: [PATCH 2/2] add defusedxml as deps --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 0f6ea30..df783b3 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ envlist = deps = pytest pdbpp + defusedxml . sphinx5: sphinx<6.0 sphinx6: sphinx<7.0