-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_examples.py
32 lines (30 loc) · 1.03 KB
/
run_examples.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
import subprocess
import os
import sys
srcdir = os.path.join(os.path.dirname(__file__), "examples")
builddir = os.path.join(sys.argv[1], "examples")
with open(os.path.join(sys.argv[1], "examples.dox"), "w", encoding="utf-8") as f:
for name in sorted(list(os.listdir(srcdir))):
if name.endswith(".cc"):
print(name)
stderr_lines = subprocess.run(
[os.path.join(builddir, "y3c-example-" + name[:-3])],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
check=False,
).stdout.split("\n")
f.write(
"\n".join(
[
"/*!",
f"\\example {name}",
"> example output:",
"> ```",
*["> " + ln for ln in stderr_lines],
"> ```",
"*/",
"",
]
)
)