Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# set -e
# pip install --upgrade pip
# pip install sphinx_rust --find-links dist --force-reinstall
# pip install pytest pytest-param-files
# pip install pytest
# pytest
# - name: pytest
# if: ${{ !startsWith(matrix.target, 'x86') && matrix.target != 'ppc64' }}
Expand All @@ -68,7 +68,7 @@ jobs:
# install: |
# apt-get update
# apt-get install -y --no-install-recommends python3-dev python3-pip build-essential
# pip3 install -U pip pytest pytest-param-files
# pip3 install -U pip pytest
# run: |
# set -e
# pip3 install sphinx_rust --find-links dist --force-reinstall
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
# set -e
# pip install --upgrade pip
# pip install sphinx_rust --find-links dist --force-reinstall
# pip install pytest pytest-param-files
# pip install pytest
# pytest

macos:
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
# set -e
# pip install --upgrade pip
# pip install sphinx_rust --find-links dist --force-reinstall
# pip install pytest pytest-param-files
# pip install pytest
# pytest

sdist:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: pip install -e .[testing]
- run: pip install -e .[test]
env:
RUST_BACKTRACE: 1
- run: pip freeze
# - run: pytest
- run: pytest

check:
if: always()
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ To run the analysis CLI tool:
tox -e dev -- python -m sphinx_rust.cli crates/py_binding --overwrite
```

To run the pytest tests:

```bash
tox -e test-py39
```

To build the documentation:

```bash
Expand Down
18 changes: 15 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dynamic = ["version"]
description = "Sphinx plugin for documentation of Rust projects."
authors = [{ name = "Chris Sewell", email = "chrisj_sewell@hotmail.com" }]
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = { file = "LICENSE" }
keywords = [
"sphinx",
Expand All @@ -26,7 +26,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -47,9 +46,12 @@ Documentation = "http://sphinx-rust.readthedocs.io"

[project.optional-dependencies]
dev = [
"pytest",
"ipython"
]
test = [
"pytest",
"defusedxml",
]
docs = [
"furo",
"myst-parser",
Expand Down Expand Up @@ -111,6 +113,16 @@ allowlist_externals = bash
commands_pre = bash -c "unset CONDA_PREFIX; maturin develop"
commands = {posargs:ipython}

[testenv:test-{py39,py310,py311,py312}]
extras = test
passenv = TERM
; ensure that the compilation is up-to-date
; There is an issue with mixing maturin with tox-conda, raising:
; Both VIRTUAL_ENV and CONDA_PREFIX are set. Please unset one of them
allowlist_externals = bash
commands_pre = bash -c "unset CONDA_PREFIX; maturin develop"
commands = pytest {posargs}

[testenv:docs]
extras = docs
passenv = TERM
Expand Down
1 change: 1 addition & 0 deletions python/sphinx_rust/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def on_builder_inited(app: Sphinx) -> None:
LOGGER.warning(
f"Error analyzing crate: {e!s}", type="rust", subtype="analyze"
)
return
create_pages(srcdir, result)

@property
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest_plugins = ["sphinx.testing.fixtures"]
42 changes: 42 additions & 0 deletions tests/test_sphinx_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Simple test to build sphinx documentation."""

from __future__ import annotations

from pathlib import Path
from textwrap import dedent

from sphinx.testing.util import SphinxTestApp
from sphinx.util.console import strip_colors


def test_basic(make_app: type[SphinxTestApp], tmp_path: Path) -> None:
"""Basic sphinx build test."""
tmp_path.joinpath("Cargo.toml").write_text(
dedent("""\
[package]
name = "test"
version = "0.1.0"
[lib]
""")
)
tmp_path.joinpath("conf.py").write_text(
dedent("""\
extensions = ['sphinx_rust']
rust_crates = ['.']
""")
)
tmp_path.joinpath("index.rst").write_text(
dedent("""\
Test
====
.. toctree:: api/crates/test/index
""")
)

app = make_app("html", srcdir=tmp_path)
app.build()
assert strip_colors(app.warning.getvalue()) == "" # noqa: PLC1901

assert (
Path(str(app.outdir)).joinpath("api", "crates", "test", "index.html").exists()
)