| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
""" |
| 18 |
Documentation Tasks |
| 19 |
~~~~~~~~~~~~~~~~~~~ |
| 20 |
|
| 21 |
""" |
| 22 |
|
| 23 |
import os as _os |
| 24 |
|
| 25 |
import invoke as _invoke |
| 26 |
|
| 27 |
from .. import _features |
| 28 |
from .._inv import tasks as _tasks |
| 29 |
from . import _sphinx |
| 30 |
|
| 31 |
NAMESPACE = "doc" |
| 32 |
|
| 33 |
|
| 34 |
@_tasks.optional(None, _features.sphinx) |
| 35 |
@_invoke.task() |
| 36 |
def userdoc(ctx): |
| 37 |
"""Create userdocs""" |
| 38 |
if _tasks.exists("compile.compile"): |
| 39 |
_tasks.execute(ctx, "compile.compile") |
| 40 |
|
| 41 |
_sphinx.run( |
| 42 |
ctx, ctx.doc.sphinx.build, ctx.doc.sphinx.source, ctx.doc.userdoc |
| 43 |
) |
| 44 |
|
| 45 |
|
| 46 |
@_tasks.optional(None, _features.sphinx) |
| 47 |
@_invoke.task(userdoc, default=True) |
| 48 |
def doc(ctx): |
| 49 |
"""Create docs""" |
| 50 |
|
| 51 |
|
| 52 |
@_tasks.optional(None, _features.sphinx) |
| 53 |
@_invoke.task() |
| 54 |
def website(ctx): |
| 55 |
"""Create website""" |
| 56 |
ctx.shell.rm_rf(ctx.doc.website.source) |
| 57 |
ctx.shell.cp_r( |
| 58 |
ctx.doc.sphinx.source, _os.path.join(ctx.doc.website.source, "src") |
| 59 |
) |
| 60 |
ctx.shell.rm_rf(ctx.doc.website.target) |
| 61 |
ctx.shell.mkdir_p(ctx.doc.website.target) |
| 62 |
|
| 63 |
dlfile = _os.path.join( |
| 64 |
ctx.doc.website.source, "src", "website_download.txt" |
| 65 |
) |
| 66 |
with open(dlfile, "rb") as fp: |
| 67 |
download = fp.read().decode("latin-1") |
| 68 |
|
| 69 |
ixfile = _os.path.join(ctx.doc.website.source, "src", "index.txt") |
| 70 |
with open(ixfile, "rb") as fp: |
| 71 |
index = fp.read().decode("latin-1").splitlines(True) |
| 72 |
|
| 73 |
with open(ixfile, "wb") as fp: |
| 74 |
for line in index: |
| 75 |
if line.startswith(".. placeholder: Download"): |
| 76 |
line = download |
| 77 |
fp.write(line.encode("latin-1")) |
| 78 |
|
| 79 |
_sphinx.run( |
| 80 |
ctx, |
| 81 |
ctx.shell.native(_os.path.join(ctx.doc.website.source, "build")), |
| 82 |
ctx.shell.native(_os.path.join(ctx.doc.website.source, "src")), |
| 83 |
ctx.shell.native(ctx.doc.website.target), |
| 84 |
) |
| 85 |
ctx.shell.rm(_os.path.join(ctx.doc.website.target, ".buildinfo")) |