eolian_mono: fix documentation warning by using "<" and ">"

Summary:
If type A: list<B>; is written in eo, then documentation warning
occurs because list<B> is written in the documentation without string
conversion.

To fix the warning, "<" and ">" are converted into "&lt;" and "&gt;".

Reviewers: lauromoura

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9891
This commit is contained in:
Jaehyun Cho 2019-09-11 11:46:51 -03:00 committed by Lauro Moura
parent 5d5128b226
commit 993b337e67
2 changed files with 20 additions and 2 deletions

View File

@ -37,6 +37,10 @@ struct alias_definition_generator
if (!as_generator(eolian_mono::type).generate(std::back_inserter(alias_type), alias.base_type, context))
return false;
std::string alias_type_doc;
alias_type_doc = utils::replace_all(alias_type, "<", "&lt;");
alias_type_doc = utils::replace_all(alias_type_doc, ">", "&gt;");
std::string const alias_name = utils::remove_all(alias.eolian_name, '_');
if (!as_generator(
documentation
@ -44,7 +48,7 @@ struct alias_definition_generator
<< "{\n"
<< scope_tab << "private " << alias_type << " payload;\n\n"
<< scope_tab << "/// <summary>Converts an instance of " << alias_type << " to this struct.</summary>\n"
<< scope_tab << "/// <summary>Converts an instance of " << alias_type_doc << " to this struct.</summary>\n"
<< scope_tab << "/// <param name=\"value\">The value to be converted.</param>\n"
<< scope_tab << "/// <returns>A struct with the given value.</returns>\n"
<< scope_tab << "public static implicit operator " << alias_name << "(" << alias_type << " value)\n"
@ -52,7 +56,7 @@ struct alias_definition_generator
<< scope_tab << scope_tab << "return new " << alias_name << "{payload=value};\n"
<< scope_tab << "}\n\n"
<< scope_tab << "/// <summary>Converts an instance of this struct to " << alias_type << ".</summary>\n"
<< scope_tab << "/// <summary>Converts an instance of this struct to " << alias_type_doc << ".</summary>\n"
<< scope_tab << "/// <param name=\"value\">The value to be converted packed in this struct.</param>\n"
<< scope_tab << "/// <returns>The actual value the alias is wrapping.</returns>\n"
<< scope_tab << "public static implicit operator " << alias_type << "(" << alias_name << " value)\n"

View File

@ -88,6 +88,20 @@ namespace eolian_mono { namespace utils {
else
return false;
}
inline std::string replace_all(std::string s, std::string target, std::string replace)
{
size_t pos = s.find(target);
while (pos != std::string::npos)
{
s.replace(pos, target.length(), replace);
pos += replace.length();
pos = s.find(target, pos);
}
return s;
}
} }
#endif