1
2
3
4
5
6
7
8
9
10
11
12
13
14 import sys, os, shutil
15 import logging
16 logging.basicConfig()
17 root = logging.getLogger()
18 root.setLevel(logging.CRITICAL)
19
20 import Globals
21
22 from utils import importClasses
23 from Products.ZenUtils.Utils import zenPath
24
26
27 - def __init__(self, baseModule, classList, outdir="docs"):
32
33
39
40
41
43 """
44 Generate our index file must be called after all classes are processed.
45 """
46 self.of = open(os.path.join(self.outdir, "index.html"),"w")
47 self.writeHeader()
48 keys = self._classnames.keys()
49 keys.sort()
50 self.writeTableHeader("Classes", ("ClassName", ))
51 for clsname in keys:
52 filepath = self._classnames[clsname]
53 self.of.write("""<tr class="tablevalues">""")
54 self.td("""<a href="%s">%s</a>""" % (filepath, clsname))
55 self.of.write("</table>")
56 self.writeFooter()
57 self.of.close()
58
59
71
72
74 props = getattr(cls, "_properties", False)
75 if not props: return
76 self.writeTableHeader("Properties", ("name", "type", "mode", "setter"))
77 for prop in props:
78 self.of.write("""<tr class="tablevalues">""")
79 for key in ("id", "type", "mode", "setter"):
80 self.of.write("""<td>%s</td>""" % prop.get(key, ""))
81 self.of.write("</tr>")
82 self.of.write("</table>")
83
84
102
103
105 self.of.write("<table>")
106 self.of.write(
107 """<tr class="tabletitle"><td colspan="%s">%s</td></tr>""" % (
108 len(colnames), title))
109 self.of.write("""<tr class="tableheader">""")
110 for colname in colnames:
111 self.of.write("<td>%s</td>" % colname)
112
113
115 self.of.write("<html>")
116 self.of.write("<head>")
117 self.of.write("""<link rel="stylesheet" href="schemadoc.css" """
118 """type="text/css" />""")
119 self.of.write("</head>")
120 self.of.write("<body>")
121
122
125
126
128 name = getattr(cls, "__name__", cls)
129 return ".".join((self.baseModule, name)) + ".html"
130
131
137
138
139 - def td(self, value):
141
142
143 baseModule = None
144 if len(sys.argv) > 1:
145 baseModule = sys.argv[1]
146 docdir = zenPath("zendocs/schema")
147 classList = importClasses(basemodule=baseModule,
148 skipnames=("ZentinelPortal", "ZDeviceLoader"))
149 htmlGen = HtmlGenerator(baseModule, classList, docdir)
150 htmlGen.generate()
151 cssfile = os.path.join(os.path.dirname(__file__),"schemadoc.css")
152 shutil.copy2(cssfile, docdir)
153