7 Star 14 Fork 7

Gitee 极速下载/Graphviz

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/xflr6/graphviz
克隆/下载
build-docs.py 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
Sebastian Bank 提交于 2021-12-02 01:21 +08:00 . increase verbosity
#!/usr/bin/env python3
# flake8: noqa
"""Build the docs with https://www.sphinx-doc.org."""
import functools
import pathlib
import sys
import webbrowser
from sphinx.cmd import build
SELF = pathlib.Path(__file__)
SOURCE = pathlib.Path('docs')
TARGET = SOURCE / '_build'
RESULT = TARGET / 'index.html'
BROWSER_OPEN = '--open'
SKIP_OPEN_RESULT = '--no-open'
DEFAULT_ARGS = [BROWSER_OPEN, '-W', '-n', '-v', str(SOURCE), str(TARGET)]
OPEN_RESULT = BROWSER_OPEN in DEFAULT_ARGS
print = functools.partial(print, sep='\n')
args = sys.argv[1:]
print(f'run {[SELF.name] + args}')
if not args:
args = DEFAULT_ARGS
if SKIP_OPEN_RESULT in args:
open_result = None
args = [a for a in args
for name, value in [a.partition('=')[::2]]
if name not in (SKIP_OPEN_RESULT, BROWSER_OPEN)]
elif any(a.partition('=')[0] == BROWSER_OPEN for a in args):
open_result = RESULT
values = {value for a in args
for name, value in [a.partition('=')[::2]]
if name == BROWSER_OPEN and value}
if values:
if len(values) != 1:
raise ValueError(f'conflicting {BROWSER_OPEN}: {values}')
value, = values
if value:
open_result = open_result.parent / value
args = [a for a in args if a.partition('=')[0] != BROWSER_OPEN]
if not args: # no pytest args given
args = [a for a in DEFAULT_ARGS
if a != SKIP_OPEN_RESULT and a.partition('=')[0] != BROWSER_OPEN]
if args == ['-b', 'doctest']:
args += ['-W', str(SOURCE), str(SOURCE / '_doctest')]
print('', f'sphinx.cmd.build.main({args})',)
returncode = build.main(args)
status = 'FAILED' if returncode else 'PASSED'
print('', f'{status} (returncode {returncode!r})', end='')
try:
if 'doctest' not in args:
print('', f'index: {RESULT}', f'assert {RESULT!r}.stat().st_size', end='')
assert open_result.stat().st_size, f'non-empty {open_result}'
if open_result:
print('', f'webbrowser.open({open_result!r})', end='')
webbrowser.open(open_result)
finally:
sys.exit(returncode)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/mirrors/Graphviz.git
git@gitee.com:mirrors/Graphviz.git
mirrors
Graphviz
Graphviz
master

搜索帮助