eolian/generator: generation for new documentation system
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Fri, 5 Jun 2015 11:15:51 +0000 (12:15 +0100)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Fri, 5 Jun 2015 11:15:51 +0000 (12:15 +0100)
This commit adds the necessary generator logic to emit doc
comments from the new doc syntax. Old doc comments are kept
in for the time being as they're used within the EFL but they
will be removed eventually. This new generator focuses all the
important code in one place, making usage easy.

@feature

15 files changed:
src/Makefile_Eolian.am
src/bin/eolian/docs_generator.c [new file with mode: 0644]
src/bin/eolian/docs_generator.h [new file with mode: 0644]
src/bin/eolian/eo_generator.c
src/bin/eolian/legacy_generator.c
src/bin/eolian/types_generator.c
src/tests/eolian/data/class_simple.eo
src/tests/eolian/data/class_simple_ref_eo.h
src/tests/eolian/data/class_simple_ref_legacy.h
src/tests/eolian/data/complex_type.eo
src/tests/eolian/data/consts.eo
src/tests/eolian/data/events.eo
src/tests/eolian/data/object_impl.eo
src/tests/eolian/data/typedef.eo
src/tests/eolian/eolian_parsing.c

index 12d8ef5..58c452d 100644 (file)
@@ -59,6 +59,8 @@ bin_eolian_eolian_gen_SOURCES = \
                 bin/eolian/legacy_generator.h \
                 bin/eolian/types_generator.c \
                 bin/eolian/types_generator.h \
+                bin/eolian/docs_generator.c \
+                bin/eolian/docs_generator.h \
                 bin/eolian/main.c
 
 bin_eolian_eolian_gen_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EOLIAN_CFLAGS@
