Skip to content

Commit

Permalink
Fix operator documentation in GDExtension API dump with docs
Browse files Browse the repository at this point in the history
The type of the right operand is now taken into account.
  • Loading branch information
rburing committed Dec 12, 2023
1 parent 84692c6 commit 82afe58
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/extension/extension_api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,14 +742,19 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
Dictionary d2;
String operator_name = Variant::get_operator_name(Variant::Operator(k));
d2["name"] = operator_name;
if (k != Variant::OP_NEGATE && k != Variant::OP_POSITIVE && k != Variant::OP_NOT && k != Variant::OP_BIT_NEGATE) {
d2["right_type"] = get_builtin_or_variant_type_name(Variant::Type(j));

String right_type_name = get_builtin_or_variant_type_name(Variant::Type(j));
bool is_unary = k == Variant::OP_NEGATE || k == Variant::OP_POSITIVE || k == Variant::OP_NOT || k == Variant::OP_BIT_NEGATE;
if (!is_unary) {
d2["right_type"] = right_type_name;
}

d2["return_type"] = get_builtin_or_variant_type_name(Variant::get_operator_return_type(Variant::Operator(k), type, Variant::Type(j)));

if (p_include_docs && builtin_doc != nullptr) {
for (const DocData::MethodDoc &operator_doc : builtin_doc->operators) {
if (operator_doc.name == "operator " + operator_name) {
if (operator_doc.name == "operator " + operator_name &&
(is_unary || operator_doc.arguments[0].type == right_type_name)) {
d2["description"] = fix_doc_description(operator_doc.description);
break;
}
Expand Down

0 comments on commit 82afe58

Please sign in to comment.