from __future__ import absolute_import

from fabric.api import task, local
from fabric.context_managers import lcd


@task
def sphinx():
    """Generate documentation."""

    local("rm -rf docs/build/html")

    with lcd('docs'):
        local('sphinx-build -a -b html -d build/doctrees   source build/html')


@task
def clean():
    """Remove .pyc files."""
    # Ignore hidden files and folder
    local("find . \( ! -regex '.*/\..*/..*' \) -type f -name '*.pyc' -exec rm '{}' +")
