Skip to content

Commit 9e09fbb

Browse files
AakashGfudemmcky
andauthored
ENH: Compatibility with docutils>=0.18 (from support with sphinx>=5) (#60)
* pre-commit file update * removing python 3.6 * removing python 3.6 * updated tests * sphinx version * sphinx versions * specific test files for sphinx4 * remove py37 support * update CI * removing python3.7 * updating tests for sphinx5 Co-authored-by: mmcky <[email protected]>
1 parent f555d72 commit 9e09fbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+854
-115
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Set up Python 3.8
16+
- name: Set up Python 3.9
1717
uses: actions/setup-python@v1
1818
with:
19-
python-version: 3.8
19+
python-version: 3.9
2020
- uses: pre-commit/[email protected]
2121

2222
tests:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
python-version: [3.6, 3.7, 3.8]
26+
python-version: [3.8, 3.9]
2727
steps:
2828
- uses: actions/checkout@v2
2929
- name: Set up Python ${{ matrix.python-version }}
@@ -40,10 +40,10 @@ jobs:
4040
- name: Create cov
4141
run: coverage xml
4242
- name: Upload to Codecov
43-
if: matrix.python-version == 3.7
43+
if: matrix.python-version == 3.8
4444
uses: codecov/codecov-action@v1
4545
with:
46-
name: sphinx-exercise-pytest-py3.7
46+
name: sphinx-exercise-pytest-py3.8
4747
flags: pytests
4848
file: ./coverage.xml
4949
fail_ci_if_error: true
@@ -53,10 +53,10 @@ jobs:
5353
runs-on: ubuntu-latest
5454
steps:
5555
- uses: actions/checkout@v2
56-
- name: Set up Python 3.8
56+
- name: Set up Python 3.9
5757
uses: actions/setup-python@v1
5858
with:
59-
python-version: 3.8
59+
python-version: 3.9
6060
- name: Install dependencies
6161
run: |
6262
python -m pip install --upgrade pip
@@ -75,10 +75,10 @@ jobs:
7575
steps:
7676
- name: Checkout source
7777
uses: actions/checkout@v2
78-
- name: Set up Python 3.7
78+
- name: Set up Python 3.9
7979
uses: actions/setup-python@v1
8080
with:
81-
python-version: 3.7
81+
python-version: 3.9
8282
- name: Build package
8383
run: |
8484
pip install wheel

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ exclude: >
1515
1616
repos:
1717

18-
- repo: git://github.com/pre-commit/pre-commit-hooks
19-
rev: v2.2.3
18+
- repo: https://github.com/pre-commit/pre-commit-hooks
19+
rev: v4.3.0
2020
hooks:
2121
- id: check-yaml
2222
- id: end-of-file-fixer
2323
- id: trailing-whitespace
2424

25-
- repo: https://gitlab.com/pycqa/flake8
26-
rev: 3.7.9
25+
- repo: https://github.com/PyCQA/flake8
26+
rev: 5.0.4
2727
hooks:
2828
- id: flake8
2929

3030
- repo: https://github.com/psf/black
31-
rev: 20.8b1
31+
rev: 22.8.0
3232
hooks:
3333
- id: black

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sphinx>=3.0
1+
sphinx>=4,<6
22
sphinx-book-theme
33
myst-nb

docs/runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7
1+
3.8

setup.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,23 @@
1818

1919
# Define all extras
2020
extras = {
21-
"code_style": ["flake8<3.8.0,>=3.7.0", "black", "pre-commit==1.17.0"],
21+
"code_style": ["flake8<3.8.0,>=3.7.0", "black", "pre-commit"],
2222
"testing": [
2323
"coverage",
2424
"pytest>=3.6,<4",
2525
"pytest-cov",
2626
"pytest-regressions",
2727
"beautifulsoup4",
28-
"myst-nb",
28+
"myst-nb~=0.17.1",
29+
"sphinx>=4,<6",
30+
"docutils>=0.15,<0.19",
2931
"texsoup",
3032
"matplotlib",
3133
],
3234
"rtd": [
33-
"sphinx>=3.0",
35+
"sphinx>=4,<6",
3436
"sphinx-book-theme",
35-
"myst-nb",
37+
"myst-nb~=0.17.1",
3638
],
3739
}
3840

@@ -41,7 +43,7 @@
4143
setup(
4244
name="sphinx-exercise",
4345
version=VERSION,
44-
python_requires=">=3.6",
46+
python_requires=">=3.8",
4547
author="QuantEcon",
4648
author_email="[email protected]",
4749
url=BASE_URL,
@@ -55,7 +57,7 @@
5557
long_description_content_type="text/markdown",
5658
license="BSD",
5759
packages=find_packages(),
58-
install_requires=["docutils>=0.15", "sphinx", "sphinx-book-theme"],
60+
install_requires=["sphinx>=4", "sphinx-book-theme"],
5961
extras_require=extras,
6062
include_package_data=True,
6163
classifiers=[
@@ -67,9 +69,8 @@
6769
"License :: OSI Approved :: MIT License",
6870
"Natural Language :: English",
6971
"Operating System :: OS Independent",
70-
"Programming Language :: Python :: 3.6",
71-
"Programming Language :: Python :: 3.7",
7272
"Programming Language :: Python :: 3.8",
73+
"Programming Language :: Python :: 3.9",
7374
"Programming Language :: Python",
7475
"Topic :: Documentation :: Sphinx",
7576
"Topic :: Documentation",

sphinx_exercise/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767

6868
def purge_exercises(app: Sphinx, env: BuildEnvironment, docname: str) -> None:
69-
""" Purge sphinx_exercise registry """
69+
"""Purge sphinx_exercise registry"""
7070

7171
if not hasattr(env, "sphinx_exercise_registry"):
7272
return
@@ -85,7 +85,7 @@ def purge_exercises(app: Sphinx, env: BuildEnvironment, docname: str) -> None:
8585
def merge_exercises(
8686
app: Sphinx, env: BuildEnvironment, docnames: Set[str], other: BuildEnvironment
8787
) -> None:
88-
""" Merge sphinx_exercise_registry """
88+
"""Merge sphinx_exercise_registry"""
8989

9090
if not hasattr(env, "sphinx_exercise_registry"):
9191
env.sphinx_exercise_registry = {}
@@ -109,7 +109,7 @@ def init_numfig(app: Sphinx, config: Config) -> None:
109109

110110

111111
def copy_asset_files(app: Sphinx, exc: Union[bool, Exception]):
112-
""" Copies required assets for formating in HTML """
112+
"""Copies required assets for formating in HTML"""
113113

114114
static_path = (
115115
Path(__file__).parent.joinpath("assets", "html", "exercise.css").absolute()

sphinx_exercise/directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
class SphinxExerciseBaseDirective(SphinxDirective):
3434
def duplicate_labels(self, label):
35-
""" Check for duplicate labels """
35+
"""Check for duplicate labels"""
3636

3737
if not label == "" and label in self.env.sphinx_exercise_registry.keys():
3838
docpath = self.env.doc2path(self.env.docname)

sphinx_exercise/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CheckGatedDirectives(SphinxTransform):
2828
default_priority = 1
2929

3030
def check_structure(self, registry):
31-
""" Check Structure of the Gated Registry"""
31+
"""Check Structure of the Gated Registry"""
3232
error = False
3333
docname = self.env.docname
3434
if docname in registry:
@@ -111,7 +111,7 @@ def apply(self):
111111
new_node += child
112112
# Collect nodes attached to the Parent Node until :solution-end:
113113
content = docutils.nodes.section(
114-
ids="solution-content"
114+
ids=["solution-content"]
115115
) # TODO: should id be classes?
116116
for child in parent.children[parent_start + 1 : parent_end]:
117117
content += child

tests/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,24 @@ def read(app):
2727

2828
@pytest.fixture
2929
def get_sphinx_app_doctree(file_regression):
30-
def read(app, docname="index", resolve=False, regress=False, flatten_outdir=False):
30+
def read(
31+
app,
32+
docname="index",
33+
resolve=False,
34+
regress=False,
35+
flatten_outdir=False,
36+
sphinx_version=False,
37+
):
3138
if resolve:
3239
doctree = app.env.get_and_resolve_doctree(docname, app.builder)
3340
extension = ".resolved.xml"
3441
else:
3542
doctree = app.env.get_doctree(docname)
3643
extension = ".xml"
3744

45+
if sphinx_version:
46+
extension = sphinx_version + extension
47+
3848
# convert absolute filenames
3949
for node in doctree.traverse(lambda n: "source" in n):
4050
node["source"] = Path(node["source"]).name

tests/test_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ def test_warnings(app, warnings, wmsg):
3737
build_path = app.srcdir.joinpath("_build")
3838
shutil.rmtree(build_path)
3939
app.build()
40-
assert wmsg in warnings(app)
40+
assert wmsg in warnings(app).replace("'", "")

0 commit comments

Comments
 (0)