1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

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.
This commit is contained in:
Raul Santos
2022-02-09 18:59:22 +01:00
parent 3f69ea4f3b
commit 47a7d85cc4

View File

@@ -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>");