summaryrefslogtreecommitdiff
path: root/src/lib/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-09-30 17:01:31 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-09-30 18:21:17 +0200
commit2946cb3c325f27d77354ac1b83b614e3a1d9e1d5 (patch)
treeff8e4f093fe7156c314f8eefbcda3616a7cfc72c /src/lib/eolian
parent09859cacf29d23dfa62fa1b9ac3efd897ac1c3f7 (diff)
eolian: disallow missing docs for stable API where necessary
The things that require docs include classes, variables, typedecls, events and methods/properties. Implements, params, returns, parts and struct/enum fields don't require them. Empty/whitespace only string does not count as documentation.
Diffstat (limited to 'src/lib/eolian')
-rw-r--r--src/lib/eolian/database_validate.c65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index c1de7ec11a..20417f7f4a 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -41,12 +41,23 @@ _validate(Eolian_Object *obj)
41 eolian_state_log_obj((_base)->unit->state, (_base), __VA_ARGS__) 41 eolian_state_log_obj((_base)->unit->state, (_base), __VA_ARGS__)
42 42
43static Eina_Bool 43static Eina_Bool
44_validate_docstr(Eina_Stringshare *str, const Eolian_Object *info, Eina_List **rdbg) 44_validate_docstr(Eina_Stringshare *str, const Eolian_Object *info, Eina_List **rdbg, Eina_Bool sum)
45{ 45{
46 if (!str || !str[0]) return EINA_TRUE; 46 Eina_List *pl = NULL;
47 if (str && str[0])
48 pl = eolian_documentation_string_split(str);
49 if (!pl)
50 {
51 if (sum)
52 {
53 _eo_parser_log(info, "empty documentation");
54 return EINA_FALSE;
55 }
56 /* description can be empty, summary-only line */
57 return EINA_TRUE;
58 }
47 59
48 Eina_Bool ret = EINA_TRUE; 60 Eina_Bool ret = EINA_TRUE;
49 Eina_List *pl = eolian_documentation_string_split(str);
50 char *par; 61 char *par;
51 EINA_LIST_FREE(pl, par) 62 EINA_LIST_FREE(pl, par)
52 { 63 {
@@ -88,16 +99,23 @@ _validate_docstr(Eina_Stringshare *str, const Eolian_Object *info, Eina_List **r
88} 99}
89 100
90static Eina_Bool 101static Eina_Bool
91_validate_doc(Eolian_Documentation *doc) 102_validate_doc(Validate_State *vals, Eolian_Documentation *doc,
103 const Eolian_Object *obj)
92{ 104{
93 if (!doc) 105 if (!doc)
106 {
107 if (!obj) return EINA_TRUE;
108 if (!vals->stable) return EINA_TRUE;
109 _eo_parser_log(obj, "missing documentation");
110 return EINA_FALSE;
111 }
94 return EINA_TRUE; 112 return EINA_TRUE;
95 113
96 Eina_List *rdbg = doc->ref_dbg; 114 Eina_List *rdbg = doc->ref_dbg;
97 115
98 if (!_validate_docstr(doc->summary, &doc->base, &rdbg)) 116 if (!_validate_docstr(doc->summary, &doc->base, &rdbg, EINA_TRUE))
99 return EINA_FALSE; 117 return EINA_FALSE;
100 if (!_validate_docstr(doc->description, &doc->base, &rdbg)) 118 if (!_validate_docstr(doc->description, &doc->base, &rdbg, EINA_FALSE))
101 return EINA_FALSE; 119 return EINA_FALSE;
102 120
103 return _validate(&doc->base); 121 return _validate(&doc->base);
@@ -132,7 +150,7 @@ _sf_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
132 if (!sc->succ) 150 if (!sc->succ)
133 return EINA_FALSE; 151 return EINA_FALSE;
134 152
135 sc->succ = _validate_doc(sf->doc); 153 sc->succ = _validate_doc(sc->vals, sf->doc, NULL);
136 154
137 return sc->succ; 155 return sc->succ;
138} 156}
@@ -149,7 +167,7 @@ _ef_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
149 if (!sc->succ) 167 if (!sc->succ)
150 return EINA_FALSE; 168 return EINA_FALSE;
151 169
152 sc->succ = _validate_doc(ef->doc); 170 sc->succ = _validate_doc(sc->vals, ef->doc, NULL);
153 171
154 return sc->succ; 172 return sc->succ;
155} 173}
@@ -160,12 +178,12 @@ _validate_typedecl(Validate_State *vals, Eolian_Typedecl *tp)
160 if (tp->base.validated) 178 if (tp->base.validated)
161 return EINA_TRUE; 179 return EINA_TRUE;
162 180
163 if (!_validate_doc(tp->doc))
164 return EINA_FALSE;
165
166 /* for the time being assume all typedecls are beta unless overridden */ 181 /* for the time being assume all typedecls are beta unless overridden */
167 Eina_Bool was_stable = _set_stable(vals, !tp->base.is_beta); 182 Eina_Bool was_stable = _set_stable(vals, !tp->base.is_beta);
168 183
184 if (!_validate_doc(vals, tp->doc, &tp->base))
185 return EINA_FALSE;
186
169 switch (tp->type) 187 switch (tp->type)
170 { 188 {
171 case EOLIAN_TYPEDECL_ALIAS: 189 case EOLIAN_TYPEDECL_ALIAS:
@@ -471,7 +489,7 @@ _validate_param(Validate_State *vals, Eolian_Function_Parameter *param)
471 if (param->value && !_validate_expr(param->value, param->type, 0, param->by_ref)) 489 if (param->value && !_validate_expr(param->value, param->type, 0, param->by_ref))
472 return EINA_FALSE; 490 return EINA_FALSE;
473 491
474 if (!_validate_doc(param->doc)) 492 if (!_validate_doc(vals, param->doc, NULL))
475 return EINA_FALSE; 493 return EINA_FALSE;
476 494
477 return _validate(&param->base); 495 return _validate(&param->base);
@@ -539,9 +557,9 @@ _validate_function(Validate_State *vals, Eolian_Function *func, Eina_Hash *nhash
539 557
540#undef EOLIAN_PARAMS_VALIDATE 558#undef EOLIAN_PARAMS_VALIDATE
541 559
542 if (!_validate_doc(func->get_return_doc)) 560 if (!_validate_doc(vals, func->get_return_doc, NULL))
543 return _reset_stable(vals, was_stable, EINA_FALSE); 561 return _reset_stable(vals, was_stable, EINA_FALSE);
544 if (!_validate_doc(func->set_return_doc)) 562 if (!_validate_doc(vals, func->set_return_doc, NULL))
545 return _reset_stable(vals, was_stable, EINA_FALSE); 563 return _reset_stable(vals, was_stable, EINA_FALSE);
546 564
547 /* just for now, when dups become errors there will be no need to check */ 565 /* just for now, when dups become errors there will be no need to check */
@@ -574,7 +592,7 @@ _validate_part(Validate_State *vals, Eolian_Part *part, Eina_Hash *phash)
574 592
575 Eina_Bool was_stable = _set_stable(vals, !part->base.is_beta && vals->stable); 593 Eina_Bool was_stable = _set_stable(vals, !part->base.is_beta && vals->stable);
576 594
577 if (!_validate_doc(part->doc)) 595 if (!_validate_doc(vals, part->doc, NULL))
578 return _reset_stable(vals, was_stable, EINA_FALSE); 596 return _reset_stable(vals, was_stable, EINA_FALSE);
579 597
580 /* switch the class name for class */ 598 /* switch the class name for class */
@@ -693,7 +711,7 @@ _validate_event(Validate_State *vals, Eolian_Event *event, Eina_Hash *nhash)
693 } 711 }
694 } 712 }
695 713
696 if (!_validate_doc(event->doc)) 714 if (!_validate_doc(vals, event->doc, &event->base))
697 return _reset_stable(vals, was_stable, EINA_FALSE); 715 return _reset_stable(vals, was_stable, EINA_FALSE);
698 716
699 eina_hash_set(nhash, &event->base.name, &event->base); 717 eina_hash_set(nhash, &event->base.name, &event->base);
@@ -1346,16 +1364,17 @@ _db_fill_inherits(Validate_State *vals, Eolian_Class *cl, Eina_Hash *fhash,
1346} 1364}
1347 1365
1348static Eina_Bool 1366static Eina_Bool
1349_validate_implement(Eolian_Implement *impl) 1367_validate_implement(Validate_State *vals, Eolian_Implement *impl)
1350{ 1368{
1351 if (impl->base.validated) 1369 if (impl->base.validated)
1352 return EINA_TRUE; 1370 return EINA_TRUE;
1353 1371
1354 if (!_validate_doc(impl->common_doc)) 1372 if (!_validate_doc(vals, impl->common_doc, (impl->implklass == impl->klass)
1373 ? &impl->foo_id->base : NULL))
1355 return EINA_FALSE; 1374 return EINA_FALSE;
1356 if (!_validate_doc(impl->get_doc)) 1375 if (!_validate_doc(vals, impl->get_doc, NULL))
1357 return EINA_FALSE; 1376 return EINA_FALSE;
1358 if (!_validate_doc(impl->set_doc)) 1377 if (!_validate_doc(vals, impl->set_doc, NULL))
1359 return EINA_FALSE; 1378 return EINA_FALSE;
1360 1379
1361 return _validate(&impl->base); 1380 return _validate(&impl->base);
@@ -1503,7 +1522,7 @@ _validate_class(Validate_State *vals, Eolian_Class *cl,
1503 return EINA_FALSE; 1522 return EINA_FALSE;
1504 1523
1505 EINA_LIST_FOREACH(cl->implements, l, impl) 1524 EINA_LIST_FOREACH(cl->implements, l, impl)
1506 if (!_validate_implement(impl)) 1525 if (!_validate_implement(vals, impl))
1507 return EINA_FALSE; 1526 return EINA_FALSE;
1508 1527
1509 /* all the checks that need to be done every time are performed now */ 1528 /* all the checks that need to be done every time are performed now */
@@ -1514,7 +1533,7 @@ _validate_class(Validate_State *vals, Eolian_Class *cl,
1514 return EINA_TRUE; 1533 return EINA_TRUE;
1515 } 1534 }
1516 1535
1517 if (!_validate_doc(cl->doc)) 1536 if (!_validate_doc(vals, cl->doc, &cl->base))
1518 return EINA_FALSE; 1537 return EINA_FALSE;
1519 1538
1520 /* also done */ 1539 /* also done */
@@ -1537,7 +1556,7 @@ _validate_constant(Validate_State *vals, Eolian_Constant *var)
1537 if (!_validate_expr(var->value, var->base_type, 0, EINA_FALSE)) 1556 if (!_validate_expr(var->value, var->base_type, 0, EINA_FALSE))
1538 return _reset_stable(vals, was_stable, EINA_FALSE); 1557 return _reset_stable(vals, was_stable, EINA_FALSE);
1539 1558
1540 if (!_validate_doc(var->doc)) 1559 if (!_validate_doc(vals, var->doc, &var->base))
1541 return _reset_stable(vals, was_stable, EINA_FALSE); 1560 return _reset_stable(vals, was_stable, EINA_FALSE);
1542 1561
1543 _reset_stable(vals, was_stable, EINA_TRUE); 1562 _reset_stable(vals, was_stable, EINA_TRUE);