[Telepathy-commits] [telepathy-spec/master] Generate a .devhelp2 file for the new spec parser

Davyd Madeley davyd at madeley.id.au
Wed Mar 25 07:57:23 PDT 2009


---
 doc/templates/devhelp.devhelp2 |   17 +++++++++++++++++
 tools/doc-generator.py         |    8 ++++++++
 tools/specparser.py            |   15 +++++++++++++++
 3 files changed, 40 insertions(+), 0 deletions(-)
 create mode 100644 doc/templates/devhelp.devhelp2

diff --git a/doc/templates/devhelp.devhelp2 b/doc/templates/devhelp.devhelp2
new file mode 100644
index 0000000..13a9beb
--- /dev/null
+++ b/doc/templates/devhelp.devhelp2
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<book xmlns="http://www.devhelp.net/book" title="$spec.title" name="$name" link="index.html">
+ <chapters>
+#for $interface in $spec.interfaces
+  <sub name="$interface.name" link="$interface.get_url()"/>
+#end for
+  <sub name="Generic Types" link="generic-types.html"/>
+  <sub name="Errors" link="errors.html"/>
+ </chapters>
+ <functions>
+#for $obj in $spec.everything.values() + $spec.types.values() + $spec.errors.values()
+  <keyword type="$obj.devhelp_name" name="$obj.get_title()" link="$obj.get_url()" #slurp
+#if $obj.deprecated: deprecated="true" #slurp
+/>
+#end for
+ </functions>
+</book>
diff --git a/tools/doc-generator.py b/tools/doc-generator.py
index 21d5c51..69c0cf5 100755
--- a/tools/doc-generator.py
+++ b/tools/doc-generator.py
@@ -104,3 +104,11 @@ t = Template(template_def, namespaces=namespace)
 out = open(os.path.join(output_path, 'fullindex.html'), 'w')
 print >> out, unicode(t).encode('utf-8')
 out.close()
+
+# write out the devhelp2 file
+namespace = { 'spec': spec, 'name': 'telepathy-spec' }
+template_def = load_template('devhelp.devhelp2')
+t = Template(template_def, namespaces=namespace)
+out = open(os.path.join(output_path, 'telepathy-spec.devhelp2'), 'w')
+print >> out, unicode(t).encode('utf-8')
+out.close()
diff --git a/tools/specparser.py b/tools/specparser.py
index c391363..6de11b3 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -65,6 +65,8 @@ class Base(object):
 
        Don't instantiate this class directly.
     """
+    devhelp_name = ""
+
     def __init__(self, parent, namespace, dom):
         self.short_name = name = dom.getAttribute('name')
         self.namespace = namespace
@@ -239,6 +241,8 @@ class PossibleError(Base):
             return d
 
 class Method(Base):
+    devhelp_name = "function"
+
     def __init__(self, parent, namespace, dom):
         super(Method, self).__init__(parent, namespace, dom)
 
@@ -273,6 +277,7 @@ class Typed(Base):
 
        Don't instantiate this class directly.
     """
+
     def __init__(self, parent, namespace, dom):
         super(Typed, self).__init__(parent, namespace, dom)
 
@@ -486,6 +491,9 @@ class DBusType(Base):
 
        Don't instantiate this class directly.
     """
+
+    devhelp_name = "typedef"
+
     def __init__(self, parent, namespace, dom):
         super(DBusType, self).__init__(parent, namespace, dom)
 
@@ -523,6 +531,7 @@ class StructLike(DBusType):
 
        Don't instantiate this class directly.
     """
+
     class StructMember(Typed):
         def get_root_namespace(self):
             return self.parent.get_root_namespace()
@@ -557,6 +566,9 @@ class Mapping(StructLike):
         self.dbus_type = 'a{%s}' % ''.join(map(lambda m: m.dbus_type, self.members))
 
 class Struct(StructLike):
+
+    devhelp_name = "struct"
+
     def __init__(self, parent, namespace, dom):
         super(Struct, self).__init__(parent, namespace, dom)
 
@@ -601,6 +613,9 @@ class EnumLike(DBusType):
         return str
 
 class Enum(EnumLike):
+
+    devhelp_name = "enum"
+
     def __init__(self, parent, namespace, dom):
         super(Enum, self).__init__(parent, namespace, dom)
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list