diff options
author | David Laban <david.laban@collabora.co.uk> | 2011-07-14 22:04:19 -0400 |
---|---|---|
committer | David Laban <david.laban@collabora.co.uk> | 2011-07-14 22:25:56 -0400 |
commit | 3b8f91b728d59fa717ee5abbd54ca21b523124ac (patch) | |
tree | 73636bb8e15a511568f2d46d0da605a00ccab572 /tools | |
parent | a8b99977a2cd3b722db1e4bbdcdabd9ad588e9d7 (diff) |
<tp:value-ref> for semantic enumvalues.
This should ensure that our enum value names don't go out of sync with the
references to them.
Note that the links don't *quite* go to the actual value, but it should be within
view once the link is clicked. This is not a regression.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/specparser.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/specparser.py b/tools/specparser.py index 697d4aff..d21eb7f9 100644 --- a/tools/specparser.py +++ b/tools/specparser.py @@ -305,6 +305,24 @@ class Base(object): n.namespaceURI = None n.setAttribute('href', t.get_url()) + # rewrite <tp:value-ref> + for n in node.getElementsByTagNameNS(XMLNS_TP, 'value-ref'): + type_name = n.getAttribute('type') + assert type_name, "value-ref must have a type attribute" + t = spec.lookup_type(type_name) + assert isinstance(t, EnumLike), ("%s is not an enum or flags type" + % type_name) + n.tagName = 'a' + n.namespaceURI = None + n.setAttribute('href', t.get_url()) + name = getText(n) + short_names = [val.short_name for val in t.values] + if name not in short_names: + raise ValueError("'%s' is not a valid value of '%s'. " + "Valid values are %s" % + (name, type_name, short_names)) + n.childNodes[0].data = "%s_%s" % (type_name, type) + # rewrite <tp:error-ref> error_ns = spec.spec_namespace + '.Error.' for n in node.getElementsByTagNameNS(XMLNS_TP, 'error-ref'): |