Skip to content

Commit

Permalink
⬆️ Update sphinx v8 and test dependency versions (#212)
Browse files Browse the repository at this point in the history
Support sphinx v8, drop v5
  • Loading branch information
chrisjsewell authored Aug 2, 2024
1 parent a3bdfa3 commit 36d3378
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 25 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- uses: pre-commit/[email protected]
Expand All @@ -29,30 +29,36 @@ jobs:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
sphinx-version: ["~=7.0"]
extras: ["testing"]
include:
- os: ubuntu-latest
python-version: 3.9
sphinx-version: "~=5.0"
- os: ubuntu-latest
python-version: 3.9
python-version: "3.9"
sphinx-version: "~=6.0"
extras: "testing"
- os: ubuntu-latest
python-version: "3.10"
sphinx-version: "~=8.0"
extras: "testing-no-myst" # TODO myst does not yet support Sphinx 8.0
- os: windows-latest
python-version: 3.9
python-version: "3.9"
sphinx-version: "~=7.0"
extras: "testing"

runs-on: ${{ matrix.os }}

name: Tests (py${{ matrix.python-version }}, Sphinx${{ matrix.sphinx-version }}, on ${{ matrix.os }})

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade "sphinx${{ matrix.sphinx-version }}" -e .[testing]
pip install --upgrade "sphinx${{ matrix.sphinx-version }}" -e .[${{ matrix.extras}}]
- name: Run pytest
run: |
pytest --cov=sphinx_design --cov-report=xml --cov-report=term-missing
Expand All @@ -76,7 +82,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: pip
Expand Down Expand Up @@ -115,7 +121,7 @@ jobs:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: install flit
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
rev: v0.5.5
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.11.1
hooks:
- id: mypy
additional_dependencies: []
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.10"

python:
install:
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ coverage:
status:
project:
default:
target: 90%
target: 85%
threshold: 0.2%
patch:
default:
Expand Down
19 changes: 13 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
Expand All @@ -27,28 +28,34 @@ classifiers = [
]
keywords = ["sphinx", "extension", "material design", "web components"]
requires-python = ">=3.9"
dependencies = ["sphinx>=5,<8"]
dependencies = ["sphinx>=6,<9"]

[project.urls]
Homepage = "https://github.com/executablebooks/sphinx-design"
Documentation = "https://sphinx-design.readthedocs.io"

[project.optional-dependencies]
code-style = ["pre-commit>=3,<4"]
rtd = ["myst-parser>=1,<3"]
rtd = ["myst-parser>=2,<4"]
testing = [
"myst-parser>=1,<3",
"pytest~=7.1",
"myst-parser>=2,<4",
"pytest~=8.3",
"pytest-cov",
"pytest-regressions",
"defusedxml",
]
testing-no-myst = [
"pytest~=8.3",
"pytest-cov",
"pytest-regressions",
"defusedxml",
]

theme-furo = ["furo~=2024.5.4"]
theme-furo = ["furo~=2024.7.18"]
theme-pydata = ["pydata-sphinx-theme~=0.15.2"]
theme-rtd = ["sphinx-rtd-theme~=2.0"]
theme-sbt = ["sphinx-book-theme~=1.1"]
theme-im = ["sphinx-immaterial~=0.11.11"]
theme-im = ["sphinx-immaterial~=0.12.2"]

[tool.flit.sdist]
exclude = [
Expand Down
2 changes: 1 addition & 1 deletion sphinx_design/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def split_content(content: StringList, offset: int) -> CardContent:
return CardContent(body, header, footer)

@classmethod
def _create_component( # noqa: PLR0913
def _create_component(
cls,
inst: SphinxDirective,
name: str,
Expand Down
17 changes: 14 additions & 3 deletions tests/test_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

from .conftest import SphinxBuilder

try:
import myst_parser # noqa: F401

MYST_INSTALLED = True
except ImportError:
MYST_INSTALLED = False

SNIPPETS_PATH = Path(__file__).parent.parent / "docs" / "snippets"
SNIPPETS_GLOB_RST = list((SNIPPETS_PATH / "rst").glob("[!_]*"))
SNIPPETS_GLOB_MYST = list((SNIPPETS_PATH / "myst").glob("[!_]*"))
Expand All @@ -29,7 +36,7 @@ def test_snippets_rst(
sphinx_builder: Callable[..., SphinxBuilder], path: Path, file_regression
):
"""Test snippets written in RestructuredText (before post-transforms)."""
builder = sphinx_builder()
builder = sphinx_builder(conf_kwargs={"extensions": ["sphinx_design"]})
content = "Heading\n-------" + "\n\n" + path.read_text(encoding="utf8")
builder.src_path.joinpath("index.rst").write_text(content, encoding="utf8")
write_assets(builder.src_path)
Expand All @@ -49,6 +56,7 @@ def test_snippets_rst(
SNIPPETS_GLOB_MYST,
ids=[path.name[: -len(path.suffix)] for path in SNIPPETS_GLOB_MYST],
)
@pytest.mark.skipif(not MYST_INSTALLED, reason="myst-parser not installed")
def test_snippets_myst(
sphinx_builder: Callable[..., SphinxBuilder], path: Path, file_regression
):
Expand Down Expand Up @@ -77,7 +85,7 @@ def test_snippets_rst_post(
sphinx_builder: Callable[..., SphinxBuilder], path: Path, file_regression
):
"""Test snippets written in RestructuredText (after HTML post-transforms)."""
builder = sphinx_builder()
builder = sphinx_builder(conf_kwargs={"extensions": ["sphinx_design"]})
content = "Heading\n-------" + "\n\n" + path.read_text(encoding="utf8")
builder.src_path.joinpath("index.rst").write_text(content, encoding="utf8")
write_assets(builder.src_path)
Expand All @@ -97,6 +105,7 @@ def test_snippets_rst_post(
SNIPPETS_GLOB_MYST,
ids=[path.name[: -len(path.suffix)] for path in SNIPPETS_GLOB_MYST],
)
@pytest.mark.skipif(not MYST_INSTALLED, reason="myst-parser not installed")
def test_snippets_myst_post(
sphinx_builder: Callable[..., SphinxBuilder], path: Path, file_regression
):
Expand All @@ -120,7 +129,7 @@ def test_sd_hide_title_rst(
sphinx_builder: Callable[..., SphinxBuilder], file_regression
):
"""Test that the root title is hidden."""
builder = sphinx_builder()
builder = sphinx_builder(conf_kwargs={"extensions": ["sphinx_design"]})
content = ":sd_hide_title:\n\nHeading\n-------\n\ncontent"
builder.src_path.joinpath("index.rst").write_text(content, encoding="utf8")
builder.build()
Expand All @@ -134,6 +143,7 @@ def test_sd_hide_title_rst(
)


@pytest.mark.skipif(not MYST_INSTALLED, reason="myst-parser not installed")
def test_sd_hide_title_myst(
sphinx_builder: Callable[..., SphinxBuilder], file_regression
):
Expand All @@ -152,6 +162,7 @@ def test_sd_hide_title_myst(
)


@pytest.mark.skipif(not MYST_INSTALLED, reason="myst-parser not installed")
def test_sd_custom_directives(
sphinx_builder: Callable[..., SphinxBuilder], file_regression
):
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ envlist = py39
[testenv]
usedevelop = true

[testenv:py{39,310,311,312}]
[testenv:py{39,310,311,312,313}]
description = Run unit tests with this Python version
extras =
testing
commands = pytest {posargs}

[testenv:py{39,310,311,312,313}-no-myst]
description = Run unit tests with this Python version
extras =
testing-no-myst
commands = pytest {posargs}

[testenv:docs-{alabaster,rtd,pydata,sbt,furo,im}]
description =
Run documentation build for this theme
Expand Down

0 comments on commit 36d3378

Please sign in to comment.