forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_full_index.py
71 lines (56 loc) · 1.58 KB
/
build_full_index.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
# generates docs/html/full_index.html
# (C) 2003-2009 Markus Neteler and the GRASS Development Team
# Authors:
# Markus Neteler
# Glynn Clements
import sys
import os
from build_html import *
year = None
if len(sys.argv) > 1:
year = sys.argv[1]
os.chdir(html_dir)
# TODO: create some master function/dict somewhere
class_labels = {
"d": "display",
"db": "database",
"g": "general",
"i": "imagery",
"m": "miscellaneous",
"ps": "PostScript",
"r": "raster",
"r3": "3D raster",
"t": "temporal",
"v": "vector",
}
classes = []
for cmd in html_files("*"):
prefix = cmd.split(".")[0]
if prefix not in [item[0] for item in classes]:
classes.append((prefix, class_labels.get(prefix, prefix)))
classes.sort(key=lambda tup: tup[0])
# begin full index:
filename = "full_index.html"
f = open(filename + ".tmp", "w")
write_html_header(
f, "GRASS GIS %s Reference Manual: Full index" % grass_version, body_width="80%"
)
# generate main index of all modules:
f.write(full_index_header)
f.write(toc)
# for all module groups:
for cls, cls_label in classes:
f.write(cmd2_tmpl.substitute(cmd_label=to_title(cls_label), cmd=cls))
# for all modules:
for cmd in html_files(cls):
basename = os.path.splitext(cmd)[0]
desc = check_for_desc_override(basename)
if desc is None:
desc = get_desc(cmd)
f.write(desc1_tmpl.substitute(cmd=cmd, basename=basename, desc=desc))
f.write("</table>\n")
write_html_footer(f, "index.html", year)
f.close()
replace_file(filename)
# done full index