add templates

This commit is contained in:
Chris PeBenito 2005-06-28 20:41:50 +00:00
parent ceebe3b4b0
commit effd58c647
6 changed files with 199 additions and 4 deletions

View File

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

View File

@ -1,10 +1,16 @@
<h1>Layer: [[mod_layer]]</h1><p/>
<h2>Module: [[mod_name]]</h2><p/>
<a href=#interfaces>Interfaces</a>
<a href=#templates>Templates</a>
<h3>Description:</h3>
[[if mod_desc]]
[[mod_desc]]
[[else]]
[[mod_summary]]
[[end]]
<a name="interfaces"/>
<h3>Interfaces: </h3>
[[interfaces]]
<a name="templates"/>
<h3>Templates: </h3>
[[templates]]

View File

@ -124,6 +124,30 @@ a:hover {background-color:#eee;}
text-decoration:none;
font-family:verdana, arial, helvetica, sans-serif;
}
#Template {
margin:5px 0px 25px 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;
}
#Templatesmall {
margin:0px 0px 5px 0px;
padding:5px 0px 0px 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;
}
#Description {
margin:0px 0px 0px 5px;
padding:0px 0px 0px 5px;

33
refpolicy/doc/templates/temp_list.html vendored Normal file
View File

@ -0,0 +1,33 @@
<h3>Master template index:</h3>
[[for temp in templates]]
<div id="templatesmall">
Module: <a href='[[temp['mod_layer']+ "_" + temp['mod_name']]].html'>
[[temp['mod_name']]]</a><p/>
Layer: <a href='[[temp['mod_layer']]].html'>
[[temp['mod_layer']]]</a><p/>
<div id="codeblock">
[[exec i = 0]]
<b>[[temp['template_name']]]</b>(
[[for arg in temp['template_parameters']]]
[[if i != 0]]
,
[[end]]
[[exec i = 1]]
[[if arg['optional'] == 'yes']]
[
[[end]]
[[arg['name']]]
[[if arg['optional'] == 'yes']]
]
[[end]]
[[end]]
)<br>
</div>
[[if temp['template_summary']]]
<div id="description">
[[temp['template_summary']]]
</div>
[[end]]
</div>
[[end]]

51
refpolicy/doc/templates/template.html vendored Normal file
View File

@ -0,0 +1,51 @@
[[for temp in templates]]
<div id="template">
[[if temp.has_key("mod_layer")]]
Layer: [[mod_layer]]<br>
[[end]]
[[if temp.has_key("mod_name")]]
Module: [[mod_name]]<br>
[[end]]
<div id="codeblock">
[[exec i = 0]]
<b>[[temp['template_name']]]</b>(
[[for arg in temp['template_parameters']]]
[[if i != 0]]
,
[[end]]
[[exec i = 1]]
[[if arg['optional'] == 'yes']]
[
[[end]]
[[arg['name']]]
[[if arg['optional'] == 'yes']]
]
[[end]]
[[end]]
)<br>
</div>
<div id="description">
[[if temp['template_summary']]]
<h5>Summary</h5>
[[temp['template_summary']]]
[[end]]
[[if temp['template_desc']]]
<h5>Description</h5>
[[temp['template_desc']]]
[[end]]
<h5>Parameters</h5>
<table border="1" cellspacing="0" cellpadding="3" width="80%">
<tr><th >Parameter:</td><th >Description:</td><th >Optional:</td></tr>
[[for arg in temp['template_parameters']]]
<tr><td>
[[arg['name']]]
</td><td>
[[arg['desc']]]
</td><td>
[[arg['optional']]]
</td></tr>
[[end]]
</table>
</div>
</div>
[[end]]

View File

