[Telepathy-commits] [telepathy-spec/master] Add generic-types and errors HTML files to the spec

Davyd Madeley davyd at madeley.id.au
Mon Mar 23 12:29:24 PDT 2009


---
 doc/templates/errors.html        |   33 +++++++++++++++++++++++++++++++++
 doc/templates/generic-types.html |   34 ++++++++++++++++++++++++++++++++++
 doc/templates/index.html         |    7 +++++++
 tools/doc-generator.py           |   18 ++++++++++++++++--
 tools/specparser.py              |   15 +++++++++++----
 5 files changed, 101 insertions(+), 6 deletions(-)
 create mode 100644 doc/templates/errors.html
 create mode 100644 doc/templates/generic-types.html

diff --git a/doc/templates/errors.html b/doc/templates/errors.html
new file mode 100644
index 0000000..20f53bb
--- /dev/null
+++ b/doc/templates/errors.html
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" "">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+  <title>Errors</title>
+  <link rel="stylesheet" href="style.css" type="text/css"/>
+ </head>
+ <body>
+  <div class="header">
+  <h1>Errors</h1>
+   <a href="index.html">Interface Index</a>
+   <a href="#errors">Errors</a>
+  </div>
+  <div class="main">
+   <div id="errors" class="outset error">
+    <h1>Errors</h1>
+    #for $error in $spec.errors.values()
+     <div id="$error.name" class="inset error">
+      <span class="permalink">(<a href="$error.get_url()">Permalink</a>)</span>
+      <h2>
+       $error.short_name
+      </h2>
+
+      $error.get_added_html()
+      $error.get_deprecated_html()
+      $error.get_docstring()
+     </div>
+    #end for
+   </div>
+   </div>
+
+ </body>
+</html>
diff --git a/doc/templates/generic-types.html b/doc/templates/generic-types.html
new file mode 100644
index 0000000..261faa1
--- /dev/null
+++ b/doc/templates/generic-types.html
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" "">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+  <title>Generic Types</title>
+  <link rel="stylesheet" href="style.css" type="text/css"/>
+ </head>
+ <body>
+  <div class="header">
+  <h1>Generic Types</h1>
+   <a href="index.html">Interface Index</a>
+   <a href="#types">Types</a>
+  </div>
+  <div class="main">
+   <div id="types" class="outset type">
+    <h1>Generic Types</h1>
+    #for $type in $spec.generic_types
+     <div id="$type.name" class="inset type">
+      <span class="permalink">$type.get_type_name() (<a href="$type.get_url()">Permalink</a>)</span>
+      <h2>
+       $type.short_name &mdash; $type.dbus_type
+      </h2>
+
+      $type.get_added_html()
+      $type.get_deprecated_html()
+      $type.get_docstring()
+      $type.get_breakdown()
+     </div>
+    #end for
+   </div>
+   </div>
+
+ </body>
+</html>
diff --git a/doc/templates/index.html b/doc/templates/index.html
index e400daa..ee36a6d 100644
--- a/doc/templates/index.html
+++ b/doc/templates/index.html
@@ -8,10 +8,17 @@
  <body>
   <h1>FIXME - get this from the XML</h1>
 
+  <h3>Interfaces</h3>
   <ul>
   #for $interface in $interfaces
    <li><a href="$interface.get_url()">$interface.name</a></li>
   #end for
   </ul>
+
+  <h3>Extra</h3>
+  <ul>
+   <li><a href="generic-types.html">Generic Types</a></li>
+   <li><a href="errors.html">Errors</a></li>
+  </ul>
  </body>
 </html>
diff --git a/tools/doc-generator.py b/tools/doc-generator.py
index bc04815..9f7aba4 100755
--- a/tools/doc-generator.py
+++ b/tools/doc-generator.py
@@ -45,8 +45,22 @@ for interface in spec.interfaces:
 # write out a TOC
 template_def = load_template ('index.html')
 t = Template (template_def, namespaces = [spec])
-
-# open the output file
 out = open (os.path.join (output_path, 'index.html'), 'w')
 print >> out, t
 out.close ()
+
+# write out the generic types
+namespace = { 'spec': spec }
+template_def = load_template ('generic-types.html')
+t = Template (template_def, namespaces = namespace)
+out = open (os.path.join (output_path, 'generic-types.html'), 'w')
+print >> out, t
+out.close ()
+
+# write out the errors
+namespace = { 'spec': spec }
+template_def = load_template ('errors.html')
+t = Template (template_def, namespaces = namespace)
+out = open (os.path.join (output_path, 'errors.html'), 'w')
+print >> out, t
+out.close ()
diff --git a/tools/specparser.py b/tools/specparser.py
index 5de525a..a5adb2e 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -292,7 +292,7 @@ class Interface (base):
                                    dom.getElementsByTagName ('signal'))
 
         # build a list of types in this interface
-        self.types = parse_types (self, dom)
+        self.types = parse_types (self, dom, self.name)
 
         # find out if this interface causes havoc
         self.causes_havoc = dom.getAttributeNS (XMLNS_TP, 'causes-havoc')
@@ -320,6 +320,9 @@ class DBusType (base):
         super (DBusType, self).__init__ (parent, namespace, dom)
 
         self.dbus_type = dom.getAttribute ('type')
+    
+    def get_root_namespace (self):
+        return self.namespace
 
     def get_breakdown (self):
         return ''
@@ -342,7 +345,9 @@ class StructLike (DBusType):
 
        Don't instantiate this class directly.
     """
-    class StructMember (Typed): pass
+    class StructMember (Typed):
+        def get_root_namespace (self):
+            return self.parent.get_root_namespace ()
     
     def __init__ (self, parent, namespace, dom):
         super (StructLike, self).__init__ (parent, namespace, dom)
@@ -394,6 +399,8 @@ class EnumLike (DBusType):
             self.name = build_name (namespace, self.short_name)
 
             self.value = dom.getAttribute ('value')
+        def get_root_namespace (self):
+            return self.parent.get_root_namespace ()
 
     def get_breakdown (self):
         str = ''
@@ -493,7 +500,7 @@ def build_dict (parent, type_, namespace, nodes):
 def build_list (parent, type_, namespace, nodes):
     return map (lambda node: type_ (parent, namespace, node), nodes)
 
-def parse_types (parent, dom):
+def parse_types (parent, dom, namespace = None):
     """Parse all of the types of type nodes mentioned in 't' from the node
        'dom' and insert them into the dictionary 'd'.
     """
@@ -508,7 +515,7 @@ def parse_types (parent, dom):
     types = []
 
     for (type_, tagname) in t:
-        types += build_list (parent, type_, None,
+        types += build_list (parent, type_, namespace,
                     dom.getElementsByTagNameNS (XMLNS_TP, tagname))
 
     return types
-- 
1.5.6.5




More information about the telepathy-commits mailing list