summaryrefslogtreecommitdiff
path: root/giscanner/docwriter.py
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2015-12-12 18:13:56 -0800
committerrockon999 <rockon999@users.noreply.github.com>2018-08-06 02:53:45 -0500
commit2635fb9fa3e223ae299a4306acf9dc85c6745637 (patch)
tree311c05bf769bafb0ca702e25ce633ab00d8e5663 /giscanner/docwriter.py
parentc7014b82d930d10e2dc88cd2ab9eb880f78e69c1 (diff)
downloadgobject-introspection-2635fb9fa3e223ae299a4306acf9dc85c6745637.tar.gz
devdocs: Don't render private fields
Skip private fields such as "priv" and "parent_instance". Unfortunately not all private structure and parent instance fields are marked private, and not all of them are named "priv" or "parent_instance". This also includes fields that are contained within anonymous unions.
Diffstat (limited to 'giscanner/docwriter.py')
-rw-r--r--giscanner/docwriter.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index d17e8700..e1d3149e 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -543,6 +543,37 @@ class DocFormatter(object):
types += [t for t in parent_chain if t is not node]
return types
+ def is_private_field(self, node, f):
+ """Returns whether @f is a private field of @node (including a heuristic
+ that tries to determine whether the field is the parent instance field
+ or a private pointer but not marked as such.)"""
+
+ if f.private:
+ return True
+ if f.anonymous_node:
+ return True
+ if f.name == 'g_type_instance':
+ return True # this field on GObject is not exposed
+
+ field_typenode = self._transformer.lookup_typenode(f.type)
+ if not field_typenode:
+ return False
+
+ if getattr(field_typenode, 'disguised', False):
+ return True # guess that it's a pointer to a private struct
+ # this also catches fields of type GdkAtom, since that is disguised
+ # as well. Not sure whether that's correct or not.
+
+ if not isinstance(node, ast.Class):
+ return False # parent instance heuristics only apply to classes
+
+ if node.parent_type:
+ parent_typenode = self._transformer.lookup_typenode(node.parent_type)
+ if field_typenode == parent_typenode:
+ return True # guess that it's a parent instance field
+
+ return False
+
def format_prerequisites(self, node):
assert isinstance(node, ast.Interface)