Beispiel #1
0
def main():
    doc_path = Path(__file__).absolute().parent.parent / "docs"
    # # clean out all the old docs
    clean_docs()

    cmd = "jupyter nbconvert --ExecutePreprocessor.timeout=1200 --to notebook --execute --inplace "
    for note_book_path in doc_path.rglob("*.ipynb"):
        # skip any hidden directores, eg .ipynb_checkpoints
        if note_book_path.parent.name.startswith('.'):
            continue
        cmd_to_run = cmd + str(note_book_path)
        result = os.system(cmd_to_run)
        if result != 0:
            raise RuntimeError("failed to run: " + cmd_to_run)
    # run auto api-doc

    with change_directory(doc_path):
        api_doc_command = " sphinx-apidoc ../obsplus -o api"
        result = os.system(api_doc_command)
        if result != 0:
            print('failed to run: ' + api_doc_command)
        # make the rest of the docs
        doc_cmd = 'make html'
        result = os.system(doc_cmd)
        if result != 0:
            print('failed to run: ' + doc_cmd)
Beispiel #2
0
def make_docs(doc_path=DOC_PATH, timeout=3000) -> str:
    """
    Make the obsplus documentation.

    Parameters
    ----------
    doc_path
        The path to the top-level sphinx directory.
    timeout
        Time in seconds allowed for notebook to build.

    Returns
    -------
    Path to created html directory.

    """
    # clean out all the old docs
    clean_docs()
    # execute all the notebooks
    cmd = (f"jupyter nbconvert --to notebook --execute --inplace "
           f"--ExecutePreprocessor.timeout={timeout}")
    for note_book_path in doc_path.rglob("*.ipynb"):
        # skip all ipython notebooks
        if "ipynb_checkpoints" in str(note_book_path):
            continue
        result = run(cmd + f" {note_book_path}", shell=True)
        if result.returncode != 0:
            raise RuntimeError(f"failed to run {note_book_path}")
    # run auto api-doc
    run("sphinx-apidoc ../obsplus -e -M -o api", cwd=doc_path, shell=True)
    run("make html", cwd=doc_path, shell=True, check=True)
    # ensure html directory was created, return path to it.
    expected_path: Path = doc_path / "_build" / "html"
    assert expected_path.is_dir(), f"{expected_path} does not exist!"
    return str(expected_path)
Beispiel #3
0
def main():
    doc_path = Path(__file__).absolute().parent.parent / "docs"
    # clean out all the old docs
    clean_docs()
    # execute all the notebooks
    cmd = "jupyter nbconvert --to notebook --execute --inplace"
    for note_book_path in doc_path.rglob("*.ipynb"):
        result = run(cmd + f" {note_book_path}", shell=True)
        if result.returncode != 0:
            raise RuntimeError(f"failed to run {note_book_path}")
    # run auto api-doc
    run(f" sphinx-apidoc ../obsplus -o api", cwd=doc_path, shell=True)
    run(f"make html", cwd=doc_path, shell=True)
Beispiel #4
0
    os.chdir(str(new_path))
    yield
    os.chdir(str(here))


if __name__ == "__main__":
    base = Path(__file__).parent.parent
    tmp = Path(tempfile.mkdtemp())
    html_path = (base / "docs" / "_build" / "html").absolute()
    detex_url = "https://github.com/d-chambers/detex"
    # make the docs
    make_docs()
    assert html_path.exists()
    # clone a copy of obplus to tempfile and cd there
    with change_directory(tmp):
        run("git clone " + detex_url)
    with change_directory(tmp / "detex"):
        # checkout gh-pages
        run("git checkout gh-pages")
        # reset to the first commit in gh-pages branch
        cmd = "git reset --hard `git rev-list --max-parents=0 HEAD | tail -n 1`"
        run(cmd)
        # copy all contents of html
        run("cp -R {}/* ./".format(html_path))
        # make a commit
        run("git add -A")
        run('git commit -m "{} docs"'.format(version))
        run("git push -f origin gh-pages")
    # clean up original repo
    clean_docs()