summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-02-19 13:29:09 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-21 08:56:13 +0100
commita152ba6d5b7ed1a8d4c111e2b7d7025a733818a9 (patch)
tree2e02e109797aa5a0db37e4d28b7702d5449544c8
parentb1217ede65b7f9398b3a27dda4ba19d347ce7c72 (diff)
mono-docs: Add <value> tags to properties
eolian_mono now generates properties (which simply wrap the setter and getter methods when both ara available), but they were missing docs, because properties require a special <value> tag instead of <returns> or <param> which we are already implementing. This commit adds <value> tags only if docs can be retrieved from the setter or the getter methods.
-rw-r--r--src/bin/eolian_mono/eolian/mono/documentation.hh23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh
index d2f4669..c00b449 100644
--- a/src/bin/eolian_mono/eolian/mono/documentation.hh
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -252,6 +252,12 @@ struct documentation_generator
252 return generate_tag(sink, "returns", text, context); 252 return generate_tag(sink, "returns", text, context);
253 } 253 }
254 254
255 template<typename OutputIterator, typename Context>
256 bool generate_tag_value(OutputIterator sink, std::string const& text, Context const& context) const
257 {
258 return generate_tag(sink, "value", text, context);
259 }
260
255 // Actual exported generators 261 // Actual exported generators
256 template<typename OutputIterator, typename Attribute, typename Context> 262 template<typename OutputIterator, typename Attribute, typename Context>
257 bool generate(OutputIterator sink, Attribute const& attr, Context const& context) const 263 bool generate(OutputIterator sink, Attribute const& attr, Context const& context) const
@@ -260,6 +266,23 @@ struct documentation_generator
260 } 266 }
261 267
262 template<typename OutputIterator, typename Context> 268 template<typename OutputIterator, typename Context>
269 bool generate(OutputIterator sink, attributes::property_def const& prop, Context const& context) const
270 {
271 if (!generate(sink, prop.documentation, context))
272 return false;
273
274 std::string text;
275 if (prop.setter.is_engaged())
276 text = prop.setter->parameters[0].documentation.full_text;
277 else if (prop.getter.is_engaged())
278 text = prop.getter->return_documentation.full_text;
279 // If there are no docs at all, do not generate <value> tag
280 else return true;
281
282 return generate_tag_value(sink, text, context);
283 }
284
285 template<typename OutputIterator, typename Context>
263 bool generate(OutputIterator sink, attributes::function_def const& func, Context const& context) const 286 bool generate(OutputIterator sink, attributes::function_def const& func, Context const& context) const
264 { 287 {
265 if (func.type == attributes::function_type::prop_get || func.type == attributes::function_type::prop_set) 288 if (func.type == attributes::function_type::prop_get || func.type == attributes::function_type::prop_set)