-
Notifications
You must be signed in to change notification settings - Fork 3
/
guides-nav.py
49 lines (38 loc) · 831 Bytes
/
guides-nav.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
'''
Generate Guide
'''
import glob
files = glob.glob("content/guides/*")
nav = {}
for file in files:
f = open(file, "r")
s = f.read()
f.close()
fname = file.split("/")[-1].split(".")
fname[-1] = "txt"
fname = ".".join(fname)
for line in s.split("\n"):
if line[0] == "#":
title = line[1:].strip()
break
print "> %s = %s" % (fname, title)
nav[fname] = title
file = '''
<div class="nav-section-header"><a href="#">
<span class="en" style="display: inline; ">Android Additions</span>
</a></div>
<ul style="display: block; ">
'''
for (fname, title) in nav.items():
file += '''
<li><a href="%s">
<span class="en" style="display: inline; ">%s</span></a>
</li>
''' % (fname, title)
file += '''
</ul>
'''
f = open("bin/content/guides/nav.html", "w")
f.write(file)
f.close()
print "OK"