[tox]

envlist =
  # Envs to build
  {win,lin,mac}-{py36,py37,py38}-{pyqt5,pyside2,pyqt4,pyside}-{build,test}
  # Envs for metrics and development
  {win,lin,mac}-{py38}-{lint,safety,metric,develop,doc,release}
  # Docs with screenshots
  {win,lin,mac}-{py38}-{pyqt5,pyside2}-{doc}

skip_missing_interpreters =
  true

[testenv]

platform =
  # platforms to run
  win: windows
  lin: linux
  mac: osx

deps =
  build: -rreq-stable.txt
  test: -rreq-test.txt
  lint: -rreq-test.txt
  safety: -rreq-test.txt
  metric: -rreq-test.txt
  develop: -rreq-develop.txt
  doc: -rreq-doc.txt
  release: -rreq-release.txt

  # basic dependencies for each env
  pyqt: pyqt4
  pyqt5: pyqt5
  pyside: pyside
  pyside2: pyside2

whitelist_externals =
  # non python dependencies
  qmake
  doc: make
  doc: latexpdf

changedir=
  doc: docs

commands =

  # check depedencies
  pip check
  # list all deps
  pip list

  # BUILD ------------------------------------------------------------------

  # try generate build
  build: python setup.py sdist bdist_wheel
  # try install with pip
  build: pip install .
  # get some info
  build: python -m qdarkstyle --all

  # need to run the interface to certify the build, run example
  pyqt-build: python example/example.py --qt_from=pyqt --test
  pyqt-build: python example/example.py --qt_from=pyqt --test --no_dark

  pyqt5-build: python example/example.py --qt_from=pyqt5 --test
  pyqt5-build: python example/example.py --qt_from=pyqt5 --test --no_dark

  pyside-build: python example/example.py --qt_from=pyside --test
  pyside-build: python example/example.py --qt_from=pyside --test --no_dark

  pyside2-build: python example/example.py --qt_from=pyside2 --test
  pyside2-build: python example/example.py --qt_from=pyside2 --test --no_dark

  # TEST -------------------------------------------------------------------

  # Those commands commented below correct style problems
  # DO NOT RUN ON SERVER, it is just to keep registry for local use
  # autopep8 --ignore=E501 --aggressive --aggressive --aggressive --experimental
  # docformatter -r -i --wrap-summaries=0 --wrap-descriptions=0 *.py
  # eradicate

  # Test and coverage
  # test: pytest --cov "./tests"
  test: pytest --cov

  # Code and docstring style check, running alone for now - pylama-#156
  # test: pylama -v --options="tox.ini" "{toxinidir}"

  # Code linting
  lint: pycodestyle --config="tox.ini" "."
  # lint: pyflakes "./qdarkstyle"
  # lint: mypy --config-file="tox.ini" "qdarkstyle"

  # Code and doc linting
  lint: pylint -r y --rcfile="pylint.ini" "./qdarkstyle" --disable="R1260,R0912"

  # Doc linting
  lint: pydocstyle --config="tox.ini" "."
  lint: doc8 --ignore="D002,D004" --config="tox.ini" "."

  # Safety
  safety: safety check
  safety: bandit --recursive qdarkstyle

  # Code metrics
  metric: radon cc -a qdarkstyle --exclude="*/ui/*"
  metric: radon mi qdarkstyle --exclude="*/ui/*"
  metric: radon raw -s qdarkstyle --exclude="*/ui/*"
  metric: radon hal -f qdarkstyle --exclude="*/ui/*"

  # DOC (inside docs folder) ----------------------------------------------

  # Documentation - generate apidocs, build html, build latex, build pdf
  doc: sphinx-apidoc --private --separate --force --module-first -o "example" "{toxworkdir}/../example" "{toxworkdir}/../example/ui/*"
  doc: sphinx-apidoc --private --separate --force --module-first -o "reference" "{toxworkdir}/../qdarkstyle"
  doc: sphinx-apidoc --private --separate --force --module-first -o "scripts" "{toxworkdir}/../scripts"

  doc: python "{toxworkdir}/../example/example.py" --screenshot
  doc: python "{toxworkdir}/../example/example.py" --screenshot --no_dark

  doc: sphinx-build -b html -j auto -E -d "{toxworkdir}/../build/docs/doctrees" . "{toxworkdir}/../build/docs/html"

  # RELEASE -------------------------------------------------------------------------------
  # Try to use re-ver package
  release: python setup.py clean --all
  release: python setup.py sdist bdist_wheel
  release: python setup.py check -s -r # even deprecated, shows better error messages that are passing in twine
  release: twine check dist/*
  # try upload in test platform before the oficial
  # release: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
  # release: pip install --index-url https://test.pypi.org/simple/ qdarkstyle
  # upload to oficial
  # release: twine upload dist/*
  # release: pip uninstall qdarkstyle
  # release: pip install qdarkstyle


usedevelop =
  develop: true


# PYCODESTYLE ################################################################

[pycodestyle]

ignore = E501,C0301,W503,W504 # Issue: in travis shows W504, local W503 the same line
max-line-length = 150
statistics = True
count = True
exclude =
    .tox,.env,.venv,build,dist,tests,examples,ui,*.egg-info*,*cache*,.coverage,
    */.tox/*,*/.env/*,*/.venv/*,*/build/*,*/dist/*,*/tests/*,*/ui/*,*/*.egg*,
    */.*,*/.coverage,*/./venv/*,./venv,*/docs/*,docs,venv,
    style_rc.py,mw_for_ui_tests.py,test.py

# PYDOCSTYLE #################################################################

[pydocstyle]

ignore = D107,D200,D202,D203,D212,D213,D406,D407,D413
match-dir = "[^\.].*,!(docs),!(venv)"
match = "!style_rc.py"

# DOC8 #######################################################################

[doc8]

extension = .rst
ignore = D002,D004 # problems in Windows fyle system, issue. Also, it just works with the first ignored code
max-line-length = 150
file-encoding = "utf-8"
ignore-path =
    .tox,.env,.venv,build,dist,tests,examples,ui,*.egg-info*,*cache*,.coverage,
    */.tox/*,*/.env/*,*/.venv/*,*/build/*,*/dist/*,*/tests/*,*/ui/*,*/*.egg*,
    */.*,*/.coverage,*/./venv/*,./venv

# PYLAMA #####################################################################

[pylama]

format = pylint
linters = pyflakes
skip =
    .tox,.env,.venv,build,dist,tests,examples,ui,*.egg-info*,*cache*,.coverage,
    */.tox/*,*/.env/*,*/.venv/*,*/build/*,*/dist/*,*/tests/*,*/ui/*,*/*.egg*,
    */.*,*/.coverage,*/./venv/*,./venv,venv

# MYPY #######################################################################

[mypy]
# general configuration

[mypy-numpy]
ignore_missing_imports = True

[mypy-qtpy]
ignore_missing_imports = True

[mypy-scipy]
ignore_missing_imports = True

[mypy-pint]
ignore_missing_imports = True

[mypy-pyqtgraph]
ignore_missing_imports = True

[mypy-spyder]
ignore_missing_imports = True

[mypy-networkx]
ignore_missing_imports = True

[mypy-qdarkstyle]
ignore_missing_imports = True

[mypy-jsonpickle]
ignore_missing_imports = True