diff --git a/src/bin/eolian/docs_generator.c b/src/bin/eolian/docs_generator.c
new file mode 100644 (file)
index 0000000..7047585
--- /dev/null
@@ -0,0 +1,356 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <ctype.h>
+
+#include "docs_generator.h"
+
+static int
+_indent_line(Eina_Strbuf *buf, int ind)
+{
+   int i;
+   for (i = 0; i < ind; ++i)
+     eina_strbuf_append_char(buf, ' ');
+   return ind;
+}
+
+#define DOC_LINE_LIMIT 79
+#define DOC_LINE_TEST 59
+#define DOC_LINE_OVER 39
+
+#define DOC_LIMIT(ind) ((ind > DOC_LINE_TEST) ? (ind + DOC_LINE_OVER) \
+                                              : DOC_LINE_LIMIT)
+
+int
+_append_section(const char *desc, int ind, int curl, Eina_Strbuf *buf,
+                Eina_Strbuf *wbuf)
+{
+   while (*desc)
+     {
+        eina_strbuf_reset(wbuf);
+        while (*desc && isspace(*desc) && (*desc != '\n'))
+          eina_strbuf_append_char(wbuf, *desc++);
+        while (*desc && !isspace(*desc))
+          eina_strbuf_append_char(wbuf, *desc++);
+        int limit = DOC_LIMIT(ind);
+        int wlen = eina_strbuf_length_get(wbuf);
+        if ((int)(curl + wlen) > limit)
+          {
+             curl = 3;
+             eina_strbuf_append_char(buf, '\n');
+             curl += _indent_line(buf, ind);
+             eina_strbuf_append(buf, " * ");
+             if (*eina_strbuf_string_get(wbuf) == ' ')
+               eina_strbuf_remove(wbuf, 0, 1);
+          }
+        curl += eina_strbuf_length_get(wbuf);
+        eina_strbuf_append(buf, eina_strbuf_string_get(wbuf));
+        if (*desc == '\n')
+          {
+             desc++;
+             eina_strbuf_append_char(buf, '\n');
+             while (*desc == '\n')
+               {
+                  _indent_line(buf, ind);
+                  eina_strbuf_append(buf, " *\n");
+                  desc++;
+               }
+             curl = _indent_line(buf, ind) + 3;
+             eina_strbuf_append(buf, " * ");
+          }
+     }
+   return curl;
+}
+
+void
+_gen_doc_brief(const char *summary, int indent, Eina_Strbuf *buf)
+{
+   int curl = 4 + indent;
+   Eina_Strbuf *wbuf = eina_strbuf_new();
+   eina_strbuf_append(buf, "/** ");
+   curl = _append_section(summary, indent, curl, buf, wbuf);
+   eina_strbuf_free(wbuf);
+   if ((curl + 3) > DOC_LIMIT(indent))
+     {
+        eina_strbuf_append_char(buf, '\n');
+        _indent_line(buf, indent);
+        eina_strbuf_append(buf, " */");
+     }
+   else
+     eina_strbuf_append(buf, " */");
+}
+
+void
+_gen_doc_full(const char *summary, const char *description, int indent,
+              Eina_Strbuf *buf)
+{
+   int curl = 0;
+   Eina_Strbuf *wbuf = eina_strbuf_new();
+   eina_strbuf_append(buf, "/**\n");
+   curl += _indent_line(buf, indent);
+   eina_strbuf_append(buf, " * @brief ");
+   curl += sizeof(" * @brief ") - 1;
+   _append_section(summary, indent, curl, buf, wbuf);
+   eina_strbuf_append_char(buf, '\n');
+   _indent_line(buf, indent);
+   eina_strbuf_append(buf, " *\n");
+   curl = _indent_line(buf, indent);
+   eina_strbuf_append(buf, " * ");
+   _append_section(description, indent, curl + 3, buf, wbuf);
+   eina_strbuf_append_char(buf, '\n');
+   _indent_line(buf, indent);
+   eina_strbuf_append(buf, " */");
+   eina_strbuf_free(wbuf);
+}
+
+Eina_Strbuf *
+docs_generate_full(const Eolian_Documentation *doc, int indent)
+{
+   if (!doc) return NULL;
+
+   const char *sum = eolian_documentation_summary_get(doc);
+   const char *desc = eolian_documentation_description_get(doc);
+
+   Eina_Strbuf *buf = eina_strbuf_new();
+   if (!desc)
+     _gen_doc_brief(sum, indent, buf);
+   else
+     _gen_doc_full(sum, desc, indent, buf);
+   return buf;
+}
+
+Eina_Strbuf *
+docs_generate_function(const Eolian_Function *fid, Eolian_Function_Type ftype, int indent)
+{
+   const Eolian_Function_Parameter *par = NULL;
+   const Eolian_Function_Parameter *vpar = NULL;
+
+   const Eolian_Documentation *doc, *pdoc, *rdoc;
+
+   Eina_Iterator *itr = NULL;
+   Eina_Iterator *vitr = NULL;
+   Eina_Bool force_out = EINA_FALSE;
+
+   Eina_Strbuf *buf = eina_strbuf_new();
+   Eina_Strbuf *wbuf = NULL;
+
+   const char *sum = NULL, *desc = NULL;
+
+   int curl = 0;
+
+   if (ftype == EOLIAN_UNRESOLVED)
+     ftype = EOLIAN_METHOD;
+
+   if (ftype == EOLIAN_METHOD)
+     {
+        doc = eolian_function_documentation_get(fid, EOLIAN_METHOD);
+        pdoc = NULL;
+     }
+   else
+     {
+        doc = eolian_function_documentation_get(fid, EOLIAN_PROPERTY);
+        pdoc = eolian_function_documentation_get(fid, ftype);
+     }
+
+   rdoc = eolian_function_return_documentation_get(fid, ftype);
+
+   if (doc)
+     {
+         sum = eolian_documentation_summary_get(doc);
+         desc = eolian_documentation_description_get(doc);
+     }
+
+   if (ftype == EOLIAN_METHOD)
+     {
+        itr = eolian_function_parameters_get(fid);
+        if (!itr || !eina_iterator_next(itr, (void**)&par))
+          {
+             eina_iterator_free(itr);
+             itr = NULL;
+          }
+     }
+   else
+     {
+        itr = eolian_property_keys_get(fid, ftype);
+        vitr = eolian_property_values_get(fid, ftype);
+        if (!vitr || !eina_iterator_next(vitr, (void**)&vpar))
+          {
+             eina_iterator_free(vitr);
+             vitr = NULL;
+         }
+     }
+
+   if (!itr || !eina_iterator_next(itr, (void**)&par))
+     {
+        eina_iterator_free(itr);
+        itr = NULL;
+     }
+
+   /* when return is not set on getter, value becomes return instead of param */
+   if (ftype == EOLIAN_PROP_GET && !eolian_function_return_type_get(fid, ftype))
+     {
+        if (!eina_iterator_next(vitr, (void**)&vpar))
+          {
+             /* one value - not out param */
+             eina_iterator_free(vitr);
+             rdoc = eolian_parameter_documentation_get(vpar);
+             vitr = NULL;
+             vpar = NULL;
+          }
+        else
+          {
+             /* multiple values - always out params */
+             eina_iterator_free(vitr);
+             vitr = eolian_property_values_get(fid, ftype);
+             if (!vitr)
+               vpar = NULL;
+             else if (!eina_iterator_next(vitr, (void**)&vpar))
+               {
+                  eina_iterator_free(vitr);
+                  vitr = NULL;
+                  vpar = NULL;
+               }
+          }
+     }
+
+   if (!par)
+     {
+        /* no keys, try values */
+        itr = vitr;
+        par = vpar;
+        vitr = NULL;
+        vpar = NULL;
+        if (ftype == EOLIAN_PROP_GET)
+          force_out = EINA_TRUE;
+     }
+
+   /* only summary, nothing else; generate standard brief doc */
+   if (!desc && !par && !vpar && !rdoc && (ftype == EOLIAN_METHOD || !pdoc))
+     {
+        _gen_doc_brief(sum ? sum : "No description supplied.", indent, buf);
+        return buf;
+     }
+
+   wbuf = eina_strbuf_new();
+
+   eina_strbuf_append(buf, "/**\n");
+   curl += _indent_line(buf, indent);
+   eina_strbuf_append(buf, " * @brief ");
+   curl += sizeof(" * @brief ") - 1;
+   _append_section(sum ? sum : "No description supplied.",
+                   indent, curl, buf, wbuf);
+
+   eina_strbuf_append_char(buf, '\n');
+   _indent_line(buf, indent);
+   eina_strbuf_append(buf, " *\n");
+
+   if (desc)
+     {
+        curl = _indent_line(buf, indent);
+        eina_strbuf_append(buf, " * ");
+        _append_section(desc, indent, curl + 3, buf, wbuf);
+        eina_strbuf_append_char(buf, '\n');
+        if (par || rdoc || pdoc)
+          {
+             _indent_line(buf, indent);
+             eina_strbuf_append(buf, " *\n");
+          }
+     }
+
+   if (pdoc)
+     {
+        const char *desc = eolian_documentation_description_get(pdoc);
+        curl = _indent_line(buf, indent);
+        eina_strbuf_append(buf, " * ");
+        _append_section(eolian_documentation_summary_get(pdoc), indent,
+            curl + 3, buf, wbuf);
+        eina_strbuf_append_char(buf, '\n');
+        if (desc)
+          {
+             _indent_line(buf, indent);
+             eina_strbuf_append(buf, " *\n");
+             curl = _indent_line(buf, indent);
+             eina_strbuf_append(buf, " * ");
+             _append_section(desc, indent, curl + 3, buf, wbuf);
+             eina_strbuf_append_char(buf, '\n');
+          }
+        if (par)
+          {
+             _indent_line(buf, indent);
+             eina_strbuf_append(buf, " *\n");
+          }
+     }
+
+   while (par)
+     {
+        const Eolian_Documentation *adoc = eolian_parameter_documentation_get(par);
+        curl = _indent_line(buf, indent);
+
+        Eolian_Parameter_Dir dir = EOLIAN_OUT_PARAM;
+        if (!force_out)
+          dir = eolian_parameter_direction_get(par);
+
+        switch (dir)
+          {
+           case EOLIAN_IN_PARAM:
+             eina_strbuf_append(buf, " * @param[in] ");
+             curl += sizeof(" * @param[in] ") - 1;
+             break;
+           case EOLIAN_OUT_PARAM:
+             eina_strbuf_append(buf, " * @param[out] ");
+             curl += sizeof(" * @param[out] ") - 1;
+             break;
+           case EOLIAN_INOUT_PARAM:
+             eina_strbuf_append(buf, " * @param[inout] ");
+             curl += sizeof(" * @param[inout] ") - 1;
+             break;
+          }
+
+        const char *nm = eolian_parameter_name_get(par);
+        eina_strbuf_append(buf, nm);
+        curl += strlen(nm);
+
+        if (adoc)
+          {
+             eina_strbuf_append_char(buf, ' ');
+             curl += 1;
+             _append_section(eolian_documentation_summary_get(adoc),
+                             indent, curl, buf, wbuf);
+          }
+
+        eina_strbuf_append_char(buf, '\n');
+        if (!eina_iterator_next(itr, (void**)&par))
+          {
+             par = NULL;
+             if (vpar)
+               {
+                  eina_iterator_free(itr);
+                  itr = vitr;
+                  par = vpar;
+                  vitr = NULL;
+                  vpar = NULL;
+                  if (ftype == EOLIAN_PROP_GET)
+                    force_out = EINA_TRUE;
+               }
+          }
+     }
+   eina_iterator_free(itr);
+
+   if (rdoc)
+     {
+        _indent_line(buf, indent);
+        eina_strbuf_append(buf, " *\n");
+        curl = _indent_line(buf, indent);
+        eina_strbuf_append(buf, " * @return ");
+        curl += sizeof(" * @return ") - 1;
+        _append_section(eolian_documentation_summary_get(rdoc), indent, curl,
+            buf, wbuf);
+        eina_strbuf_append_char(buf, '\n');
+     }
+
+   _indent_line(buf, indent);
+   eina_strbuf_append(buf, " */");
+   eina_strbuf_free(wbuf);
+   return buf;
+}
diff --git a/src/bin/eolian/docs_generator.h b/src/bin/eolian/docs_generator.h
new file mode 100644 (file)
index 0000000..c8a6c1f
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef DOCS_GENERATOR_H
+#define DOCS_GENERATOR_H
+
+#include <Eina.h>
+#include <Eolian.h>
+
+/*
+ * @brief Generate standard documentation
+ *
+ * @param[in] doc the documentation
+ * @param[in] indent by how many spaces to indent the comment from second line
+ *
+ * @return A documentation comment
+ *
+ */
+Eina_Strbuf *docs_generate_full(const Eolian_Documentation *doc, int indent);
+
+/*
+ * @brief Generate function documentation
+ *
+ * @param[in] fid te function
+ * @param[in] type the function type (either METHOD, PROP_GET, PROP_SET)
+ * @param[in] indent by how many spaces to indent the comment from second line
+ *
+ * @return A documentation comment
+ *
+ */
+Eina_Strbuf *docs_generate_function(const Eolian_Function *fid, Eolian_Function_Type ftype, int indent);
+
+#endif
+
index cb8a612..ca04359 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "Eolian.h"
 #include "eo_generator.h"
