-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmakehtml.py
More file actions
executable file
·101 lines (84 loc) · 3.13 KB
/
makehtml.py
File metadata and controls
executable file
·101 lines (84 loc) · 3.13 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
#### writes out HTML files. Uses .flowdbs information and .cmapx information (for hyperlinks).
#### HMTL files point to PNG files with the diagrams
import sys
import os
import glob
import csv
infile_str=os.path.splitext(os.path.basename(sys.argv[1]))[0]
print (infile_str)
htmloffline_str=''
htmloffline_str+="""<html>
<head>
<title>docs</title>
<script src="htmlCSSandJS/tabcontent.js" type="text/javascript"></script>
<link href="htmlCSSandJS/template1/tabcontent.css" rel="stylesheet" type="text/css" />
</head>
<body>"""
#read corresponding .flowdb file (with the same filename as the argument of the call of makehtml.py)
reader = csv.reader(open('flowdoc/aux_files/'+infile_str+'.flowdb', "rt", encoding="utf8"), delimiter='\t')
#loop over annotated functions / methods
for row in reader:
usr_key=''.join(e for e in row[0] if e.isalnum())
htmloffline_str+="""
<hr><hr><hr>"""
htmloffline_str+="<p>"+row[2]+"</p>"+"""<a name="#"""+usr_key+""""></a>"""
#if zoom level is 0
if int(row[1])==0:
zoomID=''
#if hyperlinks exist in the diagrams include them
if os.path.exists('flowdoc/aux_files/'+usr_key+zoomID+'.cmapx'):
htmloffline_str+= """
<img src="aux_files/"""+usr_key+zoomID+""".png" """
map_str=open('flowdoc/aux_files/'+usr_key+zoomID+'.cmapx').read()
htmloffline_str+=""" USEMAP="#"""+usr_key+zoomID+'_map'
htmloffline_str+=""""/> """
htmloffline_str+=map_str+'\n'
else:
htmloffline_str+= """
<img src="aux_files/"""+usr_key+zoomID+'.png'
htmloffline_str+=""" "> """
#else, loop over zoom levels and put them into tabs
else:
htmloffline_str+="""
<ul class="tabs" data-persist="true">"""
for i in range(int(row[1])+1):
zoomID=''
if i==1:
zoomID='1'
if i==2:
zoomID='2'
htmloffline_str+="""
<li><a href="#view"""+zoomID+'_'+usr_key+""" ">zoom"""+zoomID+"""</a></li>"""
htmloffline_str+="""
</ul>"""
htmloffline_str+= """
<div class="tabcontents"> """
for i in range(int(row[1])+1):
zoomID=''
if i==1:
zoomID='1'
if i==2:
zoomID='2'
htmloffline_str+="""
<div id="view"""+zoomID+'_'+usr_key+""" ">"""
#if hyperlinks exist in the diagrams include them
if os.path.exists('flowdoc/aux_files/'+usr_key+zoomID+'.cmapx'):
htmloffline_str+= """<img src="aux_files/"""+usr_key+zoomID+""".png" """
map_str=open('flowdoc/aux_files/'+usr_key+zoomID+'.cmapx').read()
htmloffline_str+=""" USEMAP="#"""+usr_key+zoomID+'_map'
htmloffline_str+=""""/> """
htmloffline_str+=map_str+'\n'
else:
htmloffline_str+= """<img src="aux_files/"""+usr_key+zoomID+'.png'
htmloffline_str+=""" "> """
htmloffline_str+="</div>"
htmloffline_str+="""
</div>"""
htmloffline_str+="""
</body>
</html>"""
#write string into HTML file
writefunc = open('flowdoc/'+infile_str+'.html',"w")
writefunc.write(htmloffline_str)
writefunc.close()