Skip to content

Commit 8c4d789

Browse files
authored
Merge pull request #57 from saimn/sphinx-minversion
Updates for recent Sphinx versions
2 parents f3adf2f + 759775a commit 8c4d789

File tree

9 files changed

+47
-97
lines changed

9 files changed

+47
-97
lines changed

.github/workflows/python-tests.yml

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,24 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
include:
20-
- os: ubuntu-latest
21-
python-version: 3.7
22-
toxenv: py37-test-sphinx17
2320
- os: windows-latest
2421
python-version: 3.7
25-
toxenv: py37-test-sphinx18
26-
- os: macos-latest
27-
python-version: 3.7
28-
toxenv: py37-test-sphinx20
29-
- os: ubuntu-latest
30-
python-version: 3.8
31-
toxenv: py38-test-sphinx24
32-
- os: windows-latest
33-
python-version: 3.8
3422
toxenv: py38-test-sphinx30
3523
- os: ubuntu-latest
36-
python-version: 3.9
37-
toxenv: py39-test-sphinx35
24+
python-version: 3.8
25+
toxenv: py38-test-sphinx35
3826
- os: ubuntu-latest
3927
python-version: 3.9
4028
toxenv: py39-test-sphinx40
29+
- os: ubuntu-latest
30+
python-version: "3.10"
31+
toxenv: py310-test-sphinx50
32+
- os: ubuntu-latest
33+
python-version: "3.11"
34+
toxenv: py311-test-sphinx60
4135
- os: macos-latest
42-
python-version: 3.9
43-
toxenv: py39-test-sphinxdev
36+
python-version: "3.11"
37+
toxenv: py311-test-sphinxdev
4438

4539
steps:
4640
- uses: actions/checkout@v2
@@ -54,11 +48,3 @@ jobs:
5448
run: python -m pip install tox
5549
- name: Run Tox
5650
run: tox -v -e ${{ matrix.toxenv }}
57-
58-
# - name: Slack Notification
59-
# uses: 8398a7/action-slack@v3
60-
# with:
61-
# status: ${{ job.status }}
62-
# env:
63-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
64-
# if: always() # TODO: cron

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Changes in sphinx-astropy
44
1.9 (unreleased)
55
----------------
66

7+
- Update minimum required version of Sphinx to 3.0.0. [#57]
8+
9+
- ``check_sphinx_version`` is deprecated. [#57]
10+
711
1.8 (2023-01-06)
812
----------------
913

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ packages = find:
2020
python_requires = >=3.7
2121
install_requires =
2222
packaging
23-
sphinx>=1.7
23+
sphinx>=3.0.0
2424
astropy-sphinx-theme
2525
numpydoc
2626
sphinx-automodapi

sphinx_astropy/conf/v1.py

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
import os
1313
import warnings
1414
from collections import ChainMap
15-
1615
from os import path
1716

18-
import sphinx
19-
from packaging.version import Version
17+
import astropy_sphinx_theme
2018

2119
try:
2220
import astropy
@@ -34,21 +32,15 @@
3432
# minor parts of the version number, not the micro. To do a more
3533
# specific version check, call check_sphinx_version("x.y.z.") from
3634
# your project's conf.py
37-
needs_sphinx = '1.7'
35+
needs_sphinx = '3.0'
3836

3937

4038
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
4139

4240

4341
def check_sphinx_version(expected_version):
44-
sphinx_version = Version(sphinx.__version__)
45-
expected_version = Version(expected_version)
46-
if sphinx_version < expected_version:
47-
raise RuntimeError(
48-
"At least Sphinx version {0} is required to build this "
49-
"documentation. Found {1}.".format(
50-
expected_version, sphinx_version))
51-
42+
warnings.warn("check_sphinx_version is deprecated, use needs_sphinx instead",
43+
DeprecationWarning)
5244

5345
# Configuration for intersphinx: refer to the Python standard library.
5446
intersphinx_mapping = {
@@ -64,7 +56,8 @@ def check_sphinx_version(expected_version):
6456
'matplotlib': ('https://matplotlib.org/stable/',
6557
(None, 'http://data.astropy.org/intersphinx/matplotlib.inv')),
6658
'astropy': ('https://docs.astropy.org/en/stable/', None),
67-
'h5py': ('https://docs.h5py.org/en/stable/', None)}
59+
'h5py': ('https://docs.h5py.org/en/stable/', None),
60+
}
6861

6962
# List of patterns, relative to source directory, that match files and
7063
# directories to ignore when looking for source files.
@@ -199,22 +192,24 @@ def check_sphinx_version(expected_version):
199192
# Add any Sphinx extension module names here, as strings. They can be
200193
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
201194
# ones.
202-
extensions = ['sphinx_astropy.ext.intersphinx_toggle',
203-
'sphinx.ext.autodoc',
204-
'sphinx.ext.intersphinx',
205-
'sphinx.ext.todo',
206-
'sphinx.ext.coverage',
207-
'sphinx.ext.inheritance_diagram',
208-
'sphinx.ext.viewcode',
209-
'sphinxcontrib.jquery',
210-
'numpydoc',
211-
'sphinx_automodapi.automodapi',
212-
'sphinx_automodapi.smart_resolver',
213-
'sphinx_astropy.ext.changelog_links',
214-
'sphinx_astropy.ext.generate_config',
215-
'sphinx_astropy.ext.missing_static',
216-
'sphinx.ext.mathjax',
217-
'pytest_doctestplus.sphinx.doctestplus']
195+
extensions = [
196+
'sphinx.ext.autodoc',
197+
'sphinx.ext.coverage',
198+
'sphinx.ext.inheritance_diagram',
199+
'sphinx.ext.intersphinx',
200+
'sphinx.ext.mathjax',
201+
'sphinx.ext.todo',
202+
'sphinx.ext.viewcode',
203+
'sphinxcontrib.jquery',
204+
'numpydoc',
205+
'pytest_doctestplus.sphinx.doctestplus',
206+
'sphinx_astropy.ext.changelog_links',
207+
'sphinx_astropy.ext.generate_config',
208+
'sphinx_astropy.ext.intersphinx_toggle',
209+
'sphinx_astropy.ext.missing_static',
210+
'sphinx_automodapi.automodapi',
211+
'sphinx_automodapi.smart_resolver',
212+
]
218213

219214
try:
220215
import matplotlib.sphinxext.plot_directive
@@ -248,7 +243,7 @@ def check_sphinx_version(expected_version):
248243
'-Efontsize=10',
249244
'-Efontname=Helvetica Neue, Helvetica, Arial, sans-serif',
250245
'-Gfontsize=10',
251-
'-Gfontname=Helvetica Neue, Helvetica, Arial, sans-serif'
246+
'-Gfontname=Helvetica Neue, Helvetica, Arial, sans-serif',
252247
]
253248

254249
# -- Options for HTML output -------------------------------------------------
@@ -270,7 +265,6 @@ def check_sphinx_version(expected_version):
270265
# pixels large.
271266

272267
# We include by default the favicon that is in the bootstrap-astropy theme.
273-
import astropy_sphinx_theme
274268
html_theme_path = astropy_sphinx_theme.get_html_theme_path()
275269
html_favicon = os.path.join(html_theme_path[0], html_theme, 'static', 'astropy_logo.ico')
276270

sphinx_astropy/ext/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from __future__ import division, absolute_import, print_function
21

sphinx_astropy/ext/changelog_links.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
GitHub issues.
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from docutils.nodes import Text, reference
119

sphinx_astropy/ext/intersphinx_toggle.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@
99
1010
This is used e.g. by astropy-helpers when using the build_docs command.
1111
"""
12-
from packaging.version import Version
1312

14-
from sphinx import __version__
15-
16-
SPHINX_LT_18 = Version(__version__) < Version('1.8')
13+
from sphinx.util.console import bold
14+
from sphinx.util import logging
1715

1816

1917
def disable_intersphinx(app, config=None):
20-
21-
from sphinx.util.console import bold
22-
23-
from sphinx.util import logging
2418
info = logging.getLogger(__name__).info
2519

2620
if app.config.disable_intersphinx:
@@ -29,16 +23,7 @@ def disable_intersphinx(app, config=None):
2923

3024

3125
def setup(app):
32-
33-
# Note that the config-inited setting was only added in Sphinx 1.8. For
34-
# earlier versions we use builder-inited but we need to be careful in what
35-
# order the extensions are declared so that this happens before intersphinx.
36-
if SPHINX_LT_18:
37-
app.connect('builder-inited', disable_intersphinx)
38-
else:
39-
app.connect('config-inited', disable_intersphinx)
40-
26+
app.connect('config-inited', disable_intersphinx)
4127
app.add_config_value('disable_intersphinx', 0, True)
42-
4328
return {'parallel_read_safe': True,
4429
'parallel_write_safe': True}

sphinx_astropy/ext/missing_static.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
a static directory to be present but it isn't.
66
"""
77
import os
8-
from packaging.version import Version
9-
10-
from sphinx import __version__
11-
12-
SPHINX_LT_18 = Version(__version__) < Version('1.8')
13-
8+
from sphinx.util import logging
149

1510
WARNING_TEMPLATE = """
1611
Note: The static directory '{0}' was not found. This is often because it is
@@ -22,8 +17,6 @@
2217

2318

2419
def static_warning(app, config=None):
25-
26-
from sphinx.util import logging
2720
info = logging.getLogger(__name__).info
2821

2922
for directory in app.config.html_static_path:
@@ -32,7 +25,6 @@ def static_warning(app, config=None):
3225

3326

3427
def setup(app):
35-
3628
app.connect('build-finished', static_warning)
3729

3830
return {'parallel_read_safe': True,

tox.ini

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
envlist =
3-
py{37,38,39}-test
3+
py{37,38,39,310,311}-test
44
codestyle
55
requires =
66
setuptools >= 30.3.0
@@ -12,22 +12,14 @@ changedir = .tmp/{envname}
1212
description = run tests
1313
extras = tests
1414
deps =
15-
sphinx17: sphinx==1.7.*
16-
sphinx17: Jinja2==3.0.3
17-
sphinx18: sphinx==1.8.*
18-
sphinx18: Jinja2==3.0.3
19-
sphinx20: sphinx==2.0.*
20-
sphinx20: docutils==0.17.*
21-
sphinx20: Jinja2==3.0.3
22-
sphinx24: sphinx==2.4.*
23-
sphinx24: docutils==0.17.*
24-
sphinx24: Jinja2==3.0.3
2515
sphinx30: sphinx==3.0.*
2616
sphinx30: docutils==0.17.*
2717
sphinx30: Jinja2==3.0.3
2818
sphinx35: sphinx==3.5.*
2919
sphinx35: Jinja2==3.0.3
3020
sphinx40: sphinx==4.0.*
21+
sphinx50: sphinx==5.0.*
22+
sphinx60: sphinx==6.0.*
3123
sphinxdev: git+https://github.com/sphinx-doc/sphinx#egg=sphinx
3224

3325
commands =

0 commit comments

Comments
 (0)