"""
Build tasks for Rookeries.

:copyright: Copyright 2013-2017, Dorian Pula <dorian.pula@amber-penguin-software.ca>
:license: AGPL v3+
"""

import invoke as inv

from . import db, server, test


@inv.task
def build_docs(ctx):
    """Creates the HTML documentation through Sphinx."""
    inv.run('sphinx-apidoc -o docs/_api rookeries', echo=True)
    inv.run('sphinx-build -b html docs docs/_build', echo=True)


@inv.task
def clean_pyc(ctx):
    inv.run('find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf')


ns = inv.Collection()
ns.add_collection(db)
ns.add_collection(server)
ns.add_collection(test)
ns.add_task(build_docs)
ns.add_task(clean_pyc)
