You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Fix doctool merges when method signatures don't match
If methods signature did not match, documentation is not merged. This is a considerable source of annoyance for contributors and it happened as a result of #4533, otherwise the documentation for constructors would not be properly merged. This PR modifies the logic introduced to only do the signature test on constructors and operators (which are the only types of members that can repeat).
This commit is contained in:
@@ -64,35 +64,42 @@ void DocTools::merge_from(const DocTools &p_data) {
|
|||||||
if (cf.methods[j].name != m.name) {
|
if (cf.methods[j].name != m.name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cf.methods[j].arguments.size() != m.arguments.size()) {
|
|
||||||
continue;
|
const char *operator_prefix = "operator "; // Operators use a space at the end, making this prefix an invalid identifier (and differentiating from methods).
|
||||||
}
|
|
||||||
// since polymorphic functions are allowed we need to check the type of
|
if (cf.methods[j].name == c.name || cf.methods[j].name.begins_with(operator_prefix)) {
|
||||||
// the arguments so we make sure they are different.
|
// Since constructors and operators can repeat, we need to check the type of
|
||||||
int arg_count = cf.methods[j].arguments.size();
|
// the arguments so we make sure they are different.
|
||||||
Vector<bool> arg_used;
|
|
||||||
arg_used.resize(arg_count);
|
if (cf.methods[j].arguments.size() != m.arguments.size()) {
|
||||||
for (int l = 0; l < arg_count; ++l) {
|
continue;
|
||||||
arg_used.write[l] = false;
|
}
|
||||||
}
|
|
||||||
// also there is no guarantee that argument ordering will match, so we
|
int arg_count = cf.methods[j].arguments.size();
|
||||||
// have to check one by one so we make sure we have an exact match
|
Vector<bool> arg_used;
|
||||||
for (int k = 0; k < arg_count; ++k) {
|
arg_used.resize(arg_count);
|
||||||
for (int l = 0; l < arg_count; ++l) {
|
for (int l = 0; l < arg_count; ++l) {
|
||||||
if (cf.methods[j].arguments[k].type == m.arguments[l].type && !arg_used[l]) {
|
arg_used.write[l] = false;
|
||||||
arg_used.write[l] = true;
|
}
|
||||||
break;
|
// also there is no guarantee that argument ordering will match, so we
|
||||||
|
// have to check one by one so we make sure we have an exact match
|
||||||
|
for (int k = 0; k < arg_count; ++k) {
|
||||||
|
for (int l = 0; l < arg_count; ++l) {
|
||||||
|
if (cf.methods[j].arguments[k].type == m.arguments[l].type && !arg_used[l]) {
|
||||||
|
arg_used.write[l] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
bool not_the_same = false;
|
||||||
bool not_the_same = false;
|
for (int l = 0; l < arg_count; ++l) {
|
||||||
for (int l = 0; l < arg_count; ++l) {
|
if (!arg_used[l]) { // at least one of the arguments was different
|
||||||
if (!arg_used[l]) { // at least one of the arguments was different
|
not_the_same = true;
|
||||||
not_the_same = true;
|
}
|
||||||
|
}
|
||||||
|
if (not_the_same) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (not_the_same) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocData::MethodDoc &mf = cf.methods[j];
|
const DocData::MethodDoc &mf = cf.methods[j];
|
||||||
|
|||||||
Reference in New Issue
Block a user