[tox]
envlist = docs, flake8, isort

[testenv:docs]
skip_install = true
deps =
  -r {toxinidir}/docs/requirements.txt
  -r {toxinidir}/requirements.txt

commands = 
  ; regenerate autodoc stub pages
  sphinx-autogen docs/source/api.rst
  ; build api docs 
  sphinx-build -b html -d ../build/docs/doctrees docs/source ../build/docs/api/py {posargs}
setenv =
  PYTHONPATH = {toxinidir}/.

[testenv:mypy]
skip_install = true
deps =
  mypy==1.4.1
  lxml==4.9.1
  types-urllib3==1.26.25
  types-certifi==2021.10.8.3
  trio-typing==0.7.0
commands = mypy --install-types {posargs}

[testenv:linting-ci]
; checks linting for CI with stricter exiting when failing.
skip_install = true
deps =
  isort==5.13.2
  black==24.1.1
  flake8==6.1.0
  flake8-typing-imports==1.14.0
  docformatter==1.7.5
commands =
  ; execute isort in check only mode.
  isort --check-only --diff selenium/ test/ conftest.py
  ; execute black in check only mode with diff.
  black --check --diff selenium/ test/ conftest.py -l 120
  flake8 selenium/ test/ --min-python-version=3.8
  docformatter --check -r selenium/

[testenv:linting]
; A consolidated linting based recipe, responsible for executing linting tools across the code base.
; This encompasses isort for imports, black for general formatting and flake8.
; IMPORTANT: black & isort rewrite files, flake8 merely alerts to the failure.
skip_install = true
deps =
  isort==5.13.2
  black==24.1.1
  flake8==6.1.0
  flake8-typing-imports==1.14.0
  docformatter==1.7.5
commands =
  isort selenium/ test/ conftest.py
  black selenium/ test/ conftest.py -l 120
  flake8 selenium/ test/ --min-python-version=3.8
  docformatter --in-place -r selenium/
