diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6b4a44..e9cc69e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/action@v3.0.1 @@ -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 @@ -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 @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b812969..d1d68f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: [] diff --git a/.readthedocs.yml b/.readthedocs.yml index a418de2..929b95b 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.9" + python: "3.10" python: install: diff --git a/codecov.yml b/codecov.yml index a30b482..3c12742 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,7 +2,7 @@ coverage: status: project: default: - target: 90% + target: 85% threshold: 0.2% patch: default: diff --git a/pyproject.toml b/pyproject.toml index c307e72..995c00c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -27,7 +28,7 @@ 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" @@ -35,20 +36,26 @@ 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 = [ diff --git a/sphinx_design/cards.py b/sphinx_design/cards.py index f7ba580..da522f5 100644 --- a/sphinx_design/cards.py +++ b/sphinx_design/cards.py @@ -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, diff --git a/tests/test_snippets.py b/tests/test_snippets.py index 986d1a3..e47bea7 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -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("[!_]*")) @@ -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) @@ -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 ): @@ -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) @@ -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 ): @@ -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() @@ -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 ): @@ -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 ): diff --git a/tox.ini b/tox.ini index fad8312..57aa07f 100644 --- a/tox.ini +++ b/tox.ini @@ -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