[gobject-introspection] docwriter/gjs: add support for shadowed function names



commit 5420484595418dc801d6f01ac02658f10255e699
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Feb 25 02:45:15 2014 +0100

    docwriter/gjs: add support for shadowed function names
    
    If a function is shadowed, omit it from the documentation, and
    if a function shadows, uses the new name.

 giscanner/doctemplates/Gjs/function.tmpl |    2 +-
 giscanner/docwriter.py                   |   20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/doctemplates/Gjs/function.tmpl b/giscanner/doctemplates/Gjs/function.tmpl
index 012978a..8e9d741 100644
--- a/giscanner/doctemplates/Gjs/function.tmpl
+++ b/giscanner/doctemplates/Gjs/function.tmpl
@@ -21,7 +21,7 @@
 <%block name="synopsis">
   <synopsis><code mime="text/x-gjs">
 function \
-${node.name}(\
+${node.name if node.shadows is None else node.shadows}(\
 ${', '.join('%s: %s' % (arg.argname, formatter.format_type(arg.type, True)) for arg in 
formatter.get_in_parameters(node))}\
 ): ${formatter.format_out_parameters(node)} {
     // Gjs wrapper for ${node.symbol}()
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index 40c5fbe..c18e822 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -45,10 +45,15 @@ def make_page_id(node, recursive=False):
         parent = None
 
     if parent is None:
-        return '%s.%s' % (node.namespace.name, node.name)
+        if isinstance(node, ast.Function) and node.shadows:
+            return '%s.%s' % (node.namespace.name, node.shadows)
+        else:
+            return '%s.%s' % (node.namespace.name, node.name)
 
     if isinstance(node, (ast.Property, ast.Signal, ast.VFunction, ast.Field)):
         return '%s-%s' % (make_page_id(parent, recursive=True), node.name)
+    elif isinstance(node, ast.Function) and node.shadows:
+        return '%s.%s' % (make_page_id(parent, recursive=True), node.shadows)
     else:
         return '%s.%s' % (make_page_id(parent, recursive=True), node.name)
 
@@ -468,6 +473,9 @@ class DocFormatterIntrospectableBase(DocFormatter):
         if not getattr(node, "introspectable", True):
             return False
 
+        if isinstance(node, ast.Function) and node.shadowed_by is not None:
+            return False
+
         return super(DocFormatterIntrospectableBase, self).should_render_node(node)
 
 
@@ -702,12 +710,16 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
             return self.format_fundamental_type(type_.target_fundamental)
 
     def format_function_name(self, func):
+        name = func.name
+        if func.shadows:
+            name = func.shadows
+
         if func.is_method:
-            return "%s.prototype.%s" % (self.format_page_name(func.parent), func.name)
+            return "%s.prototype.%s" % (self.format_page_name(func.parent), name)
         elif func.parent is not None:
-            return "%s.%s" % (self.format_page_name(func.parent), func.name)
+            return "%s.%s" % (self.format_page_name(func.parent), name)
         else:
-            return func.name
+            return name
 
     def format_page_name(self, node):
         if isinstance(node, (ast.Field, ast.Property)):


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