more updates from method

This commit is contained in:
Chris PeBenito 2005-06-10 01:35:43 +00:00
parent 0fd9dc55cf
commit d46f023278
5 changed files with 109 additions and 52 deletions

View File

@ -1,10 +1,15 @@
[[for int in interfaces]]
<div id="interface"> <div id="interface">
<h4>[[interface_name]]</h4> [[if int.has_key("mod_layer")]]
<p/> Layer: [[mod_layer]]<br>
[[end]]
[[if int.has_key("mod_name")]]
Module: [[mod_name]]<br>
[[end]]
<div id="codeblock"> <div id="codeblock">
[[exec i = 0]] [[exec i = 0]]
[[interface_name]]( <b>[[int['interface_name']]]</b>(
[[for arg in interface_parameters]] [[for arg in int['interface_parameters']]]
[[if i != 0]] [[if i != 0]]
, ,
[[end]] [[end]]
@ -21,13 +26,15 @@
</div> </div>
<div id="description"> <div id="description">
<p/> <p/>
<h5>Description</h5> <h5>Description:</h5>
[[interface_desc]]<br><br> <pre>
[[int['interface_desc']]]<br><br>
</pre>
<h5>Parameters:</h5> <h5>Parameters:</h5>
<div id="description"> <div id="description">
<table border="1" cellspacing="0" cellpadding="3" width="80%"> <table border="1" cellspacing="0" cellpadding="3" width="80%">
<tr><th class="title">Parameter:</td><th class="title">Description:</td><th class="title">Optional:</td></tr> <tr><th >Parameter:</td><th >Description:</td><th >Optional:</td></tr>
[[for arg in interface_parameters]] [[for arg in int['interface_parameters']]]
<tr><td> <tr><td>
[[arg['name']]] [[arg['name']]]
</td><td> </td><td>
@ -40,3 +47,4 @@
</div> </div>
</div> </div>
</div> </div>
[[end]]

View File

@ -9,4 +9,6 @@
[[end]] [[end]]
</div> </div>
[[end]] [[end]]
<br/><p/>
<a href="interfaces.html">*&nbsp;Interface Index</a>
</div> </div>

View File

@ -1,6 +1,9 @@
<h1>Layer: [[mod_layer]]</h1><p/> <h1>Layer: [[mod_layer]]</h1><p/>
<h2>Module: [[mod_name]]</h2><p/> <h2>Module: [[mod_name]]</h2><p/>
<h3>Summary: [[mod_summary]]</h3><p/> <h3>Summary:</h3><br>
<pre>
[[mod_summary]]<p/>
</pre>
<br/> <br/>
<h3>Interfaces: </h3> <h3>Interfaces: </h3>
[[interfaces]] [[interfaces]]

View File

@ -6,22 +6,35 @@ body {
background-color:white; background-color:white;
} }
h1 { h1 {
margin:0px 0px 15px 0px; margin:0px 0px 5px 0px;
padding:0px; padding:0px;
font-size:28px; font-size:150%
line-height:28px; line-height:28px;
font-weight:900; font-weight:900;
color:#ccc; color:#ccc;
} }
h2 { h2 {
font-size:100%; font-size:125%;
margin:0px;
padding:5px 0px 10px 0px;
} }
h3 { h3 {
font-size:75%; font-size:110%;
margin:0px;
padding:5px 0px 10px 5px;
} }
h4 { h4 {
font-size:67%; font-size:100%;
margin:0px;
padding:5px 0px 10px 5px;
} }
h5 {
font-size:100%;
margin:0px;
font-weight:600;
padding:0px 0px 5px 0px;
margin:0px 0px 0px 5px;
}
li { li {
font:11px/20px verdana, arial, helvetica, sans-serif; font:11px/20px verdana, arial, helvetica, sans-serif;
margin:0px 0px 0px 0px; margin:0px 0px 0px 0px;
@ -40,7 +53,7 @@ tt {
} }
table { table {
background-color:#eee; background-color:#efefef;
/*background-color: white;*/ /*background-color: white;*/
border-style:solid; border-style:solid;
border-color:black; border-color:black;
@ -53,7 +66,8 @@ table {
} }
th { th {
background-color: #eaeaff; font-weight:500;
background-color: #eaeaef;
text-align: center; text-align: center;
} }
@ -75,20 +89,32 @@ a:visited {color:#07a;}
a:hover {background-color:#eee;} a:hover {background-color:#eee;}
#Codeblock { #Codeblock {
margin:5px 50px 5px 50px; margin:5px 50px 5px 10px;
padding:5px 0px 5px 15px; padding:5px 0px 5px 15px;
border-style:solid; border-style:solid;
border-color:lightgrey; border-color:lightgrey;
border-width:1px 1px 1px 1px; border-width:1px 1px 1px 1px;
background-color:#f5f5ff; background-color:#f5f5ff;
font-size:11px; font-size:100%;
font-weight:600; font-weight:600;
text-decoration:none; text-decoration:none;
font-family:courier; font-family:monospace;
} }
#Interface { #Interface {
margin:5px 0px 25px 5px; margin:5px 0px 25px 5px;
padding:5px 5px 5px 5px; padding:5px 0px 5px 5px;
border-style:solid;
border-color:black;
border-width:1px 1px 1px 1px;
background-color:#fafafa;
font-size:14px;
font-weight:400;
text-decoration:none;
font-family:verdana, arial, helvetica, sans-serif;
}
#Interfacesmall {
margin:0px 0px 5px 0px;
padding:5px 0px 0px 5px;
border-style:solid; border-style:solid;
border-color:black; border-color:black;
border-width:1px 1px 1px 1px; border-width:1px 1px 1px 1px;
@ -107,19 +133,11 @@ a:hover {background-color:#eee;}
font-weight:400; font-weight:400;
} }
pre { pre {
font-size:11px; margin:0px;
font-weight:600; padding:0px;
font-size:14px;
text-decoration:none; text-decoration:none;
font-family:courier; font-family:verdana, arial, helvetica, sans-serif;
}
pre.codeblock {
/* code block (bordered, slight gray background) */
border-style:solid;
border-color:black;
border-width:1px 1px 1px 1px;
background-color:#f8f8f8;
margin-left: 10%;
margin-right: 10%;
} }
dl { dl {
/* definition text block */ /* definition text block */

View File

@ -17,8 +17,6 @@ import getopt
import pyplate import pyplate
import os import os
import string import string
#from xml.dom.ext import *
#from xml.dom.ext.reader import Sax2
from xml.dom.minidom import parse, parseString from xml.dom.minidom import parse, parseString
def read_policy_xml(filename): def read_policy_xml(filename):
@ -28,8 +26,6 @@ def read_policy_xml(filename):
error("error opening " + filename) error("error opening " + filename)
try: try:
#reader = Sax2.Reader()
#doc = reader.fromString(xml_fh.read())
doc = parseString(xml_fh.read()) doc = parseString(xml_fh.read())
except: except:
xml_fh.close() xml_fh.close()
@ -78,6 +74,9 @@ def gen_module_conf(doc, file):
def stupid_cmp(a, b): def stupid_cmp(a, b):
return cmp(a[0], b[0]) return cmp(a[0], b[0])
def int_cmp(a, b):
return cmp(a["interface_name"], b["interface_name"])
def gen_doc_menu(mod_layer, module_list): def gen_doc_menu(mod_layer, module_list):
menu = [] menu = []
for layer, value in module_list.iteritems(): for layer, value in module_list.iteritems():
@ -97,6 +96,7 @@ def gen_doc_menu(mod_layer, module_list):
def gen_docs(doc, dir, templatedir): def gen_docs(doc, dir, templatedir):
try: try:
#get the template data ahead of time so we don't reopen them over and over
bodyfile = open(templatedir + "/header.html", "r") bodyfile = open(templatedir + "/header.html", "r")
bodydata = bodyfile.read() bodydata = bodyfile.read()
bodyfile.close() bodyfile.close()
@ -112,6 +112,9 @@ def gen_docs(doc, dir, templatedir):
modulefile = open(templatedir + "/module.html","r") modulefile = open(templatedir + "/module.html","r")
moduledata = modulefile.read() moduledata = modulefile.read()
modulefile.close() modulefile.close()
intlistfile = open(templatedir + "/int_list.html", "r")
intlistdata = intlistfile.read()
intlistfile.close()
except: except:
error("Could not open templates") error("Could not open templates")
@ -176,8 +179,9 @@ def gen_docs(doc, dir, templatedir):
body_tpl = pyplate.Template(bodydata) body_tpl = pyplate.Template(bodydata)
body_tpl.execute(index_fh, body_args) body_tpl.execute(index_fh, body_args)
index_fh.close() index_fh.close()
#now generate the individual module pages
all_interfaces = []
for node in doc.getElementsByTagName("module"): for node in doc.getElementsByTagName("module"):
mod_name = mod_layer = interface_buf = '' mod_name = mod_layer = interface_buf = ''
for (name, value) in node.attributes.items(): for (name, value) in node.attributes.items():
@ -187,10 +191,11 @@ def gen_docs(doc, dir, templatedir):
mod_layer = value mod_layer = value
for desc in node.getElementsByTagName("summary"): for desc in node.getElementsByTagName("summary"):
mod_summary = desc.firstChild.data mod_summary = desc.firstChild.data
interfaces = []
for interface in node.getElementsByTagName("interface"): for interface in node.getElementsByTagName("interface"):
interface_parameters = [] interface_parameters = []
interface_secdesc = None interface_secdesc = None
interface_tpl = pyplate.Template(intdata)
for i,v in interface.attributes.items(): for i,v in interface.attributes.items():
interface_name = v interface_name = v
for desc in interface.getElementsByTagName("description"): for desc in interface.getElementsByTagName("description"):
@ -213,17 +218,25 @@ def gen_docs(doc, dir, templatedir):
"desc" : paramdesc, "desc" : paramdesc,
"optional" : paramopt } "optional" : paramopt }
interface_parameters.append(parameter) interface_parameters.append(parameter)
interface_args = { "interface_name" : interface_name, interfaces.append( { "interface_name" : interface_name,
"interface_desc" : interface_desc, "interface_desc" : interface_desc,
"interface_parameters" : interface_parameters, "interface_parameters" : interface_parameters,
"interface_secdesc" : interface_secdesc } "interface_secdesc" : interface_secdesc })
interface_buf += interface_tpl.execute_string(interface_args) #all_interfaces is for the main interface index with all interfaces
all_interfaces.append( { "interface_name" : interface_name,
"interface_desc" : interface_desc,
"interface_parameters" : interface_parameters,
"interface_secdesc" : interface_secdesc,
"mod_name": mod_name,
"mod_layer" : mod_layer })
interfaces.sort(int_cmp)
interface_tpl = pyplate.Template(intdata)
interface_buf = interface_tpl.execute_string({"interfaces" : interfaces})
menu = gen_doc_menu(mod_layer, module_list) menu = gen_doc_menu(mod_layer, module_list)
menu_args = { "menulist" : menu }
menu_tpl = pyplate.Template(menudata) menu_tpl = pyplate.Template(menudata)
menu_buf = menu_tpl.execute_string(menu_args) menu_buf = menu_tpl.execute_string({ "menulist" : menu })
module_args = { "mod_layer" : mod_layer, module_args = { "mod_layer" : mod_layer,
"mod_name" : mod_name, "mod_name" : mod_name,
@ -242,6 +255,27 @@ def gen_docs(doc, dir, templatedir):
body_tpl.execute(module_fh, body_args) body_tpl.execute(module_fh, body_args)
module_fh.close() module_fh.close()
#and last build the interface index
menu = gen_doc_menu(None, module_list)
menu_args = { "menulist" : menu,
"mod_layer" : None }
menu_tpl = pyplate.Template(menudata)
menu_buf = menu_tpl.execute_string(menu_args)
all_interfaces.sort(int_cmp)
interface_tpl = pyplate.Template(intlistdata)
interface_buf = interface_tpl.execute_string({"interfaces" : all_interfaces})
int_file = "interfaces.html"
int_fh = open(int_file, "w")
body_tpl = pyplate.Template(bodydata)
body_args = { "menu" : menu_buf,
"content" : interface_buf }
body_tpl.execute(int_fh, body_args)
int_fh.close()
def error(error): def error(error):
sys.stderr.write("%s exiting for: " % sys.argv[0]) sys.stderr.write("%s exiting for: " % sys.argv[0])
sys.stderr.write("%s\n" % error) sys.stderr.write("%s\n" % error)
@ -257,14 +291,6 @@ def usage():
sys.stdout.write("-x --xml <file> -- filename to read xml data from\n") sys.stdout.write("-x --xml <file> -- filename to read xml data from\n")
sys.stdout.write("-T --templates <dir> -- template directory for documents\n") sys.stdout.write("-T --templates <dir> -- template directory for documents\n")
def sort_dict(d):
our_list = d.items()
our_list.sort()
k = {}
for item in our_list:
k[item[0]] = item[1]
return k
try: try:
opts, args = getopt.getopt(sys.argv[1:], "t:m:d:x:T:", ["tunables","modules","docs","xml", "templates"]) opts, args = getopt.getopt(sys.argv[1:], "t:m:d:x:T:", ["tunables","modules","docs","xml", "templates"])
except getopt.GetoptError: except getopt.GetoptError: