From: Xavi Artigas Date: Thu, 1 Aug 2019 19:12:10 +0000 (+0200) Subject: mono-docs: Add misc struct docs X-Git-Tag: submit/tizen/20190805.083058~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a86e2fe5fd60c940a7fdb24f232d7157f31e10a2;p=platform%2Fupstream%2Fefl.git mono-docs: Add misc struct docs Summary: Structs have a convenience constructor which was missing parameter documentation. Struct fields need a tag or there is a hole in the generated docs. The documentation for the type of the field has been used, when available. Test Plan: Build docs and look at generated pages for structs. Reviewers: lauromoura, vitor.sousa, felipealmeida Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9478 --- diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh index d358dc7..413f59e 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh @@ -411,9 +411,10 @@ struct struct_definition_generator if (!as_generator ( documentation(indent.n + 1) + << indent << scope_tab << "/// " << string << "\n" << indent << scope_tab << "public " << type << " " << string << ";\n" ) - .generate(sink, std::make_tuple(field, field.type, name_helpers::to_field_name(field.name)), context)) + .generate(sink, std::make_tuple(field, field.type.doc_summary, field.type, name_helpers::to_field_name(field.name)), context)) return false; } @@ -434,13 +435,14 @@ struct struct_definition_generator // Constructor with default parameters for easy struct initialization if(!as_generator( indent << scope_tab << "/// Constructor for " << string << ".\n" + << *(indent << scope_tab << field_argument_docs << ";\n") << indent << scope_tab << "public " << string << "(\n" << ((indent << scope_tab << scope_tab << field_argument_default) % ",\n") << indent << scope_tab << ")\n" << indent << scope_tab << "{\n" << *(indent << scope_tab << scope_tab << field_argument_assignment << ";\n") << indent << scope_tab << "}\n\n") - .generate(sink, std::make_tuple(struct_name, struct_name, struct_.fields, struct_.fields), context)) + .generate(sink, std::make_tuple(struct_name, struct_.fields, struct_name, struct_.fields, struct_.fields), context)) return false; } diff --git a/src/bin/eolian_mono/eolian/mono/struct_fields.hh b/src/bin/eolian_mono/eolian/mono/struct_fields.hh index 163d1b9..5b755a7 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_fields.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_fields.hh @@ -37,6 +37,18 @@ struct field_argument_assignment_generator } } const field_argument_assignment {}; +struct field_argument_docs_generator +{ + template + bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const + { + if (!as_generator("/// " << string << "") + .generate(sink, std::make_tuple(name_helpers::to_field_name(field.name), field.documentation.summary), context)) + return false; + return true; + } +} const field_argument_docs {}; + } namespace efl { namespace eolian { namespace grammar { @@ -51,6 +63,11 @@ struct is_eager_generator< ::eolian_mono::field_argument_assignment_generator> : template<> struct is_generator< ::eolian_mono::field_argument_assignment_generator> : std::true_type {}; +template<> +struct is_eager_generator< ::eolian_mono::field_argument_docs_generator> : std::true_type {}; +template<> +struct is_generator< ::eolian_mono::field_argument_docs_generator> : std::true_type {}; + namespace type_traits { template <> @@ -59,6 +76,9 @@ struct attributes_needed< ::eolian_mono::field_argument_default_generator> : std template <> struct attributes_needed< ::eolian_mono::field_argument_assignment_generator> : std::integral_constant {}; +template <> +struct attributes_needed< ::eolian_mono::field_argument_docs_generator> : std::integral_constant {}; + } } } } diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp index c3c524c..9157cfd 100644 --- a/src/lib/eolian_cxx/grammar/klass_def.hpp +++ b/src/lib/eolian_cxx/grammar/klass_def.hpp @@ -375,10 +375,11 @@ struct type_def bool has_own; bool is_ptr; bool is_beta; + std::string doc_summary; type_def() = default; - type_def(variant_type original_type, std::string c_type, bool has_own, bool is_ptr, bool is_beta) - : original_type(original_type), c_type(c_type), has_own(has_own), is_ptr(is_ptr), is_beta(is_beta) {} + type_def(variant_type original_type, std::string c_type, bool has_own, bool is_ptr, bool is_beta, std::string doc_summary) + : original_type(original_type), c_type(c_type), has_own(has_own), is_ptr(is_ptr), is_beta(is_beta), doc_summary(doc_summary) {} type_def(Eolian_Type const* eolian_type, Eolian_Unit const* unit, Eolian_C_Type_Type ctype) { @@ -422,7 +423,7 @@ inline bool operator!=(type_def const& lhs, type_def const& rhs) return !(lhs == rhs); } -type_def const void_ {attributes::regular_type_def{"void", {qualifier_info::is_none, {}}, {}}, "void", false, false, false}; +type_def const void_ {attributes::regular_type_def{"void", {qualifier_info::is_none, {}}, {}}, "void", false, false, false, ""}; inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* unit, Eolian_C_Type_Type ctype) { @@ -434,6 +435,11 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type); is_beta = decl && eolian_object_is_beta(EOLIAN_OBJECT(decl)); + if (decl) + { + documentation_def documentation = eolian_typedecl_documentation_get(decl); + doc_summary = documentation.summary; + } switch( ::eolian_type_type_get(eolian_type)) { case EOLIAN_TYPE_VOID: