Pyolian gendoc: use some aux eolian functions to simplify templates
authorDave Andreoli <dave@gurumeditation.it>
Mon, 7 Oct 2019 18:32:05 +0000 (20:32 +0200)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 7 Oct 2019 21:06:31 +0000 (06:06 +0900)
src/scripts/gendoc/doc_macros.include
src/scripts/pyolian/eolian.py
src/scripts/pyolian/eolian_lib.py
src/scripts/pyolian/test_eolian.py

index 877b7c6..1527e09 100644 (file)
@@ -7,14 +7,8 @@ ${UNTOKENIZE(tokens=obj.summary_tokens)}$#!
    <!--(elif isinstance(obj, Implement))-->
       <!--(if obj.documentation_get(obj.function.type))-->
 ${UNTOKENIZE(tokens=obj.documentation_get(obj.function.type).summary_tokens)}$#!
-      <!--(else)-->
-         <!--(for parent_impl in obj.class_.implements)-->
-            <!--(if parent_impl.function.name == obj.function.name)-->
-               <!--(if parent_impl.documentation_get(parent_impl.function.type))-->
-${UNTOKENIZE(tokens=parent_impl.documentation_get(parent_impl.function.type).summary_tokens)}$#!
-               <!--(end)-->
-            <!--(end)-->
-         <!--(end)-->
+      <!--(elif obj.documentation_fallback)-->
+${UNTOKENIZE(tokens=obj.documentation_fallback.summary_tokens)}$#!
       <!--(end)-->
    <!--(elif obj and obj.documentation)-->
 ${UNTOKENIZE(tokens=obj.documentation.summary_tokens)}$#!
@@ -31,14 +25,8 @@ ${UNTOKENIZE(tokens=obj.description_tokens)}$#!
    <!--(elif isinstance(obj, Implement))-->
       <!--(if obj.documentation_get(obj.function.type))-->
 ${UNTOKENIZE(tokens=obj.documentation_get(obj.function.type).description_tokens)}$#!
-      <!--(else)-->
-         <!--(for parent_impl in obj.class_.implements)-->
-            <!--(if parent_impl.function.name == obj.function.name)-->
-               <!--(if parent_impl.documentation_get(parent_impl.function.type))-->
-${UNTOKENIZE(tokens=parent_impl.documentation_get(parent_impl.function.type).description_tokens)}$#!
-               <!--(end)-->
-            <!--(end)-->
-         <!--(end)-->
+      <!--(elif obj.documentation_fallback)-->
+${UNTOKENIZE(tokens=obj.documentation_fallback.description_tokens)}$#!
       <!--(end)-->
    <!--(elif obj and obj.documentation)-->
 ${UNTOKENIZE(tokens=obj.documentation.description_tokens)}$#!
@@ -55,14 +43,8 @@ ${UNTOKENIZE(tokens=obj.documentation.description_tokens)}$#!
    <!--(elif isinstance(obj, Implement))-->
       <!--(if obj.documentation_get(obj.function.type))-->
 //Since ${obj.documentation_get(obj.function.type).since}$//
-      <!--(else)-->
-         <!--(for parent_impl in obj.class_.implements)-->
-            <!--(if parent_impl.function.name == obj.function.name)-->
-               <!--(if parent_impl.documentation_get(parent_impl.function.type))-->
-//Since ${parent_impl.documentation_get(parent_impl.function.type).since}$//
-               <!--(end)-->
-            <!--(end)-->
-         <!--(end)-->
+      <!--(elif obj.documentation_fallback)-->
+//Since ${obj.documentation_fallback.since}$//
       <!--(end)-->
    <!--(elif obj and obj.documentation and obj.documentation.since)-->
 //Since ${obj.documentation.since}$//
index 58c3105..70496de 100644 (file)
@@ -1012,6 +1012,11 @@ class Implement(Object):
         return "<eolian.Implement '{0.name}'>".format(self)
 
     @cached_property
+    def parent(self):
+        c_impl = lib.eolian_aux_implement_parent_get(self)
+        return Implement(c_impl) if c_impl else None
+
+    @cached_property
     def class_(self):
         c_cls = lib.eolian_implement_class_get(self)
         return Class(c_cls) if c_cls else None
@@ -1022,10 +1027,14 @@ class Implement(Object):
         return Function(c_func) if c_func else None
 
     def documentation_get(self, ftype=Eolian_Function_Type.METHOD):
-        # something strange in this eolian api :/  (see 'documentation' property
-        c_doc = lib.eolian_implement_documentation_get(self, ftype)
+        # c_doc = lib.eolian_implement_documentation_get(self, ftype)
+        c_doc = lib.eolian_aux_implement_documentation_get(self, ftype)
+        return Documentation(c_doc) if c_doc else None
+
+    @cached_property
+    def documentation_fallback(self):
+        c_doc = lib.eolian_aux_implement_documentation_fallback_get(self)
         return Documentation(c_doc) if c_doc else None
-    # TODO implement util properties for documentation_get
 
     def is_auto(self, ftype=Eolian_Function_Type.METHOD):
         return bool(lib.eolian_implement_is_auto(self, ftype))
index e73c37e..10098bf 100644 (file)
@@ -706,3 +706,17 @@ lib.eolian_error_documentation_get.restype = c_void_p
 # EAPI Eina_Bool eolian_error_is_extern(const Eolian_Error *err);
 lib.eolian_error_is_extern.argtypes = (c_void_p,)
 lib.eolian_error_is_extern.restype = c_bool
+
+
+#  Eolian Aux  ################################################################
+# EAPI const Eolian_Implement *eolian_aux_implement_parent_get(const Eolian_Implement *impl);
+lib.eolian_aux_implement_parent_get.argtypes = (c_void_p,)
+lib.eolian_aux_implement_parent_get.restype = c_void_p
+
+# EAPI const Eolian_Documentation *eolian_aux_implement_documentation_get(const Eolian_Implement *impl, Eolian_Function_Type ftype);
+lib.eolian_aux_implement_documentation_get.argtypes = (c_void_p, c_int)
+lib.eolian_aux_implement_documentation_get.restype = c_void_p
+
+# EAPI const Eolian_Documentation *eolian_aux_implement_documentation_fallback_get(const Eolian_Implement *impl);
+lib.eolian_aux_implement_documentation_fallback_get.argtypes = (c_void_p,)
+lib.eolian_aux_implement_documentation_fallback_get.restype = c_void_p
index 0271e50..3a10169 100755 (executable)
@@ -407,6 +407,14 @@ class TestEolianImplement(unittest.TestCase):
         self.assertFalse(im.is_prop_get)
         self.assertFalse(im.is_property)
         self.assertTrue(im.is_method)
+        self.assertIsNone(im.parent)
+
+    def test_implement_parent(self):
+        cls = eolian_db.class_by_name_get('Efl.Ui.Button')
+        im = [im for im in cls.implements if im.short_name == 'content_unset'][0]
+        self.assertIsInstance(im, eolian.Implement)
+        self.assertEqual(im.name, 'Efl.Content.content_unset')  # TODO is this right??
+        self.assertEqual(im.parent.name, 'Efl.Content.content_unset')
 
 
 class TestEolianEvent(unittest.TestCase):