summaryrefslogtreecommitdiff
path: root/giscanner/girwriter.py
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-05-21 10:47:11 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2013-10-08 20:56:10 +0200
commit556bb8ee3402b92e2936ed3b594cdfc0b04a9db5 (patch)
tree42c4f67dac6d6775c7e4148e374188bf517effee /giscanner/girwriter.py
parent07ad34a094cb00aef16250dfbf05d6eef05c3aff (diff)
downloadgobject-introspection-556bb8ee3402b92e2936ed3b594cdfc0b04a9db5.tar.gz
giscanner: fix description field storage in .gir files
GTK-Doc description fields for tags can contain multiple lines and even multiple paragraphs. Whitespace cannot be preserved in XML attributes, so we move the "deprecated" description text into a "<doc-deprecated />" element right next to where we already have the "<doc />" element. Keep the "deprecated" attribute around for backwards compatibility though, but set its value to "1" (analogous to the "writable", "contruct", etc attributes) if the annotated symbol is marked as deprecated. While at it, add <doc-version /> and <doc-stability /> which was not yet available in the .gir files... This takes care of the "Since:", "Stability:" and "Deprecated:" GTK-Doc tags. Nothing needs to be done for the "Returns:" tag as as we already write a "<doc />" child element on "<return-value />".
Diffstat (limited to 'giscanner/girwriter.py')
-rw-r--r--giscanner/girwriter.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index e7af2533..e5841ec1 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -125,18 +125,37 @@ class GIRWriter(XMLWriter):
def _write_generic(self, node):
for key, value in node.attributes:
self.write_tag('attribute', [('name', key), ('value', value)])
+
if hasattr(node, 'doc') and node.doc:
self.write_tag('doc', [('xml:space', 'preserve')],
node.doc)
+ if hasattr(node, 'version_doc') and node.version_doc:
+ self.write_tag('doc-version', [('xml:space', 'preserve')],
+ node.version_doc)
+
+ if hasattr(node, 'deprecated_doc') and node.deprecated_doc:
+ self.write_tag('doc-deprecated', [('xml:space', 'preserve')],
+ node.deprecated_doc)
+
+ if hasattr(node, 'stability_doc') and node.stability_doc:
+ self.write_tag('doc-stability', [('xml:space', 'preserve')],
+ node.stability_doc)
+
def _append_node_generic(self, node, attrs):
if node.skip or not node.introspectable:
attrs.append(('introspectable', '0'))
+
+ if node.deprecated or node.deprecated_doc:
+ # The deprecated attribute used to contain node.deprecated_doc as an attribute. As
+ # an xml attribute cannot preserve whitespace, deprecated_doc has been moved into
+ # it's own tag, written in _write_generic() above. We continue to write the deprecated
+ # attribute for backwards compatibility
+ attrs.append(('deprecated', '1'))
+
if node.deprecated:
- attrs.append(('deprecated', node.deprecated))
- if node.deprecated_version:
- attrs.append(('deprecated-version',
- node.deprecated_version))
+ attrs.append(('deprecated-version', node.deprecated))
+
if node.stability:
attrs.append(('stability', node.stability))