# To use tox, see https://tox.readthedocs.io
# Simply pip or conda install tox
# If you use conda, you may also want to install tox-conda
# then run `tox` or `tox -- {pytest args}`
# To run in parallel using `tox -p` (this does not appear to work for this repo)

# To rebuild the tox environment, for example when dependencies change, use
# `tox -r`

# Note: if the following error is encountered: `ImportError while loading conftest`
# then then deleting compiled files has been found to fix it: `find . -name \*.pyc -delete`

[tox]
envlist = py311-sphinx9

[testenv]
usedevelop = true

[testenv:py{311,312,313,314}-sphinx{8,9}]
deps =
    sphinx8: sphinx>=8,<9
    sphinx9: sphinx>=9,<10
extras =
    linkify
    testing
commands = pytest {posargs}

[testenv:docs-{update,clean}]
extras =
    linkify
    rtd
allowlist_externals =
    rm
passenv =
    BUILDER
    TERM
commands =
    clean: rm -rf docs/_build/{env:BUILDER:html}
    sphinx-build -nW --keep-going -b {env:BUILDER:html} docs/ docs/_build/{env:BUILDER:html} {posargs:-P}

[testenv:docs-live]
description = Build the documentation and launch browser
deps = sphinx-autobuild
extras =
    linkify
    rtd
commands =
    sphinx-autobuild \
        --re-ignore _build/.* \
        --port 0 --open-browser \
        -n -b {posargs:html} docs/ docs/_build/{posargs:html}

[testenv:ruff-check]
dependency_groups = ruff
commands = ruff check {posargs:--fix}

[testenv:ruff-fmt]
dependency_groups = ruff
commands = ruff format {posargs}

[testenv:mypy]
dependency_groups = mypy
commands = mypy {posargs:myst_parser}
