From a127723d1fc6a29d1a63b96d72341c282142b423 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 13 Dec 2010 18:48:24 +0000 Subject: Update tooling to match telepathy-spec HEAD, and add support for D-Bus annotations --- doc/templates/devhelp.devhelp2 | 4 +- doc/templates/index.html | 16 ++++--- doc/templates/interface.html | 99 ++++++++---------------------------------- doc/templates/oldspec.html | 11 ----- doc/templates/style.css | 64 ++++++++++++++++++--------- spec/Player_Node.xml | 69 ----------------------------- spec/Root_Node.xml | 6 --- spec/TrackList_Node.xml | 5 --- tools/specparser.py | 83 +++++++++++++++++++++++++++++++++-- 9 files changed, 154 insertions(+), 203 deletions(-) delete mode 100644 doc/templates/oldspec.html diff --git a/doc/templates/devhelp.devhelp2 b/doc/templates/devhelp.devhelp2 index 8bbdb3a..798a8c2 100644 --- a/doc/templates/devhelp.devhelp2 +++ b/doc/templates/devhelp.devhelp2 @@ -8,9 +8,11 @@ #for $obj in $spec.everything.values() + $spec.types.values() + $spec.errors.values() - +#end for #end for diff --git a/doc/templates/index.html b/doc/templates/index.html index 4e44f31..a749f6f 100644 --- a/doc/templates/index.html +++ b/doc/templates/index.html @@ -15,14 +15,16 @@

Version $spec.version

-

- #echo '
'.join($spec.copyrights) -

- -
- #for $para in $spec.license -

$para

