Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit a06a62a

Browse files
committed
Added tool for autoupdating wiki
1 parent 2b25485 commit a06a62a

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Diff for: update-wiki.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python2
2+
import sys, os, subprocess
3+
4+
def try_run(cmd):
5+
if os.system(cmd) != 0:
6+
sys.exit(1)
7+
8+
9+
def merge(f1, f2, from_, to):
10+
"""
11+
Merges lines from line containting 'from_' to line containing 'to'
12+
from f1 to f2
13+
"""
14+
lines1, inside = [], False
15+
for line in open(f1, "r").readlines():
16+
if from_ in line.strip("\r\n\t "):
17+
inside = True
18+
elif to in line.strip("\r\n\t "):
19+
inside = False
20+
if inside:
21+
lines1.append(line)
22+
23+
lines2, inside = [], False
24+
for line in open(f2, "r").readlines():
25+
if from_ in line.strip("\r\n\t "):
26+
inside = True
27+
lines2 += lines1
28+
elif to in line.strip("\r\n\t "):
29+
inside = False
30+
elif not inside:
31+
lines2.append(line)
32+
33+
open(f2, "w").write("".join(lines2))
34+
35+
36+
def main():
37+
38+
if not os.path.exists("sc-controller.wiki/.git"):
39+
try_run("git clone 'https://github.com/kozec/sc-controller.wiki.git'")
40+
41+
os.chdir("sc-controller.wiki")
42+
try_run("git pull")
43+
try_run("git reset master")
44+
45+
merge(
46+
'../docs/actions.md',
47+
'Custom-Action-Examples-and-Explanations.md',
48+
'# <a name="actions">',
49+
'# <a name="examples2">'
50+
)
51+
52+
try_run("git commit -a -m \"Updated wiki from docs\"")
53+
54+
55+
if __name__ == "__main__":
56+
main()

0 commit comments

Comments
 (0)