summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-20 16:05:01 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-09-20 16:23:54 +0200
commit32f92d3d869f889d729314574bf4e3b5c14a3e29 (patch)
tree4b624c371253ca8ee3cac4a864e2cf52e716d344 /src/bin
parent4672598b032d27c1b63e4c6271de12f21f41e380 (diff)
csharp: Add support for default param references in documentation
Summary: This also adds the information of default values in `parameter_def`. This will help adding actual default parameter support in the C# bindings. Thanks to @segfaultxavi for improved formatting and escaping. Fixes T8224 Reviewers: segfaultxavi, felipealmeida, brunobelo Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, segfaultxavi, #committers Tags: #efl Maniphest Tasks: T8224 Differential Revision: https://phab.enlightenment.org/D10050
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/documentation.hh17
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh24
2 files changed, 40 insertions, 1 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh
index 201ee16..2b4ed87 100644
--- a/src/bin/eolian_mono/eolian/mono/documentation.hh
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -540,7 +540,22 @@ struct documentation_generator
540 template<typename OutputIterator, typename Context> 540 template<typename OutputIterator, typename Context>
541 bool generate_parameter(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const 541 bool generate_parameter(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
542 { 542 {
543 return generate_tag_param(sink, name_helpers::escape_keyword(param.param_name), param.documentation.full_text, context); 543 auto text = param.documentation.full_text;
544 if (param.default_value.is_engaged())
545 {
546 auto value = param.default_value->serialized;
547
548 if (param.default_value->is_name_ref)
549 {
550 value = name_helpers::full_managed_name(value);
551 text += "\\<br/\\>The default value is \\<see cref=\\\"" + value + "\\\"/\\>.";
552 }
553 else
554 {
555 text += "\\<br/\\>The default value is \\<c\\>" + value + "\\</c\\>.";
556 }
557 }
558 return generate_tag_param(sink, name_helpers::escape_keyword(param.param_name), text, context);
544 } 559 }
545 560
546 template<typename OutputIterator, typename Context> 561 template<typename OutputIterator, typename Context>
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index a1fd8cd..b206311 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -204,6 +204,30 @@ inline std::string managed_name(std::string const& name, char separator='_')
204 return utils::to_pascal_case(tokens); 204 return utils::to_pascal_case(tokens);
205} 205}
206 206
207inline std::string full_managed_name(std::string const& name)
208{
209 std::stringstream ss;
210
211 auto words = utils::split(name, '.');
212 std::transform(words.begin(), words.end(), words.begin(), [](std::string const& word) {
213 return managed_name(word);
214 });
215
216 auto b = std::begin(words), e = std::end(words);
217
218 if (b != e)
219 {
220 std::copy(b, std::prev(e), std::ostream_iterator<std::string>(ss, "."));
221 b = std::prev(e);
222 }
223
224 // Avoid trailing separator
225 if (b != e)
226 ss << *b;
227
228 return ss.str();
229}
230
207inline std::string alias_full_eolian_name(attributes::alias_def const& alias) 231inline std::string alias_full_eolian_name(attributes::alias_def const& alias)
208{ 232{
209 233