-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild2docs.py
30 lines (24 loc) · 947 Bytes
/
build2docs.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
#-*- coding: utf-8 -*-
import os, glob, shutil
from pathlib import Path
def build2docs():
_, git_repo = os.path.split(os.getcwd())
print(git_repo)
if Path("docs").exists():
shutil.rmtree("docs")
html = [file for file in glob.glob("build/**", recursive=True) if file.endswith(".html")]
print(html)
for h in html:
f = open(h, 'rt', encoding='UTF8')
code = f.read()
f.close()
g = open(h, 'w', encoding='UTF8')
code = code.replace("/static", "/{}/static".format(git_repo))
code = code.replace('<a href="/">', '<a href="/{}/">'.format(git_repo))
code = code.replace('<a href="/experiences/">', '<a href="/{}/experiences/">'.format(git_repo))
code = code.replace('<a href="/projects/">', '<a href="/{}/projects/">'.format(git_repo))
g.write(code)
g.close()
shutil.move("build", "docs")
if __name__=="__main__":
build2docs()