[selinux-policy: 324/3172] more updates from method
Daniel J Walsh
dwalsh at fedoraproject.org
Thu Oct 7 19:32:55 UTC 2010
commit d46f023278b76437dcd219b9485040d1e1bbb58f
Author: Chris PeBenito <cpebenito at tresys.com>
Date: Fri Jun 10 01:35:43 2005 +0000
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 d9c6883..e9b12ab 100644
--- a/refpolicy/doc/templates/interface.html
+++ b/refpolicy/doc/templates/interface.html
@@ -1,10 +1,15 @@
+[[for int in interfaces]]
<div id="interface">
-<h4>[[interface_name]]</h4>
-<p/>
+[[if int.has_key("mod_layer")]]
+ Layer: [[mod_layer]]<br>
+[[end]]
+[[if int.has_key("mod_name")]]
+ Module: [[mod_name]]<br>
+[[end]]
<div id="codeblock">
[[exec i = 0]]
-[[interface_name]](
- [[for arg in interface_parameters]]
+<b>[[int['interface_name']]]</b>(
+ [[for arg in int['interface_parameters']]]
[[if i != 0]]
,
[[end]]
@@ -21,13 +26,15 @@
</div>
<div id="description">
<p/>
-<h5>Description</h5>
-[[interface_desc]]<br><br>
+<h5>Description:</h5>
+<pre>
+[[int['interface_desc']]]<br><br>
+</pre>
<h5>Parameters:</h5>
<div id="description">
<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>
-[[for arg in interface_parameters]]
+<tr><th >Parameter:</td><th >Description:</td><th >Optional:</td></tr>
+[[for arg in int['interface_parameters']]]
<tr><td>
[[arg['name']]]
</td><td>
@@ -40,3 +47,4 @@
</div>
</div>
</div>
+[[end]]
diff --git a/refpolicy/doc/templates/menu.html b/refpolicy/doc/templates/menu.html
index ac32524..1303e10 100644
--- a/refpolicy/doc/templates/menu.html
+++ b/refpolicy/doc/templates/menu.html
@@ -9,4 +9,6 @@
[[end]]
</div>
[[end]]
+ <br/><p/>
+ <a href="interfaces.html">* Interface Index</a>
</div>
diff --git a/refpolicy/doc/templates/module.html b/refpolicy/doc/templates/module.html
index c23ab65..53cac90 100644
--- a/refpolicy/doc/templates/module.html
+++ b/refpolicy/doc/templates/module.html
@@ -1,6 +1,9 @@
<h1>Layer: [[mod_layer]]</h1><p/>
<h2>Module: [[mod_name]]</h2><p/>
-<h3>Summary: [[mod_summary]]</h3><p/>
+<h3>Summary:</h3><br>
+<pre>
+[[mod_summary]]<p/>
+</pre>
<br/>
<h3>Interfaces: </h3>
[[interfaces]]
diff --git a/refpolicy/doc/templates/style.css b/refpolicy/doc/templates/style.css
index e865be1..a0eba00 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 1429762..a4d9b9c 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 <file> -- filename to read xml data from\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:
opts, args = getopt.getopt(sys.argv[1:], "t:m:d:x:T:", ["tunables","modules","docs","xml", "templates"])
except getopt.GetoptError:
More information about the scm-commits
mailing list