diff --git a/Make-the-tests-pass-with-Sphinx-7.3.x.patch b/Make-the-tests-pass-with-Sphinx-7.3.x.patch new file mode 100644 index 0000000000000000000000000000000000000000..1d4d4f5715b62e86e67df4084024be8c3306e14a --- /dev/null +++ b/Make-the-tests-pass-with-Sphinx-7.3.x.patch @@ -0,0 +1,42 @@ +From 2c7cd9adb7e23071fd803abe8729b9143d8dccd1 Mon Sep 17 00:00:00 2001 +From: Dmitry Shachnev +Date: Mon, 5 Aug 2024 11:54:24 +0300 +Subject: [PATCH] Make the tests pass with Sphinx 7.3.x (#245) + +Commit https://github.com/sphinx-doc/sphinx/commit/6471027d1936f0a0 was +included in Sphinx 7.4, not 7.3. +--- + tests/test_urls.py | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tests/test_urls.py b/tests/test_urls.py +index d5a4031..d5a10a5 100644 +--- a/tests/test_urls.py ++++ b/tests/test_urls.py +@@ -64,7 +64,7 @@ def test_default_settings(app, status, warning): + else: + cssclass = "" + +- if sphinx.version_info < (7, 3): ++ if sphinx.version_info < (7, 4): + alt = "Logo" + else: + alt = "Logo of Python" +@@ -144,7 +144,7 @@ def test_urls_prefix_setting(app, status, warning): + else: + cssclass = "" + +- if sphinx.version_info < (7, 3): ++ if sphinx.version_info < (7, 4): + alt = "Logo" + else: + alt = "Logo of Python" +@@ -187,7 +187,7 @@ def test_urls_prefix_setting_none(app, status, warning): + else: + cssclass = "" + +- if sphinx.version_info < (7, 3): ++ if sphinx.version_info < (7, 4): + alt = "Logo" + else: + alt = "Logo of Python" diff --git a/Make-the-tests-pass-with-Sphinx-8.1.patch b/Make-the-tests-pass-with-Sphinx-8.1.patch new file mode 100644 index 0000000000000000000000000000000000000000..802ad6227203dc2f2e447f4f797b327eb4a59527 --- /dev/null +++ b/Make-the-tests-pass-with-Sphinx-8.1.patch @@ -0,0 +1,147 @@ +From 8af414e0f76dddd64143090a7eb9ff9d3f1de2d1 Mon Sep 17 00:00:00 2001 +From: Dmitry Shachnev +Date: Wed, 4 Dec 2024 15:33:24 +0300 +Subject: [PATCH] Make the tests pass with Sphinx 8.1 (#250) + +* Make the tests pass with Sphinx 8.1 + +See https://github.com/sphinx-doc/sphinx/pull/12776 which changed the +default theme from alabaster to basic and broke the tests. + +Fixes #249. + +* Sphinx master dropped support for Python 3.10 + +See https://github.com/sphinx-doc/sphinx/pull/13000. + +* Add explicit docstrings to OrphanMetadataCollector members without :event: +--- + .circleci/config.yml | 1 + + notfound/extension.py | 8 ++++++++ + tests/test_urls.py | 15 ++++++++++++++- + tox.ini | 3 ++- + 4 files changed, 25 insertions(+), 2 deletions(-) + +diff --git a/.circleci/config.yml b/.circleci/config.yml +index 74869c4..f912e34 100644 +--- a/.circleci/config.yml ++++ b/.circleci/config.yml +@@ -37,6 +37,7 @@ jobs: + steps: + - run-tox: + version: py310 ++ sphinx-version: "5,6,7,8" + py311: + docker: + - image: 'cimg/python:3.11' +diff --git a/notfound/extension.py b/notfound/extension.py +index c89afaf..221b85d 100644 +--- a/notfound/extension.py ++++ b/notfound/extension.py +@@ -249,9 +249,17 @@ class OrphanMetadataCollector(EnvironmentCollector): + """ + + def clear_doc(self, app, env, docname): ++ """Remove specified data of a document. ++ ++ This method is called on the removal of the document. ++ """ + return None + + def process_doc(self, app, doctree): ++ """Process a document and gather specific data from it. ++ ++ This method is called after the document is read. ++ """ + metadata = app.env.metadata[app.config.notfound_pagename] + metadata.update({'orphan': True, 'nosearch': True}) + +diff --git a/tests/test_urls.py b/tests/test_urls.py +index d5a10a5..21ffb53 100644 +--- a/tests/test_urls.py ++++ b/tests/test_urls.py +@@ -52,7 +52,13 @@ def test_404_page_not_created(app, status, warning): + path = app.outdir / '404.html' + assert not path.exists() + +-@pytest.mark.sphinx(srcdir=srcdir) ++@pytest.mark.sphinx( ++ srcdir=srcdir, ++ # Sphinx changed the default theme to basic in version 8.1.0 ++ # (https://github.com/sphinx-doc/sphinx/pull/12776), but our ++ # tests depend heavily on the specifics of alabaster. ++ confoverrides={'html_theme': 'alabaster'}, ++) + def test_default_settings(app, status, warning): + app.build() + path = app.outdir / '404.html' +@@ -130,6 +136,7 @@ def test_pagename_setting(app, status, warning): + srcdir=srcdir, + confoverrides={ + 'notfound_urls_prefix': '/language/version/', ++ 'html_theme': 'alabaster', + }, + ) + def test_urls_prefix_setting(app, status, warning): +@@ -173,6 +180,7 @@ def test_urls_prefix_setting(app, status, warning): + srcdir=srcdir, + confoverrides={ + 'notfound_urls_prefix': None, ++ 'html_theme': 'alabaster', + }, + ) + def test_urls_prefix_setting_none(app, status, warning): +@@ -248,6 +256,7 @@ def test_template_setting(app, status, warning): + srcdir=rstsrcdir, + confoverrides={ + 'version': '2.5.1', ++ 'html_theme': 'alabaster', + }, + ) + def test_custom_404_rst_source(app, status, warning): +@@ -359,6 +368,7 @@ def test_image_absolute_url(app, status, warning): + @pytest.mark.sphinx( + srcdir=srcdir, + buildername='dirhtml', ++ confoverrides={'html_theme': 'alabaster'}, + ) + def test_urls_for_dirhtml_builder(app, status, warning): + app.build() +@@ -409,6 +419,7 @@ def test_sphinx_resource_urls(app, status, warning): + srcdir=srcdir, + confoverrides={ + 'notfound_urls_prefix': '/ja/default/', ++ 'html_theme': 'alabaster', + }, + ) + def test_toctree_urls_notfound_default(app, status, warning): +@@ -435,6 +446,7 @@ def test_toctree_urls_notfound_default(app, status, warning): + + @pytest.mark.sphinx( + srcdir=srcdir, ++ confoverrides={'html_theme': 'alabaster'}, + ) + def test_toctree_links(app, status, warning): + app.build() +@@ -456,6 +468,7 @@ def test_toctree_links(app, status, warning): + srcdir=srcdir, + confoverrides={ + 'notfound_urls_prefix': '/pt-br/stable/', ++ 'html_theme': 'alabaster', + }, + ) + def test_toctree_links_custom_settings(app, status, warning): +diff --git a/tox.ini b/tox.ini +index a2107a8..02644d9 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -6,7 +6,8 @@ envlist = + docs + py{38}-sphinx{5,6} + py{39}-sphinx{5,6,7} +- py{310,311,312}-sphinx{5,6,7,8,latest,dev} ++ py{310}-sphinx{5,6,7,8} ++ py{311,312}-sphinx{5,6,7,8,latest,dev} + + [testenv] + deps = diff --git a/python-sphinx-notfound-page.spec b/python-sphinx-notfound-page.spec index c5ad4724357e646ee90016d4ae892f9809dbf484..010c207d3db31731426db3587f0ba43bcd36bb38 100644 --- a/python-sphinx-notfound-page.spec +++ b/python-sphinx-notfound-page.spec @@ -6,12 +6,17 @@ Name: python-%{pypi_name} Version: 1.0.4 -Release: 1 +Release: 2 Summary: Create a custom 404 page with absolute URLs hardcoded License: MIT URL: https://pypi.python.org/pypi/%{pypi_name} Source0: https://github.com/%{project_owner}/%{pypi_name}/archive/%{version}/%{pypi_name}-%{version}.tar.gz +# https://github.com/readthedocs/sphinx-notfound-page/commit/2c7cd9adb7e23071fd803abe8729b9143d8dccd1 +Patch0: Make-the-tests-pass-with-Sphinx-7.3.x.patch +# https://github.com/readthedocs/sphinx-notfound-page/commit/8af414e0f76dddd64143090a7eb9ff9d3f1de2d1 +Patch1: Make-the-tests-pass-with-Sphinx-8.1.patch + BuildArch: noarch %description @@ -24,6 +29,7 @@ BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-sphinx BuildRequires: python3-pytest python3-pip python3-flit-core +BuildRequires: python3-simplejson Requires(post): %{_sbindir}/update-alternatives Requires(postun): %{_sbindir}/update-alternatives Requires: python%{python3_pkgversion}-setuptools @@ -53,6 +59,9 @@ PYTHONPATH=$PWD py.test-%{python3_version} -v . %{python3_sitelib}/%{importname}/ %changelog +* Tue Jan 21 2025 yaoxin <1024769339@qq.com> - 1.0.4-2 +- Fix tests with sphinx 7.3.x and 8.x + * Thu Aug 29 2024 yaoxin - 1.0.4-1 - Update to 1.0.4: * fix: Error with sphinx-notfound-page 1.0.3 - 'tuple' object has no attribute 'default'