+ #def output($items, $external_ul) diff --git a/doc/templates/interface.html b/doc/templates/interface.html index 222057c..3420ce8 100644 --- a/doc/templates/interface.html +++ b/doc/templates/interface.html @@ -82,6 +82,7 @@ #if $property.type: ($property.get_type().short_name) $property.get_access() + $property.get_flag_summary() #if $property.deprecated: (deprecated) @@ -160,7 +161,7 @@ #end if #if $interface.causes_havoc -
WARNING: +
WARNING: This interface is $interface.causes_havoc and is likely to cause havoc to your API/ABI if bindings are generated. Do not include this interface in libraries that care about compatibility. @@ -170,10 +171,16 @@ $interface.get_changed() $interface.get_deprecated() - #if $interface.requires + #if $interface.requires or $interface.xor_requires
Objects implementing this interface must also implement:
    + #for $req in $interface.get_xor_requires() +
  • + #echo " or ".join(['' + x.name + '' for x in req]) +
  • + #end for #for $req in $interface.get_requires()
  • $req.name
  • #end for @@ -193,13 +200,14 @@

    Methods

    #for $method in $interface.methods
    - + (Permalink)

    $method.short_name ($method.get_in_args()) → $method.get_out_args()

    $method.get_added() $method.get_changed() $method.get_deprecated() + $method.get_no_reply() #if $method.in_args
    @@ -265,7 +273,7 @@

    Signals

    #for $signal in $interface.signals
    - + (Permalink)

    $signal.short_name ($signal.get_args())

    @@ -302,11 +310,13 @@

    Properties

    - Accessed using the org.freedesktop.DBus.Properties interface. + Accessed using the org.freedesktop.DBus.Properties + interface.
    #for $property in $interface.properties
    - + (Permalink)

    $property.short_name — $property.dbus_type @@ -317,86 +327,13 @@ $property.get_added() $property.get_changed() $property.get_deprecated() + $property.get_emits_changed() $property.get_docstring()

    #end for
    #end if - #if $interface.tpproperties -
    - -

    Telepathy Properties

    -
    - Accessed using the org.freedesktop.Telepathy.Properties interface. -
    - #for $property in $interface.tpproperties -
    - - (Permalink) -

    - $property.short_name — $property.dbus_type - #if $property.type: ($property.get_type().short_name) -

    - $property.get_added() - $property.get_changed() - $property.get_deprecated() - $property.get_docstring() -
    - #end for -
    - #end if - - #if $interface.contact_attributes -
    - -

    Contact Attributes

    -
    - Attributes that a contact can have, accessed with the - org.freedesktop.Telepathy.Connection.Interface.Contacts interface. -
    - #for $token in $interface.contact_attributes -
    - - (Permalink) -

    - $token.name — $token.dbus_type - #if $token.type: ($token.get_type().short_name) -

    - $token.get_added() - $token.get_changed() - $token.get_deprecated() - $token.get_docstring() -
    - #end for -
    - #end if - - #if $interface.handler_capability_tokens -
    - -

    Handler Capability Tokens

    -
    - Tokens representing capabilities that a Client.Handler can have. -
    - #for $token in $interface.handler_capability_tokens -
    - - (Permalink) -

    - $token.name - #if $token.is_family - (etc.) - #end if -

    - $token.get_added() - $token.get_changed() - $token.get_deprecated() - $token.get_docstring() -
    - #end for -
    - #end if #if $interface.types
    @@ -404,7 +341,7 @@

    Types

    #for $type in $interface.types
    - + $type.get_type_name() (Permalink)

    $type.short_name — $type.dbus_type diff --git a/doc/templates/oldspec.html b/doc/templates/oldspec.html deleted file mode 100644 index fc3cf89..0000000 --- a/doc/templates/oldspec.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - MPRIS D-Bus Interface Specification - - -

    MPRIS D-Bus Interface Specification

    -

    The MPRIS specification has moved.

    - - diff --git a/doc/templates/style.css b/doc/templates/style.css index 2cc644d..a02d743 100644 --- a/doc/templates/style.css +++ b/doc/templates/style.css @@ -141,12 +141,18 @@ div.access { margin-left: 1ex; } -div.summary { +div.summary, div.legal { padding: 0.5ex; background-color: #eeeeec; border: 1px solid #d3d7cf; } +div.legal ul { + list-style: none; + padding-left: 0; + margin-left: 0; +} + table.summary { margin: 1ex; font-size: small; @@ -177,39 +183,65 @@ div.docstring { margin: 1ex; } -div.added { - border-left: 2px solid #4e9a06; +div.annotation { + border-left: 2px solid; margin: 1ex; padding-left: 1ex; } +div.annotation span.version, span.warning, span.note { + font-weight: bold; +} + +div.added { + border-left-color: #4e9a06; +} + div.added span.version { color: #4e9a06; - font-weight: bold; } div.changed { - border-left: 2px solid #8f5902; - margin: 1ex; - padding-left: 1ex; + border-left-color: #8f5902; } div.changed span.version { color: #8f5902; - font-weight: bold; } div.deprecated, div.havoc { - border-left: 2px solid #a40000; - margin: 1ex; - padding-left: 1ex; + border-left-color: #a40000; } div.deprecated span.version, +div.deprecated.no-version, span.warning { color: #a40000; - font-weight: bold; +} + +div.connection-parameter { + border-left-color: #0000a4; +} + +div.connection-parameter .note { + color: #0000a4; +} + +div.emits-changed { + border-left-color: #17BBC3; +} + +div.immutable { + border-left-color: #02598f; +} + +div.no-reply { + border-left-color: #9C11A1; +} + +div.requestable { + border-left-color: #598f02; } div.rationale { @@ -296,14 +328,6 @@ h3.chapter { font-weight: bold; } -div.license { - border: 1px solid black; - background: #ddd; - padding: 1em; - margin-top: 1em; - margin-bottom: 1em; -} - div.main { margin-bottom: 3em; } diff --git a/spec/Player_Node.xml b/spec/Player_Node.xml index 4daa00c..06ba4f2 100644 --- a/spec/Player_Node.xml +++ b/spec/Player_Node.xml @@ -304,11 +304,6 @@

    May be "Playing", "Paused" or "Stopped".

    -

    - When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

    @@ -324,11 +319,6 @@
  • "Playlist" if the playback loops through a list of tracks

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

This property is optional, and clients should deal with NotSupported errors gracefully. @@ -368,11 +358,6 @@ Clients are recommended to only use sensible fractions or multiples of 1 (eg: 0.5, 0.25, 1.5, 2.0, etc).

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

This allows clients to display (reasonably) accurate progress bars @@ -391,11 +376,6 @@ progressing linearly through a playlist, while true means playback is progressing through a playlist in some other order.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

This property is optional, and clients should deal with NotSupported errors gracefully. @@ -420,11 +400,6 @@

See the type documentation for more details.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

@@ -441,11 +416,6 @@ false, attempting to set this property should have no effect and raise an error.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

@@ -468,10 +438,6 @@ Rate property, the Seeked signal is emited.

-

- The org.freedesktop.DBus.Properties.PropertiesChanged - is not emited when this property changes. -

@@ -490,11 +456,6 @@ to 0.0.

This value should always be 1.0 or less.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

@@ -510,11 +471,6 @@

This value should always be 1.0 or greater.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

@@ -525,11 +481,6 @@ Whether the client can call the Next method on this interface and expect the current track to change.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

If CanControl is false, this property should also be @@ -557,11 +508,6 @@ Previous method on this interface and expect the current track to change.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

If CanControl is false, this property should also be @@ -596,11 +542,6 @@ CanControl is true), this should be true.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

If CanControl is false, this property should also be @@ -630,11 +571,6 @@ CanControl is true), this should be true.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

