summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.com>2012-02-20 11:30:21 +0100
committerTomeu Vizoso <tomeu.vizoso@collabora.com>2012-02-20 11:30:21 +0100
commit1ff74fb0a469f3f1f00692e20834cce3bd7b212a (patch)
treeb22c1451cb46b47e692d32199d97d825c4b766dc
parent9f81ad162fd382a4e6a969d20da929b9c5aded4b (diff)
downloadgobject-introspection-1ff74fb0a469f3f1f00692e20834cce3bd7b212a.tar.gz
g-ir-doc-tool: Add details for properties in Python
-rw-r--r--giscanner/mallard-Python-property.tmpl3
-rw-r--r--giscanner/mallardwriter.py16
2 files changed, 19 insertions, 0 deletions
diff --git a/giscanner/mallard-Python-property.tmpl b/giscanner/mallard-Python-property.tmpl
index 3570a7fe..c018e143 100644
--- a/giscanner/mallard-Python-property.tmpl
+++ b/giscanner/mallard-Python-property.tmpl
@@ -9,5 +9,8 @@
<title type="link" role="topic">${node.name}</title>
</info>
<title>${namespace.name}.${node.parent.name}:${node.name}</title>
+<synopsis><code mime="text/x-python">
+"${node.name}" ${formatter.format_type(node.type)} : ${formatter.format_property_flags(node)}
+</code></synopsis>
${formatter.format(node.doc)}
</page>
diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py
index 9ae7aa5a..fcfd2368 100644
--- a/giscanner/mallardwriter.py
+++ b/giscanner/mallardwriter.py
@@ -77,6 +77,19 @@ class MallardFormatter(object):
def format_type(self, type_):
raise NotImplementedError
+ def format_property_flags(self, property_):
+ flags = []
+ if property_.readable:
+ flags.append("Read")
+ if property_.writable:
+ flags.append("Write")
+ if property_.construct:
+ flags.append("Construct")
+ if property_.construct_only:
+ flags.append("Construct Only")
+
+ return " / ".join(flags)
+
class MallardFormatterC(MallardFormatter):
def format_type(self, type_):
@@ -95,6 +108,9 @@ class MallardFormatterPython(MallardFormatter):
def format_type(self, type_):
if isinstance(type_, ast.Array):
return '[' + self.format_type(type_.element_type) + ']'
+ elif isinstance(type_, ast.Map):
+ return '{%s: %s}' % (self.format_type(type_.key_type),
+ self.format_type(type_.value_type))
elif type_.target_giname is not None:
return type_.target_giname
else: