[tox]
envlist = py

[testenv]
description =
  run tests with pytest (you can pass extra arguments for pytest,
  e.g., "tox -- --update-goldens")
deps =
    pytest ~= 8.2
    pytest-cov
    pytest-randomly
    wcag-contrast-ratio
commands = pytest {posargs}
use_develop = True

[testenv:regexlint]
description =
  lint regular expressions with regexlint
deps =
    git+https://github.com/pygments/regexlint.git@master
commands = regexlint pygments.lexers


[testenv:pylint]
description =
  lint code with pylint
deps =
  pylint
skip_install = True # doesn't need installing Pygments into the venv
commands =
  pylint --rcfile scripts/pylintrc pygments


[testenv:check]
description =
  various checks on the source code, including ruff linting
deps =
  ruff==0.15.2
commands =
  python scripts/check_crlf.py pygments external
  python scripts/detect_missing_analyse_text.py --skip-no-aliases
  ruff check --ignore UP031 .
  python scripts/check_sources.py -i pygments/lexers/_mapping.py \
        -i pygments/styles/_mapping.py \
        -i docs/_build -i pygments/formatters/_mapping.py -i pygments/unistring.py \
        -i tests/support/empty.py
  python scripts/count_token_references.py --minfiles=1 --maxfiles=1 \
                                           --minlines=1 --maxlines=3 --subtoken

[testenv:mapfiles]
description =
  regenerate map files
deps =
commands =
  python scripts/gen_mapfiles.py


[testenv:coverage]
description =
  run tests, and generate a coverage report in htmlcov/
commands =
  pytest --cov --cov-report=html --cov-report=term {posargs}


[testenv:doc]
description =
  compile documentation with Sphinx. You can pass a builder name,
  like "tox -e doc -- latex". You can also add extra options, like
  "SPHINXOPTS='-D latex_paper_size=letter' tox -e doc -- latex".
change_dir = doc
deps =
  sphinx
  wcag-contrast-ratio
commands =
  sphinx-build -b {posargs:html} -n {env:SPHINXOPTS} . _build/{posargs:html}


[testenv:web-doc]
description =
  same as doc, but also build a wheel for the demo page.
change_dir = doc
deps = 
  {[testenv:doc]deps}
  build
setenv =
  # Build the demo page.
  WEBSITE_BUILD = 1
commands =
  python -m build --wheel --outdir _build/wheel {toxinidir}
  sphinx-build -b {posargs:html} {env:SPHINXOPTS} . _build/{posargs:html}
