summaryrefslogtreecommitdiff
path: root/giscanner/docwriter.py
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2014-02-25 02:45:15 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2014-02-26 17:27:07 +0100
commit5420484595418dc801d6f01ac02658f10255e699 (patch)
tree73c12a80c6ca6401c0a5d54996e8fd463ac9d956 /giscanner/docwriter.py
parent32b6ee9bfa99b7c106958fec8ce0e64c6390c53b (diff)
downloadgobject-introspection-5420484595418dc801d6f01ac02658f10255e699.tar.gz
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.
Diffstat (limited to 'giscanner/docwriter.py')
-rw-r--r--giscanner/docwriter.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index 40c5fbed..c18e8224 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)):