-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-doc.py
executable file
·37 lines (26 loc) · 989 Bytes
/
build-doc.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
#!/usr/bin/env python3
import os
from os.path import realpath, dirname
ROOT_DIR = realpath(dirname(__file__))
CODE_DIR = os.path.join(ROOT_DIR, "pyobfusinator")
def main():
print("Start building doc")
py_code = ""
files = ["exception.py", "inflate.py", "compress.py"]
for file in files:
print(f"Combining code from {file}")
with open(os.path.join(CODE_DIR, file)) as f:
py_code += f.read()
print("Replacing text")
py_code = py_code.replace("from .exception import UnknownCharacterException", "") \
.replace("\\", "\\\\") \
.replace("`", "\\`")
print("Reading HTML")
with open(os.path.join(ROOT_DIR, "docs", "index.template.html")) as f:
html = f.read()
html = html.replace("__PYOBFUSINATOR_CODE_PLACEHOLDER__", py_code)
print("Writing to index.html")
with open(os.path.join(ROOT_DIR, "docs", "index.html"), "w") as f:
f.write(html)
if __name__ == '__main__':
main()