[Telepathy-commits] [telepathy-spec/master] Support tp:added

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


---
 doc/spec/style.css           |   11 +++++++++++
 doc/templates/interface.html |   18 +++++++++++++++++-
 tools/specparser.py          |   26 +++++++++++++++++++++++---
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/doc/spec/style.css b/doc/spec/style.css
index e1d2fa5..02f3ffa 100644
--- a/doc/spec/style.css
+++ b/doc/spec/style.css
@@ -77,6 +77,17 @@ div.docstring {
 	margin: 1ex;
 }
 
+div.added {
+	border-left: 2px solid #4e9a06;
+	margin: 1ex;
+	padding-left: 1ex;
+}
+
+div.added span.version {
+	color: #4e9a06;
+	font-weight: bold;
+}
+
 div.rationale {
 	border-left: 2px solid gray;
 	margin: 1ex;
diff --git a/doc/templates/interface.html b/doc/templates/interface.html
index 7fce7ba..e66d3ab 100644
--- a/doc/templates/interface.html
+++ b/doc/templates/interface.html
@@ -15,6 +15,7 @@
    #if $interface.types: | <a href="#types">Types</a>
   </div>
   <div class="main">
+    $interface.get_added_html()
     $interface.get_docstring()
 
    #if $interface.methods
@@ -24,6 +25,9 @@
     <div id="$method.name" class="inset method">
      <span class="permalink">(<a href="$method.get_url()">Permalink</a>)</span>
      <h2>$method.short_name ($method.get_in_args()) &#8594; $method.get_out_args()</h2>
+
+     $method.get_added_html()
+
      #if $method.in_args
      <div class="indent">
       <h3>Parameters</h3>
@@ -33,6 +37,7 @@
         $arg.short_name &mdash; $arg.dbus_type
         #if $arg.get_type(): (<a href="$arg.get_url()" title="$arg.get_title()">$arg.get_type().short_name</a>)
        </li>
+       $arg.get_added_html()
        $arg.get_docstring()
       #end for
       </ul>
@@ -48,6 +53,7 @@
         $arg.short_name &mdash; $arg.dbus_type
         #if $arg.get_type(): (<a href="$arg.get_url()" title="$arg.get_title()">$arg.get_type().short_name</a>)
        </li>
+       $arg.get_added_html()
        $arg.get_docstring()
       #end for
       </ul>
@@ -60,12 +66,13 @@
       <ul>
       #for $error in $method.possible_errors
        <li><a href="$error.get_url()" title="$error.get_title()">$error.get_error().short_name</a></li>
+       $error.get_added_html()
        $error.get_docstring()
       #end for
       </ul>
      </div>
      #end if
-     
+    
      $method.get_docstring()
     </div>
     #end for
@@ -79,6 +86,9 @@
     <div id="$signal.name" class="inset signal">
      <span class="permalink">(<a href="$signal.get_url()">Permalink</a>)</span>
      <h2>$signal.short_name ($signal.get_args())</h2>
+     
+     $signal.get_added_html()
+     
      #if $signal.args
      <div class="indent">
       <h3>Parameters</h3>
@@ -88,11 +98,13 @@
        $arg.short_name &mdash; $arg.dbus_type
        #if $arg.get_type(): (<a href="$arg.get_url()" title="$arg.get_title()">$arg.get_type().short_name</a>)
        </li>
+       $arg.get_added_html()
        $arg.get_docstring()
       #end for
       </ul>
      </div>
      #end if
+
      $signal.get_docstring()
     </div>
     #end for
@@ -112,6 +124,8 @@
       $property.short_name &mdash; $property.dbus_type
       #if $property.type: (<a href="$property.get_url()" title="$property.get_title()">$property.get_type().short_name</a>)
      </h2>
+
+     $property.get_added_html()
      $property.get_docstring()
     </div>
     #end for
@@ -127,6 +141,8 @@
       <h2>
        $type.short_name &mdash; $type.dbus_type
       </h2>
+
+      $type.get_added_html()
       $type.get_docstring()
       $type.get_breakdown()
      </div>
diff --git a/tools/specparser.py b/tools/specparser.py
index 1470f89..bed0c83 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -10,9 +10,12 @@ import xincludator
 XMLNS_TP = 'http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0'
 
 def getText (dom):
-    if dom.childNodes[0].nodeType == dom.TEXT_NODE:
-        return dom.childNodes[0].data
-    else:
+    try:
+        if dom.childNodes[0].nodeType == dom.TEXT_NODE:
+            return dom.childNodes[0].data
+        else:
+            return ''
+    except IndexError:
         return ''
 
 def getChildrenByName (dom, namespace, name):
@@ -46,6 +49,11 @@ class base (object):
         except IndexError:
             self.docstring = None
 
+        try:
+            self.added = getChildrenByName (dom, XMLNS_TP, 'added')[0]
+        except IndexError:
+            self.added = None
+
     def get_spec (self):
         return self.parent.get_spec ()
 
@@ -58,6 +66,18 @@ class base (object):
     def get_url (self):
         return "%s#%s" % (self.get_interface ().get_url (), self.name)
 
+    def get_added (self):
+        if self.added:
+            return (self.added.getAttribute ('version'), getText (self.added))
+        else:
+            return ''
+
+    def get_added_html (self):
+        if self.added:
+            return '<div class="added"><span class="version">Added in %s.</span>\n%s</div>' % self.get_added ()
+        else:
+            return ''
+
     def get_docstring (self):
         """Get the docstring for this node, but do node substitution to
            rewrite types, interfaces, etc. as links.
-- 
1.5.6.5




More information about the telepathy-commits mailing list