[build-system]
requires = [ "setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/hdx/utilities/_version.py"
local_scheme = "no-local-version"
version_scheme = "python-simplified-semver"

[tool.black]
line-length = 79

[tool.isort]
profile = "black"
line_length = 79
multi_line_output = 3

[tool.flakeheaven]
# make output nice
format = "grouped"
max_line_length = 79
# show line of source code in output
show_source = true
exclude = ["_version.py"]

    # list of plugins and rules for them
    [tool.flakeheaven.plugins]
    mccabe = ["+*"]
    pycodestyle = ["+*", "-E203", "-E501", "-W503"]
    pyflakes = ["+*"]
    pylint = ["+*"]
    flake8-isort = ["+*"]
    flake8-black = ["+*"]

[tool.pytest.ini_options]
pythonpath = "src"
addopts = "--color=yes"
log_cli = 1

[tool.coverage.paths]
source = ["src/hdx", "*/site-packages/hdx"]

[tool.coverage.report]
omit = [
    "*/setup.py",
    "*/python?.?/*",
    "*/venv/*",
    "*/site-packages/*",
    "*/tests/*",
    "*__init__*"
]

exclude_lines = [
    "pragma: no cover",  # Have to re-enable the standard pragma
    "def __repr__",  # Don't complain about missing
    "if self.debug",  # debug-only code
    "raise AssertionError",  # Don't complain if tests don't hit
    "raise NotImplementedError",  # defensive assertion code
    "if 0:",  # Don't complain if non-runnable code
    "if __name__ == .__main__.:"  # isn't run
]

[[tool.pydoc-markdown.loaders]]
type = "python"
search_path = ["src"]
packages = ["hdx.utilities"]

[tool.pydoc-markdown.renderer]
type = "mkdocs"
output_directory = "docs"

    [tool.pydoc-markdown.renderer.mkdocs_config]
    site_name = "HDX Python Utilities"
    theme = "readthedocs"
    repo_url = "https://github.com/OCHA-DAP/hdx-python-utilities"

    [tool.pydoc-markdown.renderer.markdown.source_linker]
    type = "github"
    repo = "OCHA-DAP/hdx-python-utilities"

    [[tool.pydoc-markdown.renderer.pages]]
    title = "Home"
    name = "index"
    source ="doc/main.md"

    [[tool.pydoc-markdown.renderer.pages]]
    title = "API Documentation"

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Downloading files"
        contents = ["hdx.utilities.downloader.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Retrieving files"
        contents = ["hdx.utilities.retriever.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Loading and saving JSON and YAML"
        contents = ["hdx.utilities.loader.*", "hdx.utilities.saver.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Dictionary and list utilities"
        contents = ["hdx.utilities.dictandlist.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "HTML utilities"
        contents = ["hdx.utilities.html.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Comparing files"
        contents = ["hdx.utilities.compare.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Emailing"
        contents = ["hdx.utilities.email.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Configuring logging"
        contents = ["hdx.utilities.easy_logging.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Path utilities"
        contents = ["hdx.utilities.path.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Date parsing utilities"
        contents = ["hdx.utilities.dateparse.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Text processing"
        contents = ["hdx.utilities.text.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Encoding utilities"
        contents = ["hdx.utilities.encoding.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Valid UUID"
        contents = ["hdx.utilities.uuid.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Wheel utilities"
        contents = ["hdx.utilities.session.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "Retrying Requests session"
        contents = ["hdx.utilities.session.*"]

        [[tool.pydoc-markdown.renderer.pages.children]]
        title = "User Agent"
        contents = ["hdx.utilities.useragent.*"]

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = true
envlist = py310, lint

[gh-actions]
python =
    3: py310, lint

[testenv]
recreate = true
wheel = true
deps =
    -r test-requirements.txt
commands =
    pytest --cov=hdx --no-cov-on-fail --junitxml=.tox/test-results.xml --cov-report=xml --cov-report=term-missing

[testenv:lint]
wheel_build_env = py310
deps =
    flakeheaven
    flake8
    flake8-isort
    flake8-black
commands =
    flakeheaven lint src tests

[testenv:docs]
wheel_build_env = py310
deps =
    pydoc-markdown
commands =
    pydoc-markdown

[testenv:publish]
wheel_build_env = py310
passenv = SSH_AUTH_SOCK TWINE_USERNAME TWINE_PASSWORD
deps =
    twine

commands =
    twine upload {distdir}/*
"""
