Page http://docs.pyinvoke.org/en/latest/concepts/configuration.html, the following code example...
from invoke import Collection, ctask as task
@task
def clean(ctx, target=None):
ctx.run("rm -rf {0}".format(target or ctx.sphinx.target))
@task
def build(ctx, target=None):
ctx.run("sphinx-build docs {0}".format(target or ctx.sphinx.target))
ns = Collection(clean, build)
ns.configure({'sphinx': {'target': "docs/_build"}})
... returns: AttributeError: 'Context' object has no attribute 'sphinx'