From d46f023278b76437dcd219b9485040d1e1bbb58f Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Fri, 10 Jun 2005 01:35:43 +0000 Subject: [PATCH] more updates from method --- refpolicy/doc/templates/interface.html | 24 ++++++---- refpolicy/doc/templates/menu.html | 2 + refpolicy/doc/templates/module.html | 5 +- refpolicy/doc/templates/style.css | 64 ++++++++++++++++--------- refpolicy/support/sedoctool.py | 66 ++++++++++++++++++-------- 5 files changed, 109 insertions(+), 52 deletions(-) diff --git a/refpolicy/doc/templates/interface.html b/refpolicy/doc/templates/interface.html index d9c68839..e9b12ab5 100644 --- a/refpolicy/doc/templates/interface.html +++ b/refpolicy/doc/templates/interface.html @@ -1,10 +1,15 @@ +[[for int in interfaces]]
-

[[interface_name]]

-

+[[if int.has_key("mod_layer")]] + Layer: [[mod_layer]]
+[[end]] +[[if int.has_key("mod_name")]] + Module: [[mod_name]]
+[[end]]

[[exec i = 0]] -[[interface_name]]( - [[for arg in interface_parameters]] +[[int['interface_name']]]( + [[for arg in int['interface_parameters']]] [[if i != 0]] , [[end]] @@ -21,13 +26,15 @@

-

Description
-[[interface_desc]]

+
Description:
+
+[[int['interface_desc']]]

+
Parameters:
- -[[for arg in interface_parameters]] + +[[for arg in int['interface_parameters']]]
Parameter:Description:Optional:
Parameter:Description:Optional:
[[arg['name']]] @@ -40,3 +47,4 @@ +[[end]] diff --git a/refpolicy/doc/templates/menu.html b/refpolicy/doc/templates/menu.html index ac325248..1303e10d 100644 --- a/refpolicy/doc/templates/menu.html +++ b/refpolicy/doc/templates/menu.html @@ -9,4 +9,6 @@ [[end]] [[end]] +

+ * Interface Index diff --git a/refpolicy/doc/templates/module.html b/refpolicy/doc/templates/module.html index c23ab658..53cac908 100644 --- a/refpolicy/doc/templates/module.html +++ b/refpolicy/doc/templates/module.html @@ -1,6 +1,9 @@

Layer: [[mod_layer]]

Module: [[mod_name]]

-

Summary: [[mod_summary]]

+

Summary:


+
+[[mod_summary]]

+


Interfaces:

[[interfaces]] diff --git a/refpolicy/doc/templates/style.css b/refpolicy/doc/templates/style.css index e865be16..a0eba003 100644 --- a/refpolicy/doc/templates/style.css +++ b/refpolicy/doc/templates/style.css @@ -6,22 +6,35 @@ body { background-color:white; } h1 { - margin:0px 0px 15px 0px; + margin:0px 0px 5px 0px; padding:0px; - font-size:28px; + font-size:150% line-height:28px; font-weight:900; color:#ccc; } h2 { - font-size:100%; + font-size:125%; + margin:0px; + padding:5px 0px 10px 0px; } h3 { - font-size:75%; + font-size:110%; + margin:0px; + padding:5px 0px 10px 5px; } 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 { font:11px/20px verdana, arial, helvetica, sans-serif; margin:0px 0px 0px 0px; @@ -40,7 +53,7 @@ tt { } table { - background-color:#eee; + background-color:#efefef; /*background-color: white;*/ border-style:solid; border-color:black; @@ -53,7 +66,8 @@ table { } th { - background-color: #eaeaff; + font-weight:500; + background-color: #eaeaef; text-align: center; } @@ -75,20 +89,20 @@ a:visited {color:#07a;} a:hover {background-color:#eee;} #Codeblock { - margin:5px 50px 5px 50px; + margin:5px 50px 5px 10px; padding:5px 0px 5px 15px; border-style:solid; border-color:lightgrey; border-width:1px 1px 1px 1px; background-color:#f5f5ff; - font-size:11px; + font-size:100%; font-weight:600; text-decoration:none; - font-family:courier; + font-family:monospace; } #Interface { 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; @@ -98,6 +112,18 @@ a:hover {background-color:#eee;} 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-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; @@ -107,19 +133,11 @@ a:hover {background-color:#eee;} font-weight:400; } pre { - font-size:11px; - font-weight:600; + margin:0px; + padding:0px; + font-size:14px; text-decoration:none; - font-family:courier; -} -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%; + font-family:verdana, arial, helvetica, sans-serif; } dl { /* definition text block */ diff --git a/refpolicy/support/sedoctool.py b/refpolicy/support/sedoctool.py index 1429762c..a4d9b9c1 100755 --- a/refpolicy/support/sedoctool.py +++ b/refpolicy/support/sedoctool.py @@ -17,8 +17,6 @@ import getopt import pyplate import os import string -#from xml.dom.ext import * -#from xml.dom.ext.reader import Sax2 from xml.dom.minidom import parse, parseString def read_policy_xml(filename): @@ -28,8 +26,6 @@ def read_policy_xml(filename): error("error opening " + filename) try: - #reader = Sax2.Reader() - #doc = reader.fromString(xml_fh.read()) doc = parseString(xml_fh.read()) except: xml_fh.close() @@ -77,6 +73,9 @@ def gen_module_conf(doc, file): def stupid_cmp(a, b): 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): menu = [] @@ -97,6 +96,7 @@ def gen_doc_menu(mod_layer, module_list): def gen_docs(doc, dir, templatedir): try: + #get the template data ahead of time so we don't reopen them over and over bodyfile = open(templatedir + "/header.html", "r") bodydata = bodyfile.read() bodyfile.close() @@ -112,6 +112,9 @@ def gen_docs(doc, dir, templatedir): modulefile = open(templatedir + "/module.html","r") moduledata = modulefile.read() modulefile.close() + intlistfile = open(templatedir + "/int_list.html", "r") + intlistdata = intlistfile.read() + intlistfile.close() except: error("Could not open templates") @@ -176,8 +179,9 @@ def gen_docs(doc, dir, templatedir): body_tpl = pyplate.Template(bodydata) body_tpl.execute(index_fh, body_args) index_fh.close() - +#now generate the individual module pages + all_interfaces = [] for node in doc.getElementsByTagName("module"): mod_name = mod_layer = interface_buf = '' for (name, value) in node.attributes.items(): @@ -187,10 +191,11 @@ def gen_docs(doc, dir, templatedir): mod_layer = value for desc in node.getElementsByTagName("summary"): mod_summary = desc.firstChild.data + + interfaces = [] for interface in node.getElementsByTagName("interface"): interface_parameters = [] interface_secdesc = None - interface_tpl = pyplate.Template(intdata) for i,v in interface.attributes.items(): interface_name = v for desc in interface.getElementsByTagName("description"): @@ -213,17 +218,25 @@ def gen_docs(doc, dir, templatedir): "desc" : paramdesc, "optional" : paramopt } interface_parameters.append(parameter) - interface_args = { "interface_name" : interface_name, + interfaces.append( { "interface_name" : interface_name, "interface_desc" : interface_desc, "interface_parameters" : interface_parameters, - "interface_secdesc" : interface_secdesc } - interface_buf += interface_tpl.execute_string(interface_args) - + "interface_secdesc" : interface_secdesc }) + #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_args = { "menulist" : menu } 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, "mod_name" : mod_name, @@ -242,6 +255,27 @@ 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) + + 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): sys.stderr.write("%s exiting for: " % sys.argv[0]) sys.stderr.write("%s\n" % error) @@ -257,14 +291,6 @@ def usage(): sys.stdout.write("-x --xml -- filename to read xml data from\n") sys.stdout.write("-T --templates -- 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: opts, args = getopt.getopt(sys.argv[1:], "t:m:d:x:T:", ["tunables","modules","docs","xml", "templates"]) except getopt.GetoptError: