[gobject-introspection/mallard-templates] g-ir-doc-tool: Show how to construct instances in the Class page



commit fb98a4f19da972709ac56b89a1184624e23bc224
Author: Tomeu Vizoso <tomeu vizoso collabora com>
Date:   Mon Feb 20 12:21:41 2012 +0100

    g-ir-doc-tool: Show how to construct instances in the Class page

 giscanner/mallard-Python-class.tmpl                |   18 +++++++++++++-----
 giscanner/mallardwriter.py                         |    4 ++++
 .../GIRepository.Repository.page                   |    8 +++-----
 3 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/giscanner/mallard-Python-class.tmpl b/giscanner/mallard-Python-class.tmpl
index 1dd8644..d45b0ab 100644
--- a/giscanner/mallard-Python-class.tmpl
+++ b/giscanner/mallard-Python-class.tmpl
@@ -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">
diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py
index fcfd236..351a8c1 100644
--- a/giscanner/mallardwriter.py
+++ b/giscanner/mallardwriter.py
@@ -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_):
diff --git a/tests/doctool/GIRepository-2.0-Python-expected/GIRepository.Repository.page b/tests/doctool/GIRepository-2.0-Python-expected/GIRepository.Repository.page
index b194a07..eb46627 100644
--- a/tests/doctool/GIRepository-2.0-Python-expected/GIRepository.Repository.page
+++ b/tests/doctool/GIRepository-2.0-Python-expected/GIRepository.Repository.page
@@ -18,11 +18,9 @@
       </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">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]