[gobject-introspection/wip/docs: 4/7] docwriter: Skip lots of special kinds of parameters



commit f0d7c77e88d60bc7cf7120cfc0fc7079f03243ef
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Feb 2 11:40:51 2013 -0500

    docwriter: Skip lots of special kinds of parameters
    
    Gjs ignores all of these when constructing function signatures.

 giscanner/docwriter.py                             |   17 ++++++++++++++++-
 .../DocExamples.callback_function.page             |   14 +-------------
 2 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index be4d74f..cd72177 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -530,7 +530,22 @@ class DocFormatterGjs(DocFormatter):
             return func.name
 
     def get_parameters(self, node):
-        return node.parameters
+        skip = []
+        for param in node.parameters:
+            if param.direction == ast.PARAM_DIRECTION_OUT:
+                skip.append(param)
+            if param.closure_name is not None:
+                skip.append(node.get_parameter(param.closure_name))
+            if param.destroy_name is not None:
+                skip.append(node.get_parameter(param.destroy_name))
+            if isinstance(param.type, ast.Array) and param.type.length_param_name is not None:
+                skip.append(node.get_parameter(param.type.length_param_name))
+
+        params = []
+        for param in node.parameters:
+            if param not in skip:
+                params.append(param)
+        return params
 
 LANGUAGES = {
     "c": DocFormatterC,
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.callback_function.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.callback_function.page
index 4e3de12..cb449c7 100644
--- a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.callback_function.page
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.callback_function.page
@@ -17,21 +17,13 @@
         <api:type>DocExamples.Callback</api:type>
         <api:name>callback</api:name>
       </api:arg>
-      <api:arg>
-        <api:type>gpointer</api:type>
-        <api:name>user_data</api:name>
-      </api:arg>
-      <api:arg>
-        <api:type>GLib.DestroyNotify</api:type>
-        <api:name>destroy_notify</api:name>
-      </api:arg>
     </api:function>
 
   </info>
   <title>callback_function</title>
   
 <synopsis><code mime="text/x-gjs">
-function callback_function(callback:DocExamples.Callback, user_data:gpointer, destroy_notify:GLib.DestroyNotify):DocExamples.Enum {
+function callback_function(callback:DocExamples.Callback):DocExamples.Enum {
     // Gjs wrapper for doc_examples_callback_function()
 }
 </code></synopsis>
@@ -47,10 +39,6 @@ will expose this in different ways (e.g. Python keeps the
 <dl>
 <dt><p>callback :</p></dt>
 <dd><p>Just Call Me Maybe</p></dd>
-<dt><p>user_data :</p></dt>
-<dd><p>your stuff</p></dd>
-<dt><p>destroy_notify :</p></dt>
-<dd><p>how to get rid of <code>user_data</code></p></dd>
 <dt><p>Returns :</p></dt>
 <dd><p><link xref="DocExamples.Enum"/>.foo sometimes, <link xref="DocExamples.Enum"/>.bar other times.</p></dd>
 </dl>


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