+#include "docs_generator.h"
 #include "common_funcs.h"
 
 static _eolian_class_vars class_env;
@@ -106,7 +107,24 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
    if (scope == EOLIAN_SCOPE_PROTECTED)
       eina_strbuf_append_printf(str_func, "#ifdef %s_PROTECTED\n", class_env.upper_classname);
 
-   eina_strbuf_append(str_func, tmpl_eo_funcdef_doxygen);
+   Eina_Bool hasnewdocs = eolian_function_documentation_get(func, EOLIAN_UNRESOLVED) ||
+                          eolian_function_documentation_get(func, ftype);
+
+   if (!hasnewdocs)
+     {
+        /* it will still try to generate, but it'll have nothing to replace
+         * this is ugly, but i CBA to find a better way (it wouldn't make a
+         * difference anyway) and it'll be removed asap (when docs are replaced)
+         */
+        eina_strbuf_append(str_func, tmpl_eo_funcdef_doxygen);
+     }
+   else
+     {
+        Eina_Strbuf *dbuf = docs_generate_function(func, ftype, 0);
+        eina_strbuf_append(str_func, eina_strbuf_string_get(dbuf));
+        eina_strbuf_append_char(str_func, '\n');
+        eina_strbuf_free(dbuf);
+     }
    eina_strbuf_append_printf(str_func, "EOAPI @#rettype %s(@#full_params);\n", func_env.lower_eo_func);
 
    if (scope == EOLIAN_SCOPE_PROTECTED)
