aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-11-26 10:53:44 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2018-12-05 13:56:37 +0100
commitc88fa6b7a0cb736731184c7858cf212feabffadd (patch)
tree115fda40f7a0ad186770d59a487e50d7e351a532
parentdoc: Proper formatting of autogenerated C# XML comments (WIP) (diff)
downloadefl-devs/xartigas/new-charp-classes-documentation.tar.gz
-rw-r--r--src/bin/eolian_mono/eolian/mono/documentation.hh41
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh15
2 files changed, 46 insertions, 10 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh
index a42d4411ff..b7dada6f19 100644
--- a/src/bin/eolian_mono/eolian/mono/documentation.hh
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -25,9 +25,44 @@ struct documentation_generator
{
std::string new_text = text;
// $name to <c>name</c>
- new_text = std::regex_replace(new_text, std::regex("\\$([A-Za-z_]*)"), "<c>$1</c>");
+ // Periods (.) are included except when at the end
+ new_text = std::regex_replace(new_text, std::regex("\\$([0-9A-Za-z_\\.]*[0-9A-Za-z_])"), "<c>$1</c>");
// @name to <see cref="name">
- new_text = std::regex_replace(new_text, std::regex("@([A-Za-z._]*[A-Za-z_])"), "<see cref=\"$1\"/>");
+ // \@name is ignored
+ // Periods (.) are included except when at the end
+ auto regex = std::regex("@([A-Za-z._]*[A-Za-z_])");
+ auto cref_it = std::sregex_iterator(new_text.begin(), new_text.end(), regex);
+ std::string more_text;
+ std::smatch last;
+ bool match_found = false;
+ for (; cref_it != std::sregex_iterator(); cref_it++)
+ {
+ std::smatch cref = last = *cref_it;
+ if (!cref.prefix().str().empty() && cref.prefix().str().substr(cref.prefix().str().length() - 1) == "\\") continue;
+ std::vector<std::string> names = utils::split(cref[1].str(), '.');
+ // Special case for names ending in ".get" or ".set"
+ if ((names.size() > 1) && (names.back() == "get" || names.back() == "set"))
+ {
+ names[names.size() - 2] += "_" + names.back();
+ names.pop_back();
+ }
+ std::string new_cref;
+ std::string last_name;
+ for (auto name_it=names.begin(); name_it != names.end(); name_it++)
+ {
+ if (!new_cref.empty()) new_cref += ".";
+ if (::isupper((*name_it)[0]))
+ new_cref += name_helpers::managed_namespace(*name_it);
+ else
+ new_cref += name_helpers::managed_method_name_from_strings(last_name, *name_it);
+ last_name = *name_it;
+ }
+ more_text += cref.prefix().str() + "<see cref=\"" + new_cref + "\"/>";
+ match_found = true;
+ }
+ if (match_found)
+ new_text = more_text + last.suffix().str();
+ //new_text = std::regex_replace(new_text, std::regex("@([A-Za-z._]*[A-Za-z_])"), "<see cref=\"$1\"/>");
return new_text;
}
@@ -146,7 +181,7 @@ struct documentation_generator
summary += tabs + para + "\n" + tabs + "\n";
}
if (!doc.since.empty())
- summary += tabs + doc.since + "\n";
+ summary += tabs + "Since " + doc.since + "\n";
summary += tabs;
return generate_tag_summary(sink, summary, context);
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index 06291f412c..0883a2502e 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -32,10 +32,6 @@ namespace name_helpers {
namespace attributes = efl::eolian::grammar::attributes;
namespace detail {
-inline bool is_iequal(std::string const& lhs, std::string const& rhs)
-{
- return strcasecmp(lhs.c_str(), rhs.c_str()) == 0;
-}
inline bool is_equal(std::string const& lhs, std::string const& rhs)
{
return lhs == rhs;
@@ -176,21 +172,26 @@ inline std::string managed_namespace(std::string const& ns)
return escape_keyword(utils::remove_all(ns, '_'));
}
-inline std::string managed_method_name(attributes::function_def const& f)
+inline std::string managed_method_name_from_strings(std::string const& klass, std::string const& name)
{
- std::vector<std::string> names = utils::split(f.name, '_');
+ std::vector<std::string> names = utils::split(name, '_');
name_helpers::reorder_verb(names);
std::string candidate = escape_keyword(utils::to_pascal_case(names));
// Some eolian methods have the same name as their parent class
- if (candidate == f.klass.eolian_name)
+ if (candidate == klass)
candidate = "Do" + candidate;
return candidate;
}
+inline std::string managed_method_name(attributes::function_def const& f)
+{
+ return managed_method_name_from_strings(f.klass.eolian_name, f.name);
+}
+
inline std::string alias_full_eolian_name(attributes::alias_def const& alias)
{
return join_namespaces(alias.namespaces, '.') + alias.eolian_name;