g-ir-doc-tool: Show how to construct instances in the Class page
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Mon, 20 Feb 2012 11:21:41 +0000 (12:21 +0100)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Mon, 20 Feb 2012 11:21:41 +0000 (12:21 +0100)
giscanner/mallard-Python-class.tmpl
giscanner/mallardwriter.py
tests/doctool/GIRepository-2.0-Python-expected/GIRepository.Repository.page

index 1dd8644dcbf70ff71061a1ac3a33d93668a0dfbd..d45b0ab67d8a819937844516c1a3938cd4397ed2 100644 (file)
@@ -21,11 +21,19 @@ ${formatter.format(node.doc)}
       </item>
     </tree>
   </synopsis>
-  <links type="topic" ui:expanded="yes"
-         api:type="function" api:mime="text/x-python"
-         groups="constructor" style="linklist">
-    <title>Constructors</title>
-  </links>
+  <p>Constructor</p>
+  <synopsis><code mime="text/x-python">
+${formatter.to_underscores(node.name).lower()} = ${node.name}(\
+% for property_, ix in zip(node.properties, range(len(node.properties))):
+% if property_.construct or property_.construct_only or property_.writable:
+${property_.name.replace('-', '_')}=value\
+% if ix != len(node.properties) - 1:
+, \
+% endif
+% endif
+% endfor
+)\
+  </code></synopsis>
   <links type="topic" ui:expanded="yes"
          api:type="function" api:mime="text/x-python"
          groups="method" style="linklist">
index fcfd236861edf9c0b6e19c84488c4e7eafea3e6f..351a8c1f356420a15e9fb364ff3326656b1a6fd0 100644 (file)
@@ -30,6 +30,7 @@ from mako.template import Template
 from mako.runtime import supports_caller
 
 from . import ast
+from .utils import to_underscores
 
 class MallardFormatter(object):
     def __init__(self, namespace):
@@ -90,6 +91,9 @@ class MallardFormatter(object):
 
         return " / ".join(flags)
 
+    def to_underscores(self, string):
+        return to_underscores(string)
+
 class MallardFormatterC(MallardFormatter):
 
     def format_type(self, type_):
index b194a079d9e6862542d3b0a0ae6698d7fc0fa44f..eb466270b2b55dfbbbdfea4e36adb928c31d065e 100644 (file)
       </item>
     </tree>
   </synopsis>
-  <links type="topic" ui:expanded="yes"
-         api:type="function" api:mime="text/x-python"
-         groups="constructor" style="linklist">
-    <title>Constructors</title>
-  </links>
+  <p>Constructor</p>
+  <synopsis><code mime="text/x-python">
+repository = Repository()  </code></synopsis>
   <links type="topic" ui:expanded="yes"
          api:type="function" api:mime="text/x-python"
          groups="method" style="linklist">