summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-05 12:15:51 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-05 12:15:51 +0100
commitac0113ba2b8fc9515448be594cc0dc3a9b1fa492 (patch)
tree59be45637446ac3c889425efdab90a707cede448 /src/bin
parent51d9760fe648179aa660c893dbb965a7e5cc7f18 (diff)
eolian/generator: generation for new documentation system
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
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/docs_generator.c356
-rw-r--r--src/bin/eolian/docs_generator.h31
-rw-r--r--src/bin/eolian/eo_generator.c70
-rw-r--r--src/bin/eolian/legacy_generator.c44
-rw-r--r--src/bin/eolian/types_generator.c46
5 files changed, 527 insertions, 20 deletions
diff --git a/src/bin/eolian/docs_generator.c b/src/bin/eolian/docs_generator.c
new file mode 100644
index 0000000000..70475850f0
--- /dev/null
+++ b/src/bin/eolian/docs_generator.c
@@ -0,0 +1,356 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <ctype.h>
6
7#include "docs_generator.h"
8
9static int
10_indent_line(Eina_Strbuf *buf, int ind)
11{
12 int i;
13 for (i = 0; i < ind; ++i)
14 eina_strbuf_append_char(buf, ' ');
15 return ind;
16}
17
18#define DOC_LINE_LIMIT 79
19#define DOC_LINE_TEST 59
20#define DOC_LINE_OVER 39
21
22#define DOC_LIMIT(ind) ((ind > DOC_LINE_TEST) ? (ind + DOC_LINE_OVER) \
23 : DOC_LINE_LIMIT)
24
25int
26_append_section(const char *desc, int ind, int curl, Eina_Strbuf *buf,
27 Eina_Strbuf *wbuf)
28{
29 while (*desc)
30 {
31 eina_strbuf_reset(wbuf);
32 while (*desc && isspace(*desc) && (*desc != '\n'))
33 eina_strbuf_append_char(wbuf, *desc++);
34 while (*desc && !isspace(*desc))
35 eina_strbuf_append_char(wbuf, *desc++);
36 int limit = DOC_LIMIT(ind);
37 int wlen = eina_strbuf_length_get(wbuf);
38 if ((int)(curl + wlen) > limit)
39 {
40 curl = 3;
41 eina_strbuf_append_char(buf, '\n');
42 curl += _indent_line(buf, ind);
43 eina_strbuf_append(buf, " * ");
44 if (*eina_strbuf_string_get(wbuf) == ' ')
45 eina_strbuf_remove(wbuf, 0, 1);
46 }
47 curl += eina_strbuf_length_get(wbuf);
48 eina_strbuf_append(buf, eina_strbuf_string_get(wbuf));
49 if (*desc == '\n')
50 {
51 desc++;
52 eina_strbuf_append_char(buf, '\n');
53 while (*desc == '\n')
54 {
55 _indent_line(buf, ind);
56 eina_strbuf_append(buf, " *\n");
57 desc++;
58 }
59 curl = _indent_line(buf, ind) + 3;
60 eina_strbuf_append(buf, " * ");
61 }
62 }
63 return curl;
64}
65
66void
67_gen_doc_brief(const char *summary, int indent, Eina_Strbuf *buf)
68{
69 int curl = 4 + indent;
70 Eina_Strbuf *wbuf = eina_strbuf_new();
71 eina_strbuf_append(buf, "/** ");
72 curl = _append_section(summary, indent, curl, buf, wbuf);
73 eina_strbuf_free(wbuf);
74 if ((curl + 3) > DOC_LIMIT(indent))
75 {
76 eina_strbuf_append_char(buf, '\n');
77 _indent_line(buf, indent);
78 eina_strbuf_append(buf, " */");
79 }
80 else
81 eina_strbuf_append(buf, " */");
82}
83
84void
85_gen_doc_full(const char *summary, const char *description, int indent,
86 Eina_Strbuf *buf)
87{
88 int curl = 0;
89 Eina_Strbuf *wbuf = eina_strbuf_new();
90 eina_strbuf_append(buf, "/**\n");
91 curl += _indent_line(buf, indent);
92 eina_strbuf_append(buf, " * @brief ");
93 curl += sizeof(" * @brief ") - 1;
94 _append_section(summary, indent, curl, buf, wbuf);
95 eina_strbuf_append_char(buf, '\n');
96 _indent_line(buf, indent);
97 eina_strbuf_append(buf, " *\n");
98 curl = _indent_line(buf, indent);
99 eina_strbuf_append(buf, " * ");
100 _append_section(description, indent, curl + 3, buf, wbuf);
101 eina_strbuf_append_char(buf, '\n');
102 _indent_line(buf, indent);
103 eina_strbuf_append(buf, " */");
104 eina_strbuf_free(wbuf);
105}
106
107Eina_Strbuf *
108docs_generate_full(const Eolian_Documentation *doc, int indent)
109{
110 if (!doc) return NULL;
111
112 const char *sum = eolian_documentation_summary_get(doc);
113 const char *desc = eolian_documentation_description_get(doc);
114
115 Eina_Strbuf *buf = eina_strbuf_new();
116 if (!desc)
117 _gen_doc_brief(sum, indent, buf);
118 else
119 _gen_doc_full(sum, desc, indent, buf);
120 return buf;
121}
122
123Eina_Strbuf *
124docs_generate_function(const Eolian_Function *fid, Eolian_Function_Type ftype, int indent)
125{
126 const Eolian_Function_Parameter *par = NULL;
127 const Eolian_Function_Parameter *vpar = NULL;
128
129 const Eolian_Documentation *doc, *pdoc, *rdoc;
130
131 Eina_Iterator *itr = NULL;
132 Eina_Iterator *vitr = NULL;
133 Eina_Bool force_out = EINA_FALSE;
134
135 Eina_Strbuf *buf = eina_strbuf_new();
136 Eina_Strbuf *wbuf = NULL;
137
138 const char *sum = NULL, *desc = NULL;
139
140 int curl = 0;
141
142 if (ftype == EOLIAN_UNRESOLVED)
143 ftype = EOLIAN_METHOD;
144
145 if (ftype == EOLIAN_METHOD)
146 {
147 doc = eolian_function_documentation_get(fid, EOLIAN_METHOD);
148 pdoc = NULL;
149 }
150 else
151 {
152 doc = eolian_function_documentation_get(fid, EOLIAN_PROPERTY);
153 pdoc = eolian_function_documentation_get(fid, ftype);
154 }
155
156 rdoc = eolian_function_return_documentation_get(fid, ftype);
157
158 if (doc)
159 {
160 sum = eolian_documentation_summary_get(doc);
161 desc = eolian_documentation_description_get(doc);
162 }
163
164 if (ftype == EOLIAN_METHOD)
165 {
166 itr = eolian_function_parameters_get(fid);
167 if (!itr || !eina_iterator_next(itr, (void**)&par))
168 {
169 eina_iterator_free(itr);
170 itr = NULL;
171 }
172 }
173 else
174 {
175 itr = eolian_property_keys_get(fid, ftype);
176 vitr = eolian_property_values_get(fid, ftype);
177 if (!vitr || !eina_iterator_next(vitr, (void**)&vpar))
178 {
179 eina_iterator_free(vitr);
180 vitr = NULL;
181 }
182 }
183
184 if (!itr || !eina_iterator_next(itr, (void**)&par))
185 {
186 eina_iterator_free(itr);
187 itr = NULL;
188 }
189
190 /* when return is not set on getter, value becomes return instead of param */
191 if (ftype == EOLIAN_PROP_GET && !eolian_function_return_type_get(fid, ftype))
192 {
193 if (!eina_iterator_next(vitr, (void**)&vpar))
194 {
195 /* one value - not out param */
196 eina_iterator_free(vitr);
197 rdoc = eolian_parameter_documentation_get(vpar);
198 vitr = NULL;
199 vpar = NULL;
200 }
201 else
202 {
203 /* multiple values - always out params */
204 eina_iterator_free(vitr);
205 vitr = eolian_property_values_get(fid, ftype);
206 if (!vitr)
207 vpar = NULL;
208 else if (!eina_iterator_next(vitr, (void**)&vpar))
209 {
210 eina_iterator_free(vitr);
211 vitr = NULL;
212 vpar = NULL;
213 }
214 }
215 }
216
217 if (!par)
218 {
219 /* no keys, try values */
220 itr = vitr;
221 par = vpar;
222 vitr = NULL;
223 vpar = NULL;
224 if (ftype == EOLIAN_PROP_GET)
225 force_out = EINA_TRUE;
226 }
227
228 /* only summary, nothing else; generate standard brief doc */
229 if (!desc && !par && !vpar && !rdoc && (ftype == EOLIAN_METHOD || !pdoc))
230 {
231 _gen_doc_brief(sum ? sum : "No description supplied.", indent, buf);
232 return buf;
233 }
234
235 wbuf = eina_strbuf_new();
236
237 eina_strbuf_append(buf, "/**\n");
238 curl += _indent_line(buf, indent);
239 eina_strbuf_append(buf, " * @brief ");
240 curl += sizeof(" * @brief ") - 1;
241 _append_section(sum ? sum : "No description supplied.",
242 indent, curl, buf, wbuf);
243
244 eina_strbuf_append_char(buf, '\n');
245 _indent_line(buf, indent);
246 eina_strbuf_append(buf, " *\n");
247
248 if (desc)
249 {
250 curl = _indent_line(buf, indent);
251 eina_strbuf_append(buf, " * ");
252 _append_section(desc, indent, curl + 3, buf, wbuf);
253 eina_strbuf_append_char(buf, '\n');
254 if (par || rdoc || pdoc)
255 {
256 _indent_line(buf, indent);
257 eina_strbuf_append(buf, " *\n");
258 }
259 }
260
261 if (pdoc)
262 {
263 const char *desc = eolian_documentation_description_get(pdoc);
264 curl = _indent_line(buf, indent);
265 eina_strbuf_append(buf, " * ");
266 _append_section(eolian_documentation_summary_get(pdoc), indent,
267 curl + 3, buf, wbuf);
268 eina_strbuf_append_char(buf, '\n');
269 if (desc)
270 {
271 _indent_line(buf, indent);
272 eina_strbuf_append(buf, " *\n");
273 curl = _indent_line(buf, indent);
274 eina_strbuf_append(buf, " * ");
275 _append_section(desc, indent, curl + 3, buf, wbuf);
276 eina_strbuf_append_char(buf, '\n');
277 }
278 if (par)
279 {
280 _indent_line(buf, indent);
281 eina_strbuf_append(buf, " *\n");
282 }
283 }
284
285 while (par)
286 {
287 const Eolian_Documentation *adoc = eolian_parameter_documentation_get(par);
288 curl = _indent_line(buf, indent);
289
290 Eolian_Parameter_Dir dir = EOLIAN_OUT_PARAM;
291 if (!force_out)
292 dir = eolian_parameter_direction_get(par);
293
294 switch (dir)
295 {
296 case EOLIAN_IN_PARAM:
297 eina_strbuf_append(buf, " * @param[in] ");
298 curl += sizeof(" * @param[in] ") - 1;
299 break;
300 case EOLIAN_OUT_PARAM:
301 eina_strbuf_append(buf, " * @param[out] ");
302 curl += sizeof(" * @param[out] ") - 1;
303 break;
304 case EOLIAN_INOUT_PARAM:
305 eina_strbuf_append(buf, " * @param[inout] ");
306 curl += sizeof(" * @param[inout] ") - 1;
307 break;
308 }
309
310 const char *nm = eolian_parameter_name_get(par);
311 eina_strbuf_append(buf, nm);
312 curl += strlen(nm);
313
314 if (adoc)
315 {
316 eina_strbuf_append_char(buf, ' ');
317 curl += 1;
318 _append_section(eolian_documentation_summary_get(adoc),
319 indent, curl, buf, wbuf);
320 }
321
322 eina_strbuf_append_char(buf, '\n');
323 if (!eina_iterator_next(itr, (void**)&par))
324 {
325 par = NULL;
326 if (vpar)
327 {
328 eina_iterator_free(itr);
329 itr = vitr;
330 par = vpar;
331 vitr = NULL;
332 vpar = NULL;
333 if (ftype == EOLIAN_PROP_GET)
334 force_out = EINA_TRUE;
335 }
336 }
337 }
338 eina_iterator_free(itr);
339
340 if (rdoc)
341 {
342 _indent_line(buf, indent);
343 eina_strbuf_append(buf, " *\n");
344 curl = _indent_line(buf, indent);
345 eina_strbuf_append(buf, " * @return ");
346 curl += sizeof(" * @return ") - 1;
347 _append_section(eolian_documentation_summary_get(rdoc), indent, curl,
348 buf, wbuf);
349 eina_strbuf_append_char(buf, '\n');
350 }
351
352 _indent_line(buf, indent);
353 eina_strbuf_append(buf, " */");
354 eina_strbuf_free(wbuf);
355 return buf;
356}
diff --git a/src/bin/eolian/docs_generator.h b/src/bin/eolian/docs_generator.h
new file mode 100644
index 0000000000..c8a6c1f019
--- /dev/null
+++ b/src/bin/eolian/docs_generator.h
@@ -0,0 +1,31 @@
1#ifndef DOCS_GENERATOR_H
2#define DOCS_GENERATOR_H
3
4#include <Eina.h>
5#include <Eolian.h>
6
7/*
8 * @brief Generate standard documentation
9 *
10 * @param[in] doc the documentation
11 * @param[in] indent by how many spaces to indent the comment from second line
12 *
13 * @return A documentation comment
14 *
15 */
16Eina_Strbuf *docs_generate_full(const Eolian_Documentation *doc, int indent);
17
18/*
19 * @brief Generate function documentation
20 *
21 * @param[in] fid te function
22 * @param[in] type the function type (either METHOD, PROP_GET, PROP_SET)
23 * @param[in] indent by how many spaces to indent the comment from second line
24 *
25 * @return A documentation comment
26 *
27 */
28Eina_Strbuf *docs_generate_function(const Eolian_Function *fid, Eolian_Function_Type ftype, int indent);
29
30#endif
31
diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c
index cb8a612e22..ca04359ccb 100644
--- a/src/bin/eolian/eo_generator.c
+++ b/src/bin/eolian/eo_generator.c
@@ -8,6 +8,7 @@
8 8
9#include "Eolian.h" 9#include "Eolian.h"
10#include "eo_generator.h" 10#include "eo_generator.h"
11#include "docs_generator.h"
11#include "common_funcs.h" 12#include "common_funcs.h"
12 13
13static _eolian_class_vars class_env; 14static _eolian_class_vars class_env;
@@ -106,7 +107,24 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia
106 if (scope == EOLIAN_SCOPE_PROTECTED) 107 if (scope == EOLIAN_SCOPE_PROTECTED)
107 eina_strbuf_append_printf(str_func, "#ifdef %s_PROTECTED\n", class_env.upper_classname); 108 eina_strbuf_append_printf(str_func, "#ifdef %s_PROTECTED\n", class_env.upper_classname);
108 109
109 eina_strbuf_append(str_func, tmpl_eo_funcdef_doxygen); 110 Eina_Bool hasnewdocs = eolian_function_documentation_get(func, EOLIAN_UNRESOLVED) ||
111 eolian_function_documentation_get(func, ftype);
112
113 if (!hasnewdocs)
114 {
115 /* it will still try to generate, but it'll have nothing to replace
116 * this is ugly, but i CBA to find a better way (it wouldn't make a
117 * difference anyway) and it'll be removed asap (when docs are replaced)
118 */
119 eina_strbuf_append(str_func, tmpl_eo_funcdef_doxygen);
120 }
121 else
122 {
123 Eina_Strbuf *dbuf = docs_generate_function(func, ftype, 0);
124 eina_strbuf_append(str_func, eina_strbuf_string_get(dbuf));
125 eina_strbuf_append_char(str_func, '\n');
126 eina_strbuf_free(dbuf);
127 }
110 eina_strbuf_append_printf(str_func, "EOAPI @#rettype %s(@#full_params);\n", func_env.lower_eo_func); 128 eina_strbuf_append_printf(str_func, "EOAPI @#rettype %s(@#full_params);\n", func_env.lower_eo_func);
111 129
112 if (scope == EOLIAN_SCOPE_PROTECTED) 130 if (scope == EOLIAN_SCOPE_PROTECTED)
@@ -228,9 +246,20 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
228 Eina_Strbuf * str_hdr = eina_strbuf_new(); 246 Eina_Strbuf * str_hdr = eina_strbuf_new();
229 247
230 const char *desc = eolian_class_description_get(class); 248 const char *desc = eolian_class_description_get(class);
249 const Eolian_Documentation *doc = eolian_class_documentation_get(class);
231 _class_env_create(class, NULL, &class_env); 250 _class_env_create(class, NULL, &class_env);
232 251
233 if (desc) 252 if (doc)
253 {
254 Eina_Strbuf *cdoc = docs_generate_full(doc, 0);
255 if (cdoc)
256 {
257 eina_strbuf_append(buf, eina_strbuf_string_get(cdoc));
258 eina_strbuf_append_char(buf, '\n');
259 eina_strbuf_free(cdoc);
260 }
261 }
262 else if (desc)
234 { 263 {
235 Eina_Strbuf *linedesc = eina_strbuf_new(); 264 Eina_Strbuf *linedesc = eina_strbuf_new();
236 eina_strbuf_append(linedesc, "/**\n"); 265 eina_strbuf_append(linedesc, "/**\n");
@@ -257,6 +286,7 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
257 { 286 {
258 Eina_Stringshare *evname = eolian_event_c_name_get(event); 287 Eina_Stringshare *evname = eolian_event_c_name_get(event);
259 const char *evdesc = eolian_event_description_get(event); 288 const char *evdesc = eolian_event_description_get(event);
289 const Eolian_Documentation *evdoc = eolian_event_documentation_get(event);
260 Eolian_Object_Scope scope = eolian_event_scope_get(event); 290 Eolian_Object_Scope scope = eolian_event_scope_get(event);
261 291
262 if (scope == EOLIAN_SCOPE_PRIVATE) 292 if (scope == EOLIAN_SCOPE_PRIVATE)
@@ -278,12 +308,22 @@ eo_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
278 if (!eolian_event_is_beta(event) && scope == EOLIAN_SCOPE_PUBLIC) 308 if (!eolian_event_is_beta(event) && scope == EOLIAN_SCOPE_PUBLIC)
279 eina_strbuf_append_char(str_ev, '\n'); 309 eina_strbuf_append_char(str_ev, '\n');
280 310
281 if (!evdesc) evdesc = "No description"; 311 if (evdoc)
282 eina_strbuf_reset(tmpbuf); 312 {
283 eina_strbuf_append(tmpbuf, evdesc); 313 Eina_Strbuf *evdbuf = docs_generate_full(evdoc, 0);
284 eina_strbuf_replace_all(tmpbuf, "\n", "\n * "); 314 eina_strbuf_append(str_ev, eina_strbuf_string_get(evdbuf));
285 eina_strbuf_prepend(tmpbuf," * "); 315 eina_strbuf_append_char(str_ev, '\n');
286 eina_strbuf_append_printf(str_ev, "/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf)); 316 eina_strbuf_free(evdbuf);
317 }
318 else
319 {
320 if (!evdesc) evdesc = "No description";
321 eina_strbuf_reset(tmpbuf);
322 eina_strbuf_append(tmpbuf, evdesc);
323 eina_strbuf_replace_all(tmpbuf, "\n", "\n * ");
324 eina_strbuf_prepend(tmpbuf," * ");
325 eina_strbuf_append_printf(str_ev, "/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf));
326 }
287 327
288 eina_strbuf_append_printf(str_ev, "#define %s (&(_%s))\n", evname, evname); 328 eina_strbuf_append_printf(str_ev, "#define %s (&(_%s))\n", evname, evname);
289 eina_strbuf_append_printf(str_extrn_ev, "EOAPI extern const Eo_Event_Description _%s;\n", evname); 329 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)
662 { 702 {
663 Eina_Stringshare *evname = eolian_event_c_name_get(event); 703 Eina_Stringshare *evname = eolian_event_c_name_get(event);
664 const char *evdesc = eolian_event_description_get(event); 704 const char *evdesc = eolian_event_description_get(event);
705 if (!evdesc)
706 {
707 const Eolian_Documentation *doc = eolian_event_documentation_get(event);
708 if (doc) evdesc = eolian_documentation_summary_get(doc);
709 }
665 char *evdesc_line1 = _source_desc_get(evdesc); 710 char *evdesc_line1 = _source_desc_get(evdesc);
666 711
667 eina_strbuf_append_printf(tmpbuf, 712 eina_strbuf_append_printf(tmpbuf,
@@ -686,7 +731,14 @@ _desc_generate(const Eolian_Class *class, const Eolian_Function *fid, Eolian_Fun
686 snprintf(tmpstr, sizeof(tmpstr), "%s%s", funcname, (ftype == EOLIAN_PROP_SET) 731 snprintf(tmpstr, sizeof(tmpstr), "%s%s", funcname, (ftype == EOLIAN_PROP_SET)
687 ? "_set" : ((ftype == EOLIAN_PROP_GET) ? "_get" : "")); 732 ? "_set" : ((ftype == EOLIAN_PROP_GET) ? "_get" : ""));
688 733
689 char *desc = _source_desc_get(eolian_function_description_get(fid, ftype)); 734 const char *opdesc = eolian_function_description_get(fid, ftype);
735 if (!opdesc)
736 {
737 const Eolian_Documentation *doc = eolian_function_documentation_get(fid, ftype);
738 if (doc) opdesc = eolian_documentation_summary_get(doc);
739 }
740
741 char *desc = _source_desc_get(opdesc);
690 eo_op_desc_generate(class, fid, ftype, desc, tmpbuf); 742 eo_op_desc_generate(class, fid, ftype, desc, tmpbuf);
691 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf)); 743 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
692 free(desc); 744 free(desc);
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c
index ea6cfb409e..d1e56dc5eb 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -8,18 +8,20 @@
8#include "Eolian.h" 8#include "Eolian.h"
9 9
10#include "legacy_generator.h" 10#include "legacy_generator.h"
11#include "docs_generator.h"
11#include "common_funcs.h" 12#include "common_funcs.h"
12 13
13static _eolian_class_vars class_env; 14static _eolian_class_vars class_env;
14 15
15static const char 16static const char
16tmpl_eapi_funcdef[] = "\n\ 17tmpl_eapi_funcdef_doxygen[] = "\n\
17/**\n\ 18/**\n\
18@#desc\n\ 19@#desc\n\
19@#list_desc_param\ 20@#list_desc_param\
20 */\n\ 21 */\n";
21EAPI @#type_return%s(@#params)@#flags;\n\ 22
22"; 23static const char
24tmpl_eapi_funcdef[] = "EAPI @#type_return%s(@#params)@#flags;\n";
23 25
24/*@#CLASS_CHECK(obj) @#check_ret;\n\*/ 26/*@#CLASS_CHECK(obj) @#check_ret;\n\*/
25static const char 27static const char
@@ -81,6 +83,27 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
81 } 83 }
82 84
83 if (func_env.legacy_func[0] == '\0') goto end; 85 if (func_env.legacy_func[0] == '\0') goto end;
86
87 Eina_Bool hasnewdocs = eolian_function_documentation_get(funcid, EOLIAN_UNRESOLVED) ||
88 eolian_function_documentation_get(funcid, ftype);
89
90 if (!hasnewdocs)
91 {
92 /* it will still try to generate, but it'll have nothing to replace
93 * this is ugly, but i CBA to find a better way (it wouldn't make a
94 * difference anyway) and it'll be removed asap (when docs are replaced)
95 */
96 eina_strbuf_append(fbody, tmpl_eapi_funcdef_doxygen);
97 }
98 else
99 {
100 Eina_Strbuf *dbuf = docs_generate_function(funcid, ftype, 0);
101 eina_strbuf_append_char(fbody, '\n');
102 eina_strbuf_append(fbody, eina_strbuf_string_get(dbuf));
103 eina_strbuf_append_char(fbody, '\n');
104 eina_strbuf_free(dbuf);
105 }
106
84 eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func); 107 eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func);
85 108
86 if (!eolian_function_is_class(funcid)) 109 if (!eolian_function_is_class(funcid))
@@ -361,7 +384,18 @@ legacy_header_generate(const Eolian_Class *class, Eina_Strbuf *buf)
361 _class_env_create(class, NULL, &class_env); 384 _class_env_create(class, NULL, &class_env);
362 385
363 const char *desc = eolian_class_description_get(class); 386 const char *desc = eolian_class_description_get(class);
364 if (desc) 387 const Eolian_Documentation *doc = eolian_class_documentation_get(class);
388 if (doc)
389 {
390 Eina_Strbuf *cdoc = docs_generate_full(doc, 0);
391 if (cdoc)
392 {
393 eina_strbuf_append(buf, eina_strbuf_string_get(cdoc));
394 eina_strbuf_append_char(buf, '\n');
395 eina_strbuf_free(cdoc);
396 }
397 }
398 else if (desc)
365 { 399 {
366 Eina_Strbuf *linedesc = eina_strbuf_new(); 400 Eina_Strbuf *linedesc = eina_strbuf_new();
367 eina_strbuf_append(linedesc, "/**\n"); 401 eina_strbuf_append(linedesc, "/**\n");
diff --git a/src/bin/eolian/types_generator.c b/src/bin/eolian/types_generator.c
index d18a0df6d6..35e741d928 100644
--- a/src/bin/eolian/types_generator.c
+++ b/src/bin/eolian/types_generator.c
@@ -8,6 +8,7 @@
8 8
9#include "Eolian.h" 9#include "Eolian.h"
10#include "types_generator.h" 10#include "types_generator.h"
11#include "docs_generator.h"
11#include "common_funcs.h" 12#include "common_funcs.h"
12 13
13static char * 14static char *
@@ -48,8 +49,19 @@ _desc_generate(const char *desc, Eina_Strbuf *buf)
48static Eina_Strbuf * 49static Eina_Strbuf *
49_type_generate(const Eolian_Type *tp, Eina_Bool full) 50_type_generate(const Eolian_Type *tp, Eina_Bool full)
50{ 51{
51 Eina_Strbuf *buf = eina_strbuf_new(); 52 const char *cdesc = eolian_type_description_get(tp);
52 _desc_generate(eolian_type_description_get(tp), buf); 53 Eina_Strbuf *buf;
54 if (cdesc)
55 {
56 buf = eina_strbuf_new();
57 _desc_generate(cdesc, buf);
58 }
59 else
60 {
61 buf = docs_generate_full(eolian_type_documentation_get(tp), 0);
62 if (!buf) buf = eina_strbuf_new();
63 else eina_strbuf_append_char(buf, '\n');
64 }
53 Eolian_Type_Type tp_type = eolian_type_type_get(tp); 65 Eolian_Type_Type tp_type = eolian_type_type_get(tp);
54 switch(tp_type) 66 switch(tp_type)
55 { 67 {
@@ -78,13 +90,24 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
78 Eina_Iterator *members = eolian_type_struct_fields_get(tp); 90 Eina_Iterator *members = eolian_type_struct_fields_get(tp);
79 EINA_ITERATOR_FOREACH(members, member) 91 EINA_ITERATOR_FOREACH(members, member)
80 { 92 {
81 const char *desc = eolian_type_struct_field_description_get(member);
82 const Eolian_Type *type = eolian_type_struct_field_type_get(member); 93 const Eolian_Type *type = eolian_type_struct_field_type_get(member);
83 Eina_Stringshare *c_type = eolian_type_c_type_get(type); 94 Eina_Stringshare *c_type = eolian_type_c_type_get(type);
84 eina_strbuf_append_printf(buf, " %s%s%s;", 95 eina_strbuf_append_printf(buf, " %s%s%s;",
85 c_type, strchr(c_type, '*')?"":" ", 96 c_type, strchr(c_type, '*')?"":" ",
86 eolian_type_struct_field_name_get(member)); 97 eolian_type_struct_field_name_get(member));
87 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc); 98 const char *fdesc = eolian_type_struct_field_description_get(member);
99 const Eolian_Documentation *fdoc
100 = eolian_type_struct_field_documentation_get(member);
101 if (fdesc) eina_strbuf_append_printf(buf, " /** %s */", fdesc);
102 else if (fdoc)
103 {
104 const char *obuf = eina_strbuf_string_get(buf);
105 Eina_Strbuf *fbuf = docs_generate_full(fdoc,
106 strrchr(obuf, '\n') - obuf + 1);
107 if (fbuf) eina_strbuf_append_printf(buf, " %s",
108 eina_strbuf_string_get(fbuf));
109 eina_strbuf_free(fbuf);
110 }
88 eina_strbuf_append(buf, "\n"); 111 eina_strbuf_append(buf, "\n");
89 } 112 }
90 eina_iterator_free(members); 113 eina_iterator_free(members);
@@ -111,7 +134,6 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
111 Eina_Strbuf *membuf = eina_strbuf_new(); 134 Eina_Strbuf *membuf = eina_strbuf_new();
112 while (next) 135 while (next)
113 { 136 {
114 const char *desc = eolian_type_enum_field_description_get(member);
115 const Eolian_Expression *value = eolian_type_enum_field_value_get(member, EINA_FALSE); 137 const Eolian_Expression *value = eolian_type_enum_field_value_get(member, EINA_FALSE);
116 char *memb_u = strdup(eolian_type_enum_field_name_get(member)); 138 char *memb_u = strdup(eolian_type_enum_field_name_get(member));
117 eina_str_toupper(&memb_u); 139 eina_str_toupper(&memb_u);
@@ -138,7 +160,19 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
138 next = eina_iterator_next(members, (void**)&member); 160 next = eina_iterator_next(members, (void**)&member);
139 if (next) 161 if (next)
140 eina_strbuf_append(buf, ","); 162 eina_strbuf_append(buf, ",");
141 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc); 163 const char *fdesc = eolian_type_enum_field_description_get(member);
164 const Eolian_Documentation *fdoc
165 = eolian_type_enum_field_documentation_get(member);
166 if (fdesc) eina_strbuf_append_printf(buf, " /** %s */", fdesc);
167 else if (fdoc)
168 {
169 const char *obuf = eina_strbuf_string_get(buf);
170 Eina_Strbuf *fbuf = docs_generate_full(fdoc,
171 strrchr(obuf, '\n') - obuf + 1);
172 if (fbuf) eina_strbuf_append_printf(buf, " %s",
173 eina_strbuf_string_get(fbuf));
174 eina_strbuf_free(fbuf);
175 }
142 eina_strbuf_append(buf, "\n"); 176 eina_strbuf_append(buf, "\n");
143 } 177 }
144 eina_strbuf_append_printf(buf, "} %s", name); 178 eina_strbuf_append_printf(buf, "} %s", name);