@@ -228,9 +246,20 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
    Eina_Strbuf * str_hdr = eina_strbuf_new();
 
    const char *desc = eolian_class_description_get(class);
+   const Eolian_Documentation *doc = eolian_class_documentation_get(class);
    _class_env_create(class, NULL, &class_env);
 
-   if (desc)
+   if (doc)
+     {
+        Eina_Strbuf *cdoc = docs_generate_full(doc, 0);
+        if (cdoc)
+          {
+             eina_strbuf_append(buf, eina_strbuf_string_get(cdoc));
+             eina_strbuf_append_char(buf, '\n');
+             eina_strbuf_free(cdoc);
+          }
+     }
+   else if (desc)
      {
         Eina_Strbuf *linedesc = eina_strbuf_new();
         eina_strbuf_append(linedesc, "/**\n");
@@ -257,6 +286,7 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
      {
         Eina_Stringshare *evname = eolian_event_c_name_get(event);
         const char *evdesc = eolian_event_description_get(event);
+        const Eolian_Documentation *evdoc = eolian_event_documentation_get(event);
         Eolian_Object_Scope scope = eolian_event_scope_get(event);
 
         if (scope == EOLIAN_SCOPE_PRIVATE)
@@ -278,12 +308,22 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
         if (!eolian_event_is_beta(event) && scope == EOLIAN_SCOPE_PUBLIC)
           eina_strbuf_append_char(str_ev, '\n');
 
-        if (!evdesc) evdesc = "No description";
-        eina_strbuf_reset(tmpbuf);
-        eina_strbuf_append(tmpbuf, evdesc);
-        eina_strbuf_replace_all(tmpbuf, "\n", "\n * ");
-        eina_strbuf_prepend(tmpbuf," * ");
-        eina_strbuf_append_printf(str_ev, "/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf));
+        if (evdoc)
+          {
+             Eina_Strbuf *evdbuf = docs_generate_full(evdoc, 0);
+             eina_strbuf_append(str_ev, eina_strbuf_string_get(evdbuf));
+             eina_strbuf_append_char(str_ev, '\n');
+             eina_strbuf_free(evdbuf);
+          }
+        else
+          {
+             if (!evdesc) evdesc = "No description";
+             eina_strbuf_reset(tmpbuf);
+             eina_strbuf_append(tmpbuf, evdesc);
+             eina_strbuf_replace_all(tmpbuf, "\n", "\n * ");
+             eina_strbuf_prepend(tmpbuf," * ");
+             eina_strbuf_append_printf(str_ev, "/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf));
+          }
 
         eina_strbuf_append_printf(str_ev, "#define %s (&(_%s))\n", evname, evname);
         eina_strbuf_append_printf(str_extrn_ev, "EOAPI extern const Eo_Event_Description _%s;\n", evname);
@@ -662,6 +702,11 @@ eo_source_beginning_generate(const Eolian_Class *class, Eina_Strbuf *buf)
      {
         Eina_Stringshare *evname = eolian_event_c_name_get(event);
         const char *evdesc = eolian_event_description_get(event);
+        if (!evdesc)
+          {
+             const Eolian_Documentation *doc = eolian_event_documentation_get(event);
+             if (doc) evdesc = eolian_documentation_summary_get(doc);
+          }
         char *evdesc_line1 = _source_desc_get(evdesc);
 
         eina_strbuf_append_printf(tmpbuf,
@@ -686,7 +731,14 @@ _desc_generate(const Eolian_Class *class, const Eolian_Function *fid, Eolian_Fun
    snprintf(tmpstr, sizeof(tmpstr), "%s%s", funcname, (ftype == EOLIAN_PROP_SET)
      ? "_set" : ((ftype == EOLIAN_PROP_GET) ? "_get" : ""));
 
-   char *desc = _source_desc_get(eolian_function_description_get(fid, ftype));
+   const char *opdesc = eolian_function_description_get(fid, ftype);
+   if (!opdesc)
+     {
+        const Eolian_Documentation *doc = eolian_function_documentation_get(fid, ftype);
+        if (doc) opdesc = eolian_documentation_summary_get(doc);
+     }
+
+   char *desc = _source_desc_get(opdesc);
    eo_op_desc_generate(class, fid, ftype, desc, tmpbuf);
    eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
    free(desc);
index ea6cfb4..d1e56dc 100644 (file)
@@ -8,18 +8,20 @@
 #include "Eolian.h"
 
 #include "legacy_generator.h"
+#include "docs_generator.h"
 #include "common_funcs.h"
 
 static _eolian_class_vars class_env;
 
 static const char
-tmpl_eapi_funcdef[] = "\n\
+tmpl_eapi_funcdef_doxygen[] = "\n\
 /**\n\
 @#desc\n\
 @#list_desc_param\
- */\n\
-EAPI @#type_return%s(@#params)@#flags;\n\
-";
+ */\n";
+
+static const char
+tmpl_eapi_funcdef[] = "EAPI @#type_return%s(@#params)@#flags;\n";
 
 /*@#CLASS_CHECK(obj) @#check_ret;\n\*/
 static const char
@@ -81,6 +83,27 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
      }
 
    if (func_env.legacy_func[0] == '\0') goto end;
+
+   Eina_Bool hasnewdocs = eolian_function_documentation_get(funcid, EOLIAN_UNRESOLVED) ||
+                          eolian_function_documentation_get(funcid, ftype);
+
+   if (!hasnewdocs)
+     {
+        /* it will still try to generate, but it'll have nothing to replace
+         * this is ugly, but i CBA to find a better way (it wouldn't make a
+         * difference anyway) and it'll be removed asap (when docs are replaced)
+         */
+        eina_strbuf_append(fbody, tmpl_eapi_funcdef_doxygen);
+     }
+   else
+     {
+        Eina_Strbuf *dbuf = docs_generate_function(funcid, ftype, 0);
+        eina_strbuf_append_char(fbody, '\n');
+        eina_strbuf_append(fbody, eina_strbuf_string_get(dbuf));
+        eina_strbuf_append_char(fbody, '\n');
+        eina_strbuf_free(dbuf);
+     }
+
    eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func);
 
    if (!eolian_function_is_class(funcid))
@@ -361,7 +384,18 @@ legacy_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
    _class_env_create(class, NULL, &class_env);
 
    const char *desc = eolian_class_description_get(class);
-   if (desc)
+   const Eolian_Documentation *doc = eolian_class_documentation_get(class);
+   if (doc)
+     {
+        Eina_Strbuf *cdoc = docs_generate_full(doc, 0);
+        if (cdoc)
+          {
+             eina_strbuf_append(buf, eina_strbuf_string_get(cdoc));
+             eina_strbuf_append_char(buf, '\n');
+             eina_strbuf_free(cdoc);
+          }
+     }
+   else if (desc)
      {
         Eina_Strbuf *linedesc = eina_strbuf_new();
         eina_strbuf_append(linedesc, "/**\n");
index d18a0df..35e741d 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "Eolian.h"
 #include "types_generator.h"
+#include "docs_generator.h"
 #include "common_funcs.h"
 
 static char *
@@ -48,8 +49,19 @@ _desc_generate(const char *desc, Eina_Strbuf *buf)
 static Eina_Strbuf *
 _type_generate(const Eolian_Type *tp, Eina_Bool full)
 {
-   Eina_Strbuf *buf = eina_strbuf_new();
-   _desc_generate(eolian_type_description_get(tp), buf);
+   const char *cdesc = eolian_type_description_get(tp);
+   Eina_Strbuf *buf;
+   if (cdesc)
+     {
+        buf = eina_strbuf_new();
+        _desc_generate(cdesc, buf);
+     }
+   else
+     {
+        buf = docs_generate_full(eolian_type_documentation_get(tp), 0);
+        if (!buf) buf = eina_strbuf_new();
+        else eina_strbuf_append_char(buf, '\n');
+     }
    Eolian_Type_Type tp_type = eolian_type_type_get(tp);
    switch(tp_type)
      {
@@ -78,13 +90,24 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
               Eina_Iterator *members = eolian_type_struct_fields_get(tp);
               EINA_ITERATOR_FOREACH(members, member)
                 {
-                   const char *desc = eolian_type_struct_field_description_get(member);
                    const Eolian_Type *type = eolian_type_struct_field_type_get(member);
                    Eina_Stringshare *c_type = eolian_type_c_type_get(type);
                    eina_strbuf_append_printf(buf, "  %s%s%s;",
                          c_type, strchr(c_type, '*')?"":" ",
                          eolian_type_struct_field_name_get(member));
-                   if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc);
+                   const char *fdesc = eolian_type_struct_field_description_get(member);
+                   const Eolian_Documentation *fdoc
+                       = eolian_type_struct_field_documentation_get(member);
+                   if (fdesc) eina_strbuf_append_printf(buf, " /** %s */", fdesc);
+                   else if (fdoc)
+                     {
+                        const char *obuf = eina_strbuf_string_get(buf);
+                        Eina_Strbuf *fbuf = docs_generate_full(fdoc,
+                            strrchr(obuf, '\n') - obuf + 1);
+                        if (fbuf) eina_strbuf_append_printf(buf, " %s",
+                            eina_strbuf_string_get(fbuf));
+                        eina_strbuf_free(fbuf);
+                     }
                    eina_strbuf_append(buf, "\n");
                 }
               eina_iterator_free(members);
@@ -111,7 +134,6 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
               Eina_Strbuf *membuf = eina_strbuf_new();
               while (next)
                 {
-                   const char *desc = eolian_type_enum_field_description_get(member);
                    const Eolian_Expression *value = eolian_type_enum_field_value_get(member, EINA_FALSE);
                    char *memb_u = strdup(eolian_type_enum_field_name_get(member));
                    eina_str_toupper(&memb_u);
@@ -138,7 +160,19 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
                    next = eina_iterator_next(members, (void**)&member);
                    if (next)
                      eina_strbuf_append(buf, ",");
-                   if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc);
+                   const char *fdesc = eolian_type_enum_field_description_get(member);
+                   const Eolian_Documentation *fdoc
+                       = eolian_type_enum_field_documentation_get(member);
+                   if (fdesc) eina_strbuf_append_printf(buf, " /** %s */", fdesc);
+                   else if (fdoc)
+                     {
+                        const char *obuf = eina_strbuf_string_get(buf);
+                        Eina_Strbuf *fbuf = docs_generate_full(fdoc,
+                            strrchr(obuf, '\n') - obuf + 1);
+                        if (fbuf) eina_strbuf_append_printf(buf, " %s",
+                            eina_strbuf_string_get(fbuf));
+                        eina_strbuf_free(fbuf);
+                     }
                    eina_strbuf_append(buf, "\n");
                 }
               eina_strbuf_append_printf(buf, "} %s", name);
index c1481f1..653c2fb 100644 (file)
@@ -1,20 +1,19 @@
 class Class_Simple {
-   /*@ Class Desc Simple */
+   [[Class Desc Simple]]
    legacy_prefix: evas_object_simple;
    eo_prefix: evas_obj_simple;
    data: Evas_Simple_Data;
    methods {
       @property a @beta {
-         /*@ Common desc for a */
+         [[Common desc for a]]
          set {
-            /*@
-            comment a.set */
-            return: bool (true); /*@ comment for property set return */
+            [[comment a.set]]
+            return: bool (true); [[comment for property set return]]
          }
          get {
          }
          values {
-            value: int (100); /*@ Value description */
+            value: int (100); [[Value description]]
          }
       }
       @property b @c_only {
@@ -23,13 +22,13 @@ class Class_Simple {
         }
       }
       foo @beta {
-         /*@ comment foo */
+         [[comment foo]]
          params {
-            @in a: int; /*@ a */
+            @in a: int; [[a]]
             @inout b: char;
             @out c: double (1337.6);
          }
-         return: char * (null); /*@ comment for method return */
+         return: char * (null); [[comment for method return]]
       }
       bar @c_only {
          eo: null;
index 7956266..4cf1c6d 100644 (file)
@@ -13,27 +13,30 @@ typedef Eo Class_Simple;
 
 
 #endif
-/**
- * Class Desc Simple
- */
+/** Class Desc Simple */
 #define CLASS_SIMPLE_CLASS class_simple_class_get()
 
 EAPI const Eo_Class *class_simple_class_get(void) EINA_CONST;
 
 #ifdef CLASS_SIMPLE_BETA
 /**
- * Common desc for a
+ * @brief Common desc for a
+ *
  * comment a.set
  *
  * @param[in] value Value description
+ *
+ * @return comment for property set return
  */
 EOAPI Eina_Bool  evas_obj_simple_a_set(int value);
 #endif
 
 #ifdef CLASS_SIMPLE_BETA
 /**
- * Common desc for a
- * 
+ * @brief Common desc for a
+ *
+ *
+ * @return Value description
  */
 EOAPI int  evas_obj_simple_a_get(void);
 #endif
@@ -45,12 +48,12 @@ EOAPI void  evas_obj_simple_b_set(void);
 
 #ifdef CLASS_SIMPLE_BETA
 /**
- * comment foo
- * 
+ * @brief comment foo
+ *
+ * @param[inout] b
+ * @param[out] c
  *
- * @param[in] a a
- * @param[inout] b No description supplied.
- * @param[out] c No description supplied.
+ * @return comment for method return
  */
 EOAPI char * evas_obj_simple_foo(int a, char *b, double *c);
 #endif
index 9109699..22c5b6b 100644 (file)
@@ -13,21 +13,24 @@ typedef Eo Class_Simple;
 
 
 #endif
-/**
- * Class Desc Simple
- */
+/** Class Desc Simple */
 
 /**
- * Common desc for a
+ * @brief Common desc for a
+ *
  * comment a.set
  *
  * @param[in] value Value description
+ *
+ * @return comment for property set return
  */
 EAPI Eina_Bool evas_object_simple_a_set(Class_Simple *obj, int value);
 
 /**
- * Common desc for a
- * 
+ * @brief Common desc for a
+ *
+ *
+ * @return Value description
  */
 EAPI int evas_object_simple_a_get(const Class_Simple *obj);
 
@@ -37,12 +40,12 @@ EAPI int evas_object_simple_a_get(const Class_Simple *obj);
 EAPI void evas_object_simple_b_set(Class_Simple *obj);
 
 /**
- * comment foo
- * 
+ * @brief comment foo
+ *
+ * @param[inout] b
+ * @param[out] c
  *
- * @param[in] a a
- * @param[inout] b No description supplied.
- * @param[out] c No description supplied.
+ * @return comment for method return
  */
 EAPI char *evas_object_simple_foo(Class_Simple *obj, int a, char *b, double *c);
 
index 7d70e40..2b1c29a 100644 (file)
@@ -14,7 +14,7 @@ class Complex_Type {
          params {
             buf: own(char*);
          }
-         return: own(list<Eina.Stringshare*>*); /*@ comment for method return */
+         return: own(list<Eina.Stringshare*>*); [[comment for method return]]
       }
    }
 }
index 6d084d7..8f8422a 100644 (file)
@@ -1,13 +1,13 @@
 class Consts {
    methods {
       foo @const {
-         /*@ comment foo */
+         [[comment foo]]
          params {
-            @in a: int; /*@ a */
+            @in a: int; [[a]]
             @inout b: char;
             @out c: double;
          }
-         return: char * (null); /*@ comment for method return */
+         return: char * (null); [[comment for method return]]
       }
    }
 }
index 76a18db..e1f68d5 100644 (file)
@@ -1,6 +1,6 @@
 class Events {
    events {
-      clicked @beta; /*@ Comment for clicked */
+      clicked @beta; [[Comment for clicked]]
       clicked,double: Evas_Event_Clicked_Double_Info; /* No comment */
    }
 }
index 67da250..17643a6 100644 (file)
@@ -35,16 +35,16 @@ class Object_Impl (Base) {
       constructor_2 {
       }
       foo1 {
-         /*@ comment foo */
+         [[comment foo]]
          params {
-            @in a: int; /*@ a */
+            @in a: int; [[a]]
             @inout b: char;
             @out c: double;
          }
-         return: char * (null); /*@ comment for method return */
+         return: char * (null); [[comment for method return]]
       }
       foo2 @const {
-         /*@ comment foo */
+         [[comment foo]]
          params {
             @in a: int;
             @in b: const(char)*;
index 33c612a..65036eb 100644 (file)
@@ -26,7 +26,7 @@ class Typedef {
          params {
             idx: int;
          }
-         return: own(char*); /*@ comment for method return */
+         return: own(char*); [[comment for method return]]
       }
    }
 }
index 8ffc936..ed0626a 100644 (file)
@@ -98,7 +98,7 @@ START_TEST(eolian_events)
 {
    const Eolian_Class *class;
    Eina_Iterator *iter;
-   const char *name, *comment, *type_name;
+   const char *name, *type_name;
    const Eolian_Type *type;
    const Eolian_Event *ev;
    void *dummy;
@@ -116,15 +116,12 @@ START_TEST(eolian_events)
    fail_if(!(eina_iterator_next(iter, (void**)&ev)));
    fail_if(!(name = eolian_event_name_get(ev)));
    fail_if(eolian_event_type_get(ev));
-   fail_if(!(comment = eolian_event_description_get(ev)));
    fail_if(strcmp(name, "clicked"));
-   fail_if(strcmp(comment, "Comment for clicked"));
    fail_if(!eolian_event_is_beta(ev));
    /* Clicked,double */
    fail_if(!(eina_iterator_next(iter, (void**)&ev)));
    fail_if(!(name = eolian_event_name_get(ev)));
    fail_if(!(type = eolian_event_type_get(ev)));
-   fail_if(comment = eolian_event_description_get(ev));
    fail_if(strcmp(name, "clicked,double"));
    type_name = eolian_type_name_get(type);
    fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info"));
@@ -546,9 +543,6 @@ START_TEST(eolian_simple_parsing)
 
    /* Class */
    fail_if(eolian_class_type_get(class) != EOLIAN_CLASS_REGULAR);
-   string = eolian_class_description_get(class);
-   fail_if(!string);
-   fail_if(strcmp(string, "Class Desc Simple"));
    fail_if(eolian_class_inherits_get(class) != NULL);
    fail_if(strcmp(eolian_class_legacy_prefix_get(class), "evas_object_simple"));
    fail_if(strcmp(eolian_class_eo_prefix_get(class), "evas_obj_simple"));
@@ -563,14 +557,6 @@ START_TEST(eolian_simple_parsing)
    fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
    fail_if(strcmp(eolian_function_name_get(fid), "a"));
    fail_if(!eolian_function_is_beta(fid));
-   string = eolian_function_description_get(fid, EOLIAN_PROPERTY);
-   fail_if(!string);
-   fail_if(strcmp(string, "Common desc for a"));
-   string = eolian_function_description_get(fid, EOLIAN_PROP_SET);
-   fail_if(!string);
-   fail_if(strcmp(string, "comment a.set"));
-   string = eolian_function_description_get(fid, EOLIAN_PROP_GET);
-   fail_if(string);
    fail_if(eolian_function_class_get(fid) != class);
    /* Set return */
    tp = eolian_function_return_type_get(fid, EOLIAN_PROP_SET);
@@ -580,14 +566,9 @@ START_TEST(eolian_simple_parsing)
    fail_if(!expr);
    v = eolian_expression_eval(expr, EOLIAN_MASK_BOOL);
    fail_if(v.type != EOLIAN_EXPR_BOOL);
-   string = eolian_function_return_comment_get(fid, EOLIAN_PROP_SET);
-   fail_if(!string);
-   fail_if(strcmp(string, "comment for property set return"));
    /* Get return */
    tp = eolian_function_return_type_get(fid, EOLIAN_PROP_GET);
    fail_if(tp);
-   string = eolian_function_return_comment_get(fid, EOLIAN_PROP_GET);
-   fail_if(string);
 
    /* Function parameters */
    fail_if(eolian_property_keys_get(fid, EOLIAN_PROP_GET) != NULL);
@@ -597,7 +578,6 @@ START_TEST(eolian_simple_parsing)
    eina_iterator_free(iter);
    fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int"));
    fail_if(strcmp(eolian_parameter_name_get(param), "value"));
-   fail_if(strcmp(eolian_parameter_description_get(param), "Value description"));
    expr = eolian_parameter_default_value_get(param);
    fail_if(!expr);
    v = eolian_expression_eval(expr, EOLIAN_MASK_INT);
@@ -614,9 +594,6 @@ START_TEST(eolian_simple_parsing)
    /* Method */
    fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
    fail_if(!eolian_function_is_beta(fid));
-   string = eolian_function_description_get(fid, EOLIAN_METHOD);
-   fail_if(!string);
-   fail_if(strcmp(string, "comment foo"));
    /* Function return */
    tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
    fail_if(!tp);
@@ -628,9 +605,6 @@ START_TEST(eolian_simple_parsing)
    fail_if(!expr);
    v = eolian_expression_eval(expr, EOLIAN_MASK_NULL);
    fail_if(v.type != EOLIAN_EXPR_NULL);
-   string = eolian_function_return_comment_get(fid, EOLIAN_METHOD);
-   fail_if(!string);
-   fail_if(strcmp(string, "comment for method return"));
    fail_if(eolian_function_is_legacy_only(fid, EOLIAN_METHOD));
 
    /* Function parameters */
@@ -639,18 +613,15 @@ START_TEST(eolian_simple_parsing)
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
    fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int"));
    fail_if(strcmp(eolian_parameter_name_get(param), "a"));
-   fail_if(strcmp(eolian_parameter_description_get(param), "a"));
    fail_if(!(eina_iterator_next(iter, (void**)&param)));
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_INOUT_PARAM);
    ptype = eolian_type_name_get(eolian_parameter_type_get(param));
    fail_if(strcmp(ptype, "char"));
    fail_if(strcmp(eolian_parameter_name_get(param), "b"));
-   fail_if(eolian_parameter_description_get(param));
    fail_if(!(eina_iterator_next(iter, (void**)&param)));
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM);
    fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "double"));
    fail_if(strcmp(eolian_parameter_name_get(param), "c"));
-   fail_if(eolian_parameter_description_get(param));
    expr = eolian_parameter_default_value_get(param);
    fail_if(!expr);
    v = eolian_expression_eval(expr, EOLIAN_MASK_FLOAT);