Module tf.tools.pdocs

Functions

def console(*args)
Expand source code Browse git
def console(*args):
    sys.stderr.write(" ".join(args) + "\n")
    sys.stderr.flush()
def getCommand(pkg, asString=False)
Expand source code Browse git
def getCommand(pkg, asString=False):
    templateLoc = TEMPLATE_LOC.format(pkg)

    pdoc3 = [
        "pdoc3",
        "--force",
        "--html",
        "--output-dir",
        SITE,
        "--template-dir",
        templateLoc,
    ]
    return " ".join(pdoc3) if asString else pdoc3
def pdoc3(pkg)
Expand source code Browse git
def pdoc3(pkg):
    """Build the docs into site."""

    console("Build docs")
    if os.path.exists(SITE):
        console(f"Remove previous build ({SITE})")
        rmtree(SITE)
    console("Generate docs with pdoc3")
    run(f"{getCommand(pkg, asString=True)} {pkg}", shell=True)
    # console("Move docs into place")
    # run(f"mv {SITE}/{pkg}/* {SITE}", shell=True)
    # rmtree(f"{SITE}/{pkg}")
    console("Copy over the images")
    copytree(f"{pkg}/docs/images", f"{SITE}/{pkg}/images", dirs_exist_ok=True)
    console("Copy over the stats")
    copytree(f"{pkg}/docs/stats", f"{SITE}/{pkg}/stats", dirs_exist_ok=True)

    # a link from the old docs URL to the new one
    copyfile(f"{pkg}/docs/index.html", f"{SITE}/index.html")

Build the docs into site.

def pdoc3serve(pkg)
Expand source code Browse git
def pdoc3serve(pkg):
    """Build the docs into site and serve them."""

    proc = Popen([*getCommand(pkg), "--http", ":", pkg])
    time.sleep(1)
    run(f"open http://localhost:8080/{pkg}", shell=True)
    try:
        proc.wait()
    except KeyboardInterrupt:
        pass
    proc.terminate()

Build the docs into site and serve them.

def servePdocs(pkg)
Expand source code Browse git
def servePdocs(pkg):
    run("python -m http.server 9000", cwd=SITE, shell=True)
def shipDocs(org, repo, pkg, pdoc=True)
Expand source code Browse git
def shipDocs(org, repo, pkg, pdoc=True):
    """Build the docs into site and ship them."""

    if pdoc:
        pdoc3(pkg)
    _gh_deploy(org, repo, pkg)

Build the docs into site and ship them.