Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Commit e4707d2

Browse files
authored
Restrict to Sphinx 5 (#282)
* Dependencies: require Sphinx 5 or newer Older Sphinx version have issues with Sphinx's dependencies itself, which isn't being fixed by the Sphinx project as these old versions are not maintained. * refactor: simplify code that maintained Sphinx compatibility Now we don't support Sphinx < 5, we don't need code that handles older versions, so we can simplify/delete as appropriate. * Update the app.require_sphinx value to 5.0
1 parent 6ff2d60 commit e4707d2

File tree

5 files changed

+18
-71
lines changed

5 files changed

+18
-71
lines changed

.circleci/config.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ commands:
88
type: string
99
sphinx-version:
1010
type: string
11-
default: "18,20,21,22,23,24,30,31,32,33,34,35,40,41,42,43,44,45,50,latest"
11+
default: "50,53,60,62,70,latest"
1212
steps:
1313
- checkout
1414
# Tox >=4 fails with `ValueError: py310-sphinx{18`
@@ -36,9 +36,6 @@ jobs:
3636
steps:
3737
- run-tox:
3838
version: py310
39-
# Do not run tests for Python 3.10 and some versions of Sphinx because it's broken
40-
# See https://github.com/sphinx-doc/sphinx/issues/9816
41-
sphinx-version: "18,20,21,22,23,24,42,43,44,45,50,latest"
4239

4340
workflows:
4441
version: 2

hoverxref/extension.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,10 @@ def setup_sphinx_tabs(app, config):
151151
Sphinx Tabs removes the CSS/JS from pages that does not use the directive.
152152
Although, we need them to use inside the tooltip.
153153
"""
154-
if sphinx.version_info < (3, 0, 0):
155-
listeners = list(app.events.listeners.get('html-page-context').items())
156-
else:
157-
listeners = [
158-
(listener.id, listener.handler)
159-
for listener in app.events.listeners.get('html-page-context')
160-
]
161-
for listener_id, function in listeners:
162-
module_name = inspect.getmodule(function).__name__
154+
for listener in app.events.listeners.get('html-page-context'):
155+
module_name = inspect.getmodule(listener.handler).__name__
163156
if module_name == 'sphinx_tabs.tabs':
164-
app.disconnect(listener_id)
157+
app.disconnect(listener.id)
165158

166159

167160
def setup_intersphinx(app, config):
@@ -179,17 +172,10 @@ def setup_intersphinx(app, config):
179172
# does not have hoverxref intersphinx enabled
180173
return
181174

182-
if sphinx.version_info < (3, 0, 0):
183-
listeners = list(app.events.listeners.get('missing-reference').items())
184-
else:
185-
listeners = [
186-
(listener.id, listener.handler)
187-
for listener in app.events.listeners.get('missing-reference')
188-
]
189-
for listener_id, function in listeners:
190-
module_name = inspect.getmodule(function).__name__
175+
for listener in app.events.listeners.get('missing-reference'):
176+
module_name = inspect.getmodule(listener.handler).__name__
191177
if module_name == 'sphinx.ext.intersphinx':
192-
app.disconnect(listener_id)
178+
app.disconnect(listener.id)
193179

194180

195181
def missing_reference(app, env, node, contnode):
@@ -335,8 +321,8 @@ def deprecated_configs_warning(app, exception):
335321
def setup(app):
336322
"""Setup ``hoverxref`` Sphinx extension."""
337323

338-
# ``override`` was introduced in 1.8
339-
app.require_sphinx('1.8')
324+
# Matches requirement from pyproject.toml
325+
app.require_sphinx('5.0')
340326

341327
app.add_config_value('hoverxref_auto_ref', False, 'env')
342328
app.add_config_value('hoverxref_mathjax', False, 'env')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ keywords=[
1717
"documentation",
1818
]
1919
dependencies = [
20-
"sphinx >=1.8",
20+
"sphinx >=5.0",
2121
"sphinxcontrib-jquery",
2222
]
2323
version = "1.3.0"

tests/test_htmltag.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ def test_python_domain_intersphinx(app, status, warning):
156156
assert chunk in content
157157

158158

159-
@pytest.mark.skipif(
160-
sphinx.version_info < (2, 1, 0),
161-
reason='sphinxcontrib-bibtex requires Sphinx>=2.1 to work',
162-
)
163159
@pytest.mark.sphinx(
164160
srcdir=bibtexdomainsrcdir,
165161
confoverrides={
@@ -270,14 +266,9 @@ def test_intersphinx_default_configs(app, status, warning):
270266
'<a class="reference internal" href="#hoverxref.extension.setup" title="hoverxref.extension.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">hoverxref.extension.setup()</span></code></a>',
271267
]
272268

273-
if sphinx.version_info >= (4, 0):
274-
chunks.extend([
275-
'<dt class="sig sig-object py" id="hoverxref.extension.setup">',
276-
])
277-
else:
278-
chunks.extend([
279-
'<dt id="hoverxref.extension.setup">',
280-
])
269+
chunks.extend([
270+
'<dt class="sig sig-object py" id="hoverxref.extension.setup">',
271+
])
281272

282273

283274
for chunk in chunks:

tox.ini

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,23 @@ isolated_build = True
44

55
envlist =
66
docs
7-
py{38,39}-sphinx{18,20,21,22,23,24,30,31,32,33,34,35,40,41,42,43,44,45,50,latest}
8-
py{310}-sphinx{18,20,21,22,23,24,42,43,44,45,50,latest}
7+
py{38,39,310}-sphinx{50,53,60,62,70,latest}
98

109
[testenv]
1110
deps =
1211
pytest
1312
pdbpp
1413
sphinxcontrib-bibtex
1514
.
16-
sphinx18: sphinx~=1.8.0
17-
sphinx20: sphinx~=2.0.0
18-
sphinx21: sphinx~=2.1.0
19-
sphinx22: sphinx~=2.2.0
20-
sphinx23: sphinx~=2.3.0
21-
sphinx24: sphinx~=2.4.0
22-
sphinx30: sphinx~=3.0.0
23-
sphinx31: sphinx~=3.1.0
24-
sphinx32: sphinx~=3.2.0
25-
sphinx33: sphinx~=3.3.0
26-
sphinx34: sphinx~=3.4.0
27-
sphinx35: sphinx~=3.5.0
28-
sphinx40: sphinx~=4.0.0
29-
sphinx41: sphinx~=4.1.0
30-
sphinx42: sphinx~=4.2.0
31-
sphinx43: sphinx~=4.3.0
32-
sphinx44: sphinx~=4.4.0
33-
sphinx45: sphinx~=4.5.0
3415
sphinx50: sphinx~=5.0.0
16+
sphinx53: sphinx~=5.3.0
17+
sphinx60: sphinx~=6.0.0
18+
sphinx62: sphinx~=6.2.0
19+
sphinx73: sphinx~=7.0.0
3520
sphinxlatest: sphinx
3621

3722
commands = pytest {posargs}
3823

39-
# Pin docutils<0.18 for all Python versions using Sphinx 1.x, 2.x, 3.x, 4.0, 4.1
40-
# since it's incompatible and generating lot of errors
41-
# https://tox.wiki/en/latest/config.html#generating-environments-conditional-settings
42-
#
43-
# Pin jinja2<3.1.0 because there is an incompatibility with the newer version:
44-
# ImportError: cannot import name 'contextfunction' from 'jinja2'
45-
[testenv:py{38,39,310}-sphinx{18,20,21,22,23,24,30,31,32,33,34,35,40,41}]
46-
deps =
47-
{[testenv]deps}
48-
docutils<0.18
49-
jinja2<3.1.0
50-
5124
[testenv:py310-sphinx50]
5225
deps =
5326
{[testenv]deps}

0 commit comments

Comments
 (0)