[tox]
envlist = py{27,34,35,36,37}, pypy, pypy3, coverage, docs
minversion = 2.5.0

[base]
packagesubdir = jt/javabridge

[testenv]
commands =
    {envpython} -B -m tests {posargs}
extras = test
deps =
    {toxinidir}/../jtypes.jni
    {toxinidir}/../jtypes.jvm

[testenv:prepare]
basepython = python3.6
skip_install = true
whitelist_externals =
    .build
commands =
    .build

[testenv:py]
commands =
    {envpython} --version
    {[testenv]commands}

[testenv:coverage]
basepython = python3.6
commands =
    {envpython} -m coverage erase
    -{envpython} -B -m coverage run -m tests {posargs}
    {envpython} -m coverage report
    {envpython} -m coverage html
deps =
    {[testenv]deps}
    coverage>=4.4.2

[testenv:docs]
basepython = python3.6
commands =
   #{envpython} -m sphinx.apidoc -f -e -M -o {toxinidir}/docs/api {envsitepackagesdir}/{[base]packagesubdir}
    {envpython} setup.py -v build_sphinx -E # {distdir}/html
   #{envpython} -c "import sys;sys.path.remove('');import shutil;shutil.rmtree('{distdir}/html',ignore_errors=True)"
   #{envpython} -c "import sys;sys.path.remove('');import shutil;shutil.move('{toxinidir}/docs/_build/html','{distdir}/html')"
   #{envpython} -c "import sys;sys.path.remove('');import shutil;shutil.rmtree('{distdir}/html/_sources',ignore_errors=True)"
   #{envpython} setup.py -v build_sphinx -b linkcheck # {distdir}/linkcheck
   #{envpython} setup.py -v build_sphinx -b doctest   # {envtmpdir}/doctest
extras = doc

[testenv:pep8]
basepython = python3.6
skip_install = true
commands =
    {envpython} -m flake8 {envsitepackagesdir}/{[base]packagesubdir}/ setup.py
deps =
    flake8
    flake8-docstrings>=0.2.7
    pep8-naming
    flake8-builtins

[coverage:run]
source =
    jt.javabridge
    tests
data_file = .tox/coverage/.coverage

[coverage:report]
exclude_lines =
    # Regexes
    # Have to re-enable the standard pragma
    pragma: no cover
    raise (AssertionError|NotImplementedError)
    if\s+(0|False)\s*:
    if\s+__name__.*\s*==\s*['"]__main__['"]\s*:
    \s+@unittest\.skip\(
    if platform\.is_osx:
    def mac_.+\(
    def create_mac\(self,
omit =
    */jt/javabridge/_platform/__init__.py
    */jt/javabridge/_java/class2py.py
    tests/run.py
skip_covered = True

[coverage:html]
directory = .tox/coverage/.coverage.html

[flake8]
filename = *.py,*.pyx
#include = tests
#exclude = .tox,*.egg,.git,_build,.hypothesis
max-line-length = 99
ignore = E126,E203,E221,E251,E302,E701,E702,E731,
         E122,E127,E128,E222,E272,E241,E266, E226,E704,
         D100, D101, D102, D103, D104, D400,
         N806, N802, N803,
         I100
# (e.g. E4,W) default: E121,E123, 126, 226,E24, 704
#select = 
#select = E,W,F,N,I
output-file = .tox/pep8/flake8out.txt
count = True
#show-pep8,
#show-source
#verbose
#quiet
