[tox]
minversion = 3.1
envlist = py39,pep8
skipsdist = True
ignore_basepython_conflict = True

[testenv]
usedevelop = True
install_command = pip install {opts} {packages}
deps =
  -r{toxinidir}/requirements.txt
commands = stestr run {posargs}
  stestr slowest

[testenv:pep8]
commands =
  doc8 doc/source README.rst

[testenv:venv]
deps =
  -r{toxinidir}/requirements.txt
commands = {posargs}

[testenv:docs]
commands =
  {[testenv:api-ref]commands}
  {[testenv:umn]commands}

[testenv:docs-pdf]
whitelist_externals =
  mkdir
commands =
  mkdir -p doc/build/pdf
  {[testenv:api-ref-pdf-docs]commands}
  {[testenv:umn-pdf-docs]commands}


[testenv:api-ref]
whitelist_externals =
  cp
  mkdir
commands =
  sphinx-build -W --keep-going -b html api-ref/source doc/build/html/api-ref
  mkdir -p api-ref/build/html
  cp -av doc/build/html/api-ref api-ref/build/html

[testenv:api-ref-pdf-docs]
whitelist_externals =
  rm
  mkdir
  make
  bash
  cp
commands =
  rm -rf api-ref/build/pdf
  sphinx-build -W --keep-going -b latex api-ref/source api-ref/build/pdf/
  bash -c "for f in api-ref/build/pdf/*.gif; do convert $f $\{f/%gif/png\}; done || true"
  bash -c "for f in api-ref/build/pdf/*.tex; do sed -iorig 's/\.gif//g' $f; done"
  make -C api-ref/build/pdf
  mkdir -p doc/build/pdf
  cp api-ref/build/pdf/dcs-api-ref.pdf doc/build/pdf/


[testenv:umn]
whitelist_externals =
  cp
  mkdir
commands =
  sphinx-build -W --keep-going -b html umn/source doc/build/html/umn
  mkdir -p umn/build/html
  cp -av doc/build/html/umn umn/build/html

[testenv:umn-pdf-docs]
whitelist_externals =
  rm
  mkdir
  make
  bash
  cp
commands =
  rm -rf umn/build/pdf
  sphinx-build -W --keep-going -b latex umn/source umn/build/pdf/
  bash -c "for f in umn/build/pdf/*.gif; do convert $f $\{f/%gif/png\}; done || true"
  bash -c "for f in umn/build/pdf/*.tex; do sed -iorig 's/\.gif//g' $f; done"
  make -C umn/build/pdf
  mkdir -p doc/build/pdf
  cp umn/build/pdf/dcs-umn.pdf doc/build/pdf/

