/usr/lib/python3/dist-packages/invocations/docs.py is in python3-invocations 0.6.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import os
from invoke import ctask as task, Collection
# Underscored func name to avoid shadowing kwargs in build()
@task(name='clean')
def _clean(ctx):
ctx.run("rm -rf {0}".format(ctx['sphinx.target']))
# Ditto
@task(name='browse')
def _browse(ctx):
index = os.path.join(ctx['sphinx.target'], ctx['sphinx.target_file'])
ctx.run("open {0}".format(index))
@task(default=True, help={'opts': "Extra sphinx-build options/args"})
def build(ctx, clean=False, browse=False, opts=None):
if clean:
_clean(ctx)
cmd = "sphinx-build{2} {0} {1}".format(
ctx['sphinx.source'],
ctx['sphinx.target'],
(" " + opts) if opts else "",
)
ctx.run(cmd, pty=True)
if browse:
_browse(ctx)
@task
def tree(ctx):
ignore = ".git|*.pyc|*.swp|dist|*.egg-info|_static|_build|_templates"
ctx.run("tree -Ca -I \"{0}\" {1}".format(ignore, ctx['sphinx.source']))
ns = Collection(_clean, _browse, build, tree)
ns.configure({
'sphinx.source': 'docs',
# TODO: allow lazy eval so one attr can refer to another?
'sphinx.target': os.path.join('docs', '_build'),
'sphinx.target_file': 'index.html',
})
|