If CanControl is false, this property should also be @@ -658,11 +594,6 @@ SetPosition. This may be different for different tracks.

-

- When this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new value. -

If CanControl is false, this property should also be diff --git a/spec/Root_Node.xml b/spec/Root_Node.xml index b9ca580..191acaa 100644 --- a/spec/Root_Node.xml +++ b/spec/Root_Node.xml @@ -3,12 +3,6 @@ - - Every time the value of this interface's properties changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited with the new values. - -

diff --git a/spec/TrackList_Node.xml b/spec/TrackList_Node.xml index 82079b4..4663ae2 100644 --- a/spec/TrackList_Node.xml +++ b/spec/TrackList_Node.xml @@ -229,11 +229,6 @@ RemoveTrack will have no effect, and may raise a NotSupported error.

-

- Every time this property changes, the - org.freedesktop.DBus.Properties.PropertiesChanged - signal is emited. -

diff --git a/tools/specparser.py b/tools/specparser.py index d4eab19..37ded16 100644 --- a/tools/specparser.py +++ b/tools/specparser.py @@ -75,6 +75,13 @@ def getChildrenByName(dom, namespace, name): n.localName == name, dom.childNodes) +def getChildrenByNameAndAttribute(dom, namespace, name, attribute, value): + return filter(lambda n: n.nodeType == n.ELEMENT_NODE and \ + n.namespaceURI == namespace and \ + n.localName == name and \ + n.getAttribute(attribute) == value, + dom.childNodes) + def getOnlyChildByName(dom, namespace, name): kids = getChildrenByName(dom, namespace, name) @@ -88,6 +95,19 @@ def getOnlyChildByName(dom, namespace, name): return kids[0] +def getAnnotationByName(dom, name): + kids = getChildrenByNameAndAttribute(dom, None, 'annotation', 'name', name) + + if len(kids) == 0: + return None + + if len(kids) > 1: + raise WrongNumberOfChildren( + '<%s> node should have at most one %s annotation' % + (dom.tagName, name)) + + return kids[0].getAttribute('value') + def getNamespace(n): if n.namespaceURI is not None: return n.namespaceURI @@ -142,6 +162,9 @@ class Base(object): self.docstring = getOnlyChildByName(dom, XMLNS_TP, 'docstring') self.added = getOnlyChildByName(dom, XMLNS_TP, 'added') self.deprecated = getOnlyChildByName(dom, XMLNS_TP, 'deprecated') + self.is_deprecated = True + if self.deprecated == None: + self.is_deprecated = getAnnotationByName(dom, 'org.freedesktop.DBus.Deprecated') == 'true' self.changed = getChildrenByName(dom, XMLNS_TP, 'changed') @@ -211,8 +234,14 @@ class Base(object): "Added in %s.") def get_deprecated(self): - return self._get_generic_with_ver(self.deprecated, 'deprecated', - "Deprecated since %s.") + if self.deprecated is None: + if self.is_deprecated: + return '
Deprecated.
' + else: + return '' + else: + return self._get_generic_with_ver(self.deprecated, 'deprecated', + "Deprecated since %s.") def get_changed(self): return '\n'.join(map(lambda n: @@ -480,6 +509,8 @@ class Method(DBusConstruct): self.possible_errors = build_list(self, PossibleError, None, dom.getElementsByTagNameNS(XMLNS_TP, 'error')) + self.no_reply = getAnnotationByName(dom, 'org.freedesktop.DBus.Method.NoReply') == 'true' + def get_in_args(self): return ', '.join(map(lambda a: a.spec_name(), self.in_args)) @@ -489,6 +520,13 @@ class Method(DBusConstruct): else: return 'nothing' + def get_no_reply(self): + if self.no_reply: + return '
' \ + 'The caller should not expect a reply when calling this method.
' + else: + return '' + def check_consistency(self): for x in self.in_args: x.check_consistency() @@ -557,6 +595,11 @@ class Property(DBusConstruct, Typed): ACCESS_READWRITE = ACCESS_READ | ACCESS_WRITE + EMITS_CHANGED_UNKNOWN = 0 + EMITS_CHANGED_NONE = 1 + EMITS_CHANGED_UPDATES = 2 + EMITS_CHANGED_INVALIDATES = 3 + def __init__(self, parent, namespace, dom): super(Property, self).__init__(parent, namespace, dom) @@ -581,6 +624,21 @@ class Property(DBusConstruct, Typed): self.requestable = requestable != '' self.sometimes_requestable = requestable == 'sometimes' + # According to the D-Bus specification, EmitsChangedSignal defaults + # to true, but - realistically - this cannot be assumed for old specs. + # As a result, we treat the absence of the annotation as "unknown". + emits_changed = getAnnotationByName(dom, 'org.freedesktop.DBus.Property.EmitsChangedSignal') + if emits_changed is None: + emits_changed = getAnnotationByName(dom.parentNode, 'org.freedesktop.DBus.Property.EmitsChangedSignal') + if emits_changed == 'true': + self.emits_changed = self.EMITS_CHANGED_UPDATES; + elif emits_changed == 'invalidates': + self.emits_changed = self.EMITS_CHANGED_INVALIDATES; + elif emits_changed == 'false': + self.emits_changed = self.EMITS_CHANGED_NONE; + else: + self.emits_changed = self.EMITS_CHANGED_UNKNOWN; + def get_access(self): if self.access & self.ACCESS_READ and self.access & self.ACCESS_WRITE: return 'Read/Write' @@ -604,6 +662,25 @@ class Property(DBusConstruct, Typed): return ', '.join(descriptions) + def get_emits_changed(self): + if self.emits_changed == self.EMITS_CHANGED_UPDATES: + return '
' \ + 'When this property changes, the ' \ + 'org.freedesktop.DBus.Properties.PropertiesChanged ' \ + 'signal is emitted with the new value.
'; + elif self.emits_changed == self.EMITS_CHANGED_INVALIDATES: + return '
' \ + 'When this property changes, the ' \ + 'org.freedesktop.DBus.Properties.PropertiesChanged ' \ + 'signal is emitted, but the new value is not sent.
'; + elif self.emits_changed == self.EMITS_CHANGED_NONE: + return '
' \ + 'The ' \ + 'org.freedesktop.DBus.Properties.PropertiesChanged ' \ + 'signal is not emitted when this property changes.
'; + else: + return ''; + class AwkwardTelepathyProperty(Typed): def get_type_name(self): return 'Telepathy Property' @@ -773,10 +850,10 @@ WARNING: Interface not known: '%s' def check_for_odd_children(self, dom): expected = [ + (None, 'annotation'), (None, 'method'), (None, 'property'), (None, 'signal'), - (None, 'annotation'), (XMLNS_TP, 'property'), (XMLNS_TP, 'handler-capability-token'), (XMLNS_TP, 'hct'), -- cgit v1.2.3