https://github.com/xflr6/graphviz
Tip revision: 01b22690912bfe43c4c21665e5a257990c084e8d authored by Sebastian Bank on 15 November 2021, 18:22:14 UTC
release 0.18.2
release 0.18.2
Tip revision: 01b2269
build-docs.py
#!/usr/bin/env python3
# flake8: noqa
"""Build the docs with https://www.sphinx-doc.org."""
import contextlib
import os
import pathlib
import sys
import webbrowser
from sphinx.cmd import build
SOURCE = pathlib.Path('docs')
TARGET = pathlib.Path('_build')
RESULT = SOURCE / TARGET / 'index.html'
DEFAULT_ARGS = ['-n', '-v', '.', str(TARGET)]
@contextlib.contextmanager
def chdir(path):
cwd_before = os.getcwd()
print(f'os.chdir({path})')
os.chdir(path)
try:
yield path
finally:
print(f'os.chdir({cwd_before}')
os.chdir(cwd_before)
args = sys.argv[1:]
if not args:
args = DEFAULT_ARGS
with chdir(SOURCE):
print(f'sphinx.cmd.build.main({args})')
result = build.main(args)
print('', RESULT, sep='\n')
try:
assert RESULT.stat().st_size, f'non-empty {RESULT}'
webbrowser.open(RESULT)
finally:
sys.exit(result)