eolian: inherit since information from struct and enum to field
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>
Mon, 23 Dec 2019 22:26:33 +0000 (07:26 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 25 Dec 2019 21:11:53 +0000 (06:11 +0900)
Summary:
If a struct or enum field doesn't explicitly sets since information, then since
is inherited from struct documentation if it is available.

Reviewers: jptiz, Jaehyun_Cho, woohyun, q66

Reviewed By: q66

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8359

Differential Revision: https://phab.enlightenment.org/D10948

src/lib/eolian/eo_parser.c
src/tests/eolian/data/docs_ref.h
src/tests/eolian/data/eo_docs.eo
src/tests/eolian/eolian_parsing.c
src/tests/eolian_cxx/eolian_cxx_test_documentation.cc

index 96de7a7..253e99e 100644 (file)
@@ -536,6 +536,8 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
 qual_end:
         check_next(ls, ';');
         FILL_DOC(ls, fdef, doc);
+        if (def->doc && fdef->doc && def->doc->since && !fdef->doc->since)
+          fdef->doc->since = eina_stringshare_ref (def->doc->since);
      }
    check_match(ls, '}', '{', bline, bcolumn);
    FILL_BASE(def->base, ls, line, column, TYPEDECL);
@@ -656,6 +658,8 @@ parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
         if (want_next)
           eo_lexer_get(ls);
         FILL_DOC(ls, fdef, doc);
+        if (def->doc && fdef->doc && def->doc->since && !fdef->doc->since)
+          fdef->doc->since = eina_stringshare_ref (def->doc->since);
         if (!want_next || ls->t.token == '}')
           break;
      }
index 158b814..a00fafb 100644 (file)
@@ -29,20 +29,30 @@ typedef Eo Eo_Docs;
  */
 typedef struct _Foo
 {
-  int field1; /**< Field documentation. */
+  int field1; /**< Field documentation.
+               *
+               * @since 1.66 */
   float field2;
-  short field3; /**< Another field documentation. */
+  short field3; /**< Another field documentation.
+                 *
+                 * @since 1.66 */
 } Foo;
 
 /** Docs for enum Bar.
  *
+ * @since 1.55
+ *
  * @ingroup Bar
  */
 typedef enum
 {
   BAR_BLAH = 0,
-  BAR_FOO = 1, /**< Docs for foo. */
-  BAR_BAR = 2 /**< Docs for bar. */
+  BAR_FOO = 1, /**< Docs for foo.
+                *
+                * @since 1.55 */
+  BAR_BAR = 2 /**< Docs for bar.
+               *
+               * @since 1.55 */
 } Bar;
 
 /**
index d42cdfc..8c62559 100644 (file)
@@ -19,7 +19,9 @@ struct Foo {
 }
 
 enum Bar {
-    [[Docs for enum Bar.]]
+    [[Docs for enum Bar.
+      @since 1.55
+    ]]
     blah = 0,
     foo = 1, [[Docs for foo.]]
     bar = 2 [[Docs for bar.]]
index ac06f99..9d137dc 100644 (file)
@@ -1150,7 +1150,8 @@ EFL_START_TEST(eolian_docs)
    fail_if(strcmp(eolian_documentation_summary_get(doc),
                   "Docs for enum Bar."));
    fail_if(eolian_documentation_description_get(doc));
-   fail_if(eolian_documentation_since_get(doc));
+   fail_if(strcmp(eolian_documentation_since_get(doc),
+                  "1.55"));
 
    fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "blah")));
    fail_if(eolian_typedecl_enum_field_documentation_get(efl));
index 961519d..eb683e3 100644 (file)
@@ -279,7 +279,7 @@ EFL_START_TEST(eolian_cxx_test_struct_docs)
    doc = field_iter->documentation;
    ck_assert_str_eq(doc.summary.c_str(), "Field documentation.");
    ck_assert_str_eq(doc.description.c_str(), "");
-   ck_assert_str_eq(doc.since.c_str(), "");
+   ck_assert_str_eq(doc.since.c_str(), "1.66");
 
    field_iter++;
 
@@ -293,7 +293,7 @@ EFL_START_TEST(eolian_cxx_test_struct_docs)
    doc = field_iter->documentation;
    ck_assert_str_eq(doc.summary.c_str(), "Another field documentation.");
    ck_assert_str_eq(doc.description.c_str(), "");
-   ck_assert_str_eq(doc.since.c_str(), "");
+   ck_assert_str_eq(doc.since.c_str(), "1.66");
 }
 EFL_END_TEST