[gobject-introspection] docwriter: Introduce a base formatter for introspectable languages



commit f5d315c9d2ad64ffe096e13367f934608e42b817
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Feb 14 22:24:52 2013 -0500

    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.

 giscanner/docwriter.py |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index 9d0d5b8..9b27e0d 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


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