-
-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathconf.py
99 lines (78 loc) · 2.65 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
import os
import pathlib
import re
EXTERNAL_PREFIXES = (
"oxidized_importer",
"pyembed",
"pyoxidizer",
"pyoxy",
"tugger",
)
EXTERNAL_SOURCE_DIRS = (
pathlib.Path("pyembed") / "docs",
pathlib.Path("pyoxidizer") / "docs",
pathlib.Path("pyoxy") / "docs",
pathlib.Path("python-oxidized-importer") / "docs",
pathlib.Path("tugger") / "docs",
)
HERE = pathlib.Path(os.path.dirname(__file__))
ROOT = pathlib.Path(os.path.dirname(HERE))
release = "unknown"
with (ROOT / "pyoxidizer" / "Cargo.toml").open("r") as fh:
for line in fh:
m = re.match('^version = "([^"]+)"', line)
if m:
release = m.group(1)
break
project = "PyOxidizer"
copyright = "2019-present, Gregory Szorc"
author = "Gregory Szorc"
extensions = ["sphinx.ext.intersphinx"]
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
html_theme = "alabaster"
master_doc = "index"
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"setuptools": ("https://setuptools.pypa.io/en/latest", None),
}
tags.add("global")
# Synchronize external docs into this directory.
# Start by collecting the set of external docs and their content.
# We'll use this to compute a minimal mutation so incremental Sphinx
# rebuilds are faster.
wanted_external_files = {}
for d in EXTERNAL_SOURCE_DIRS:
source_dir = ROOT / d
for f in os.listdir(source_dir):
if not f.endswith(("rst", "png")) or not f.startswith(EXTERNAL_PREFIXES):
continue
source_path = source_dir / f
dest_path = HERE / f
with source_path.open("rb") as fh:
source_data = fh.read()
wanted_external_files[dest_path] = source_data
for f in sorted(os.listdir(HERE)):
path = HERE / f
if not f.startswith(EXTERNAL_PREFIXES):
continue
if path in wanted_external_files:
with path.open("rb") as fh:
current_data = fh.read()
if current_data == wanted_external_files[path]:
print("%s is up to date" % path)
else:
print("updating %s" % path)
with path.open("wb") as fh:
fh.write(wanted_external_files[path])
del wanted_external_files[path]
else:
print("deleting %s since it disappeared" % path)
path.unlink()
for path, data in sorted(wanted_external_files.items()):
print("creating %s" % path)
with path.open("wb") as fh:
fh.write(data)