diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-02-14 22:24:52 -0500 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-02-14 23:18:00 -0500 |
commit | f5d315c9d2ad64ffe096e13367f934608e42b817 (patch) | |
tree | 705de3d0db79adda666727b3ce232c9aa686c9bb /giscanner | |
parent | 9c8a86bb6740a3ca10eb58797d09c657acb64d4b (diff) | |
download | gobject-introspection-f5d315c9d2ad64ffe096e13367f934608e42b817.tar.gz |
docwriter: Introduce a base formatter for introspectable languages
Introspectable languages share a non-zero set of base semantics,
so it will become easier to implement these shared semantics here,
rather than copy-paste code.
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/docwriter.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index 9d0d5b8f..9b27e0d9 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -386,7 +386,14 @@ class DocFormatterC(DocFormatter): def get_parameters(self, node): return node.all_parameters -class DocFormatterPython(DocFormatter): +class DocFormatterIntrospectableBase(DocFormatter): + def should_render_node(self, node): + if isinstance(node, ast.Record) and node.is_gtype_struct_for is not None: + return False + + return True + +class DocFormatterPython(DocFormatterIntrospectableBase): language = "Python" mime_type = "text/python" @@ -400,10 +407,7 @@ class DocFormatterPython(DocFormatter): if getattr(node, "is_constructor", False): return False - if isinstance(node, ast.Record) and node.is_gtype_struct_for is not None: - return False - - return True + return super(DocFormatterPython, self).should_render_node(node) def is_method(self, node): if getattr(node, "is_method", False): @@ -467,7 +471,7 @@ class DocFormatterPython(DocFormatter): def get_parameters(self, node): return node.all_parameters -class DocFormatterGjs(DocFormatter): +class DocFormatterGjs(DocFormatterIntrospectableBase): language = "Gjs" mime_type = "text/x-gjs" @@ -477,12 +481,6 @@ class DocFormatterGjs(DocFormatter): "NULL": "null", } - def should_render_node(self, node): - if isinstance(node, ast.Record) and node.is_gtype_struct_for is not None: - return False - - return True - def is_method(self, node): if getattr(node, "is_method", False): return True |