[Telepathy-commits] [telepathy-spec/master] Reassociate types with interfaces, show types for an interface
Davyd Madeley
davyd at madeley.id.au
Mon Mar 23 12:29:25 PDT 2009
---
doc/spec/style.css | 8 +++++++
doc/templates/interface.html | 29 +++++++++++++++++++++----
tools/specparser.py | 47 ++++++++++++++++++++++++++---------------
3 files changed, 62 insertions(+), 22 deletions(-)
diff --git a/doc/spec/style.css b/doc/spec/style.css
index 7a96046..e1d2fa5 100644
--- a/doc/spec/style.css
+++ b/doc/spec/style.css
@@ -65,6 +65,14 @@ div.property {
border: 1px solid #75507b;
}
+#types {
+ background-color: #e9b96e;
+}
+
+div.type {
+ border: 1px solid #c17d11;
+}
+
div.docstring {
margin: 1ex;
}
diff --git a/doc/templates/interface.html b/doc/templates/interface.html
index 77268bb..d82ad54 100644
--- a/doc/templates/interface.html
+++ b/doc/templates/interface.html
@@ -8,9 +8,11 @@
<body>
<div class="header">
<h1>Interface $interface.name</h1>
- <a href="index.html">Interface Index</a> |
- <a href="#methods">Methods</a> | <a href="#signals">Signals</a> |
- <a href="#properties">Properties</a>
+ <a href="index.html">Interface Index</a>
+ #if $interface.methods: | <a href="#methods">Methods</a>
+ #if $interface.signals: | <a href="#signals">Signals</a>
+ #if $interface.properties: | <a href="#properties">Properties</a>
+ #if $interface.types: | <a href="#types">Types</a>
</div>
<div class="main">
$interface.get_docstring()
@@ -114,7 +116,24 @@
</div>
#end for
</div>
- </div>
- #end if
+ #end if
+
+ #if $interface.types
+ <div id="types" class="outset type">
+ <h1>Types</h1>
+ #for $type in $interface.types
+ <div id="$type.name" class="inset type">
+ <span class="permalink">(<a href="$type.get_url()">Permalink</a>)</span>
+ <h2>
+ $type.short_name — $type.dbus_type ($type.get_type_name())
+ </h2>
+ $type.get_docstring()
+ </div>
+ #end for
+ </div>
+ #end if
+
+ </div>
+
</body>
</html>
diff --git a/tools/specparser.py b/tools/specparser.py
index 4f47259..348ea20 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -243,20 +243,18 @@ class Interface (base):
def __init__ (self, parent, namespace, dom):
super (Interface, self).__init__ (parent, namespace, dom)
- # build a dictionary of methods in this interface
+ # build a list of methods in this interface
self.methods = build_list (self, Method, self.name,
dom.getElementsByTagName ('method'))
- # build a dictionary of properties in this interface
+ # build a list of properties in this interface
self.properties = build_list (self, Property, self.name,
dom.getElementsByTagName ('property'))
- # build a dictionary of signals in this interface
+ # build a list of signals in this interface
self.signals = build_list (self, Signal, self.name,
dom.getElementsByTagName ('signal'))
- # print '-'*78
- # print self.methods
- # print self.properties
- # print self.signals
+ # build a list of types in this interface
+ self.types = parse_types (self, dom)
def get_interface (self):
return self
@@ -276,11 +274,23 @@ class DBusType (base):
Don't instantiate this class directly.
"""
+ def __init__ (self, parent, namespace, dom):
+ super (DBusType, self).__init__ (parent, namespace, dom)
+
+ self.dbus_type = dom.getAttribute ('type')
+
+ def get_title (self):
+ return "%s %s" % (self.get_type_name (), self.name)
+
+ def get_type_name (self):
+ return self.__class__.__name__
def get_url (self):
return '#FIXME'
-class SimpleType (DBusType): pass
+class SimpleType (DBusType):
+ def get_type_name (self):
+ return 'Simple Type'
class Mapping (DBusType): pass
@@ -297,16 +307,20 @@ class Spec (object):
self.errors = build_dict (self, Error,
errorsnode.getAttribute ('namespace'),
errorsnode.getElementsByTagNameNS (XMLNS_TP, 'error'))
- # build a dictionary of ALL types in this spec
- # FIXME: if we're doing all type parsing here, work out how to associate
- # types with an Interface
- self.generic_types = parse_types (self, dom)
- # build a dictionary of interfaces in this spec
+ # build a list of generic types
+ self.generic_types = parse_types (self,
+ dom.getElementsByTagNameNS (XMLNS_TP, 'generic-types')[0])
+ # build a list of interfaces in this spec
self.interfaces = build_list (self, Interface, None,
dom.getElementsByTagName ('interface'))
- # build a giant dictionary of everything
+ # build a giant dictionary of everything (interfaces, methods, signals
+ # and properties); also build a dictionary of types
self.everything = {}
+ self.types = {}
+
+ for type in self.generic_types: self.types[type.short_name] = type
+
for interface in self.interfaces:
self.everything[interface.name] = interface
@@ -317,9 +331,8 @@ class Spec (object):
for property in interface.properties:
self.everything[property.name] = property
- # build a dictionary of all types
- self.types = {}
- for type in self.generic_types: self.types[type.short_name] = type
+ for type in interface.types:
+ self.types[type.short_name] = type
def get_spec (self):
return self
--
1.5.6.5
More information about the telepathy-commits
mailing list