@ -151,7 +151,14 @@ def int_cmp(a, b):
"""
return cmp(a["interface_name"], b["interface_name"])
def temp_cmp(a, b):
"""
Compares two templates.
"""
return cmp(a["template_name"], b["template_name"])
def gen_doc_menu(mod_layer, module_list):
"""
Generates the HTML document menu.
@ -226,6 +233,9 @@ def gen_docs(doc, dir, templatedir):
intfile = open(templatedir + "/interface.html", "r")
intdata = intfile.read()
intfile.close()
templatefile = open(templatedir + "/template.html", "r")
templatedata = templatefile.read()
templatefile.close()
menufile = open(templatedir + "/menu.html", "r")
menudata = menufile.read()
menufile.close()
@ -238,6 +248,9 @@ def gen_docs(doc, dir, templatedir):
intlistfile = open(templatedir + "/int_list.html", "r")
intlistdata = intlistfile.read()
intlistfile.close()
templistfile = open(templatedir + "/temp_list.html", "r")
templistdata = templistfile.read()
templistfile.close()
except:
error("Could not open templates")
@ -305,6 +318,7 @@ def gen_docs(doc, dir, templatedir):
#now generate the individual module pages
all_interfaces = []
all_templates = []
for node in doc.getElementsByTagName("module"):
mod_name = mod_layer = mod_desc = interface_buf = ''
@ -363,6 +377,55 @@ def gen_docs(doc, dir, templatedir):
interface_tpl = pyplate.Template(intdata)
interface_buf = interface_tpl.execute_string({"interfaces" : interfaces})
# now generate individual template pages
templates = []
for template in node.getElementsByTagName("template"):
template_parameters = []
template_desc = template_secdesc = template_summary = None
for i,v in template.attributes.items():
template_name = v
for desc in template.getElementsByTagName("desc"):
template_desc = format_html_desc(desc)
for desc in template.getElementsByTagName("secdesc"):
if desc:
template_secdesc = format_html_desc(desc)
for desc in template.getElementsByTagName("summary"):
template_summary = format_html_desc(desc)
for args in template.getElementsByTagName("param"):
paramdesc = args.firstChild.data
paramname = None
paramopt = "No"
for name,val in args.attributes.items():
if name == "name":
paramname = val
if name == "optional":
if val == "true":
paramopt = "yes"
parameter = { "name" : paramname,
"desc" : paramdesc,
"optional" : paramopt }
template_parameters.append(parameter)
templates.append( { "template_name" : template_name,
"template_summary" : template_summary,
"template_desc" : template_desc,
"template_parameters" : template_parameters,
"template_secdesc" : template_secdesc })
#all_templates is for the main interface index with all templates
all_templates.append( { "template_name" : template_name,
"template_summary" : template_summary,
"template_desc" : template_desc,
"template_parameters" : template_parameters,
"template_secdesc" : template_secdesc,
"mod_name": mod_name,
"mod_layer" : mod_layer })
templates.sort(temp_cmp)
template_tpl = pyplate.Template(templatedata)
template_buf = template_tpl.execute_string({"templates" : templates})
menu = gen_doc_menu(mod_layer, module_list)
menu_tpl = pyplate.Template(menudata)
@ -372,7 +435,8 @@ def gen_docs(doc, dir, templatedir):
"mod_name" : mod_name,
"mod_summary" : mod_summary,
"mod_desc" : mod_desc,
"interfaces" : interface_buf }
"interfaces" : interface_buf,
"templates": template_buf }
module_tpl = pyplate.Template(moduledata)
module_buf = module_tpl.execute_string(module_args)
@ -386,14 +450,14 @@ def gen_docs(doc, dir, templatedir):
body_tpl.execute(module_fh, body_args)
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)
#build the interface index
all_interfaces.sort(int_cmp)
interface_tpl = pyplate.Template(intlistdata)
interface_buf = interface_tpl.execute_string({"interfaces" : all_interfaces})
@ -407,6 +471,21 @@ def gen_docs(doc, dir, templatedir):
body_tpl.execute(int_fh, body_args)
int_fh.close()
#build the template index
all_templates.sort(temp_cmp)
template_tpl = pyplate.Template(templistdata)
template_buf = template_tpl.execute_string({"templates" : all_templates})
temp_file = "templates.html"
temp_fh = open(temp_file, "w")
body_tpl = pyplate.Template(bodydata)
body_args = { "menu" : menu_buf,
"content" : template_buf }
body_tpl.execute(temp_fh, body_args)
temp_fh.close()
def error(error):
"""
Print an error message and exit.