summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul Santos <raulsntos@gmail.com>2022-02-09 18:59:22 +0100
committerRaul Santos <raulsntos@gmail.com>2022-03-03 18:53:15 +0100
commit47a7d85cc42a871106d57f45af744ea85d19be47 (patch)
treec9c5b3d3d0d2ad5ffe681bb914ba3daa1411b3fe
parent3f69ea4f3bcb4f234f6e62909a79bdee221608a9 (diff)
Fix references to global constants in C# documentation generator
Tries to find the referenced constants in the GlobalScope if not found in the target class or if no class is specified.
-rw-r--r--modules/mono/editor/bindings_generator.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 07128770b7..c4f6165ccd 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -415,6 +415,11 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
}
} else if (link_tag == "constant") {
if (!target_itype || !target_itype->is_object_type) {
+ // Search in @GlobalScope as a last resort if no class was specified
+ if (link_target_parts.size() == 1) {
+ goto find_constant_in_global_scope;
+ }
+
if (OS::get_singleton()->is_stdout_verbose()) {
if (target_itype) {
OS::get_singleton()->print("Cannot resolve constant reference for non-Godot.Object type in documentation: %s\n", link_target.utf8().get_data());
@@ -428,6 +433,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append(link_target);
xml_output.append("</c>");
} else if (!target_itype && target_cname == name_cache.type_at_GlobalScope) {
+ find_constant_in_global_scope:
const String target_name = (String)target_cname;
// Try to find as a global constant
@@ -498,6 +504,11 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append(target_iconst->proxy_name);
xml_output.append("\"/>");
} else {
+ // Also search in @GlobalScope as a last resort if no class was specified
+ if (link_target_parts.size() == 1) {
+ goto find_constant_in_global_scope;
+ }
+
ERR_PRINT("Cannot resolve constant reference in documentation: '" + link_target + "'.");
xml_output.append("<c>");