Fix missing method qualifiers in script doc

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
Xwdit 2022-07-17 07:26:57 +02:00 committed by Rémi Verschelde
parent b50acebd48
commit 5d49df8d97
3 changed files with 32 additions and 48 deletions

View File

@ -115,6 +115,31 @@ void DocData::method_doc_from_methodinfo(DocData::MethodDoc &p_method, const Met
p_method.name = p_methodinfo.name; p_method.name = p_methodinfo.name;
p_method.description = p_desc; p_method.description = p_desc;
if (p_methodinfo.flags & METHOD_FLAG_VIRTUAL) {
p_method.qualifiers = "virtual";
}
if (p_methodinfo.flags & METHOD_FLAG_CONST) {
if (!p_method.qualifiers.is_empty()) {
p_method.qualifiers += " ";
}
p_method.qualifiers += "const";
}
if (p_methodinfo.flags & METHOD_FLAG_VARARG) {
if (!p_method.qualifiers.is_empty()) {
p_method.qualifiers += " ";
}
p_method.qualifiers += "vararg";
}
if (p_methodinfo.flags & METHOD_FLAG_STATIC) {
if (!p_method.qualifiers.is_empty()) {
p_method.qualifiers += " ";
}
p_method.qualifiers += "static";
}
return_doc_from_retinfo(p_method, p_methodinfo.return_val); return_doc_from_retinfo(p_method, p_methodinfo.return_val);
for (int i = 0; i < p_methodinfo.arguments.size(); i++) { for (int i = 0; i < p_methodinfo.arguments.size(); i++) {
@ -123,7 +148,7 @@ void DocData::method_doc_from_methodinfo(DocData::MethodDoc &p_method, const Met
int default_arg_index = i - (p_methodinfo.arguments.size() - p_methodinfo.default_arguments.size()); int default_arg_index = i - (p_methodinfo.arguments.size() - p_methodinfo.default_arguments.size());
if (default_arg_index >= 0) { if (default_arg_index >= 0) {
Variant default_arg = p_methodinfo.default_arguments[default_arg_index]; Variant default_arg = p_methodinfo.default_arguments[default_arg_index];
argument.default_value = default_arg.get_construct_string(); argument.default_value = default_arg.get_construct_string().replace("\n", "");
} }
p_method.arguments.push_back(argument); p_method.arguments.push_back(argument);
} }

View File

@ -498,53 +498,7 @@ void DocTools::generate(bool p_basic_types) {
} }
DocData::MethodDoc method; DocData::MethodDoc method;
DocData::method_doc_from_methodinfo(method, E, "");
method.name = E.name;
if (E.flags & METHOD_FLAG_VIRTUAL) {
method.qualifiers = "virtual";
}
if (E.flags & METHOD_FLAG_CONST) {
if (!method.qualifiers.is_empty()) {
method.qualifiers += " ";
}
method.qualifiers += "const";
}
if (E.flags & METHOD_FLAG_VARARG) {
if (!method.qualifiers.is_empty()) {
method.qualifiers += " ";
}
method.qualifiers += "vararg";
}
if (E.flags & METHOD_FLAG_STATIC) {
if (!method.qualifiers.is_empty()) {
method.qualifiers += " ";
}
method.qualifiers += "static";
}
for (int i = -1; i < E.arguments.size(); i++) {
if (i == -1) {
#ifdef DEBUG_METHODS_ENABLED
DocData::return_doc_from_retinfo(method, E.return_val);
#endif
} else {
const PropertyInfo &arginfo = E.arguments[i];
DocData::ArgumentDoc argument;
DocData::argument_doc_from_arginfo(argument, arginfo);
int darg_idx = i - (E.arguments.size() - E.default_arguments.size());
if (darg_idx >= 0) {
Variant default_arg = E.default_arguments[darg_idx];
argument.default_value = default_arg.get_construct_string().replace("\n", " ");
}
method.arguments.push_back(argument);
}
}
Vector<Error> errs = ClassDB::get_method_error_return_values(name, E.name); Vector<Error> errs = ClassDB::get_method_error_return_values(name, E.name);
if (errs.size()) { if (errs.size()) {

View File

@ -278,6 +278,11 @@ void GDScript::_get_script_method_list(List<MethodInfo> *r_list, bool p_include_
GDScriptFunction *func = E.value; GDScriptFunction *func = E.value;
MethodInfo mi; MethodInfo mi;
mi.name = E.key; mi.name = E.key;
if (func->is_static()) {
mi.flags |= METHOD_FLAG_STATIC;
}
for (int i = 0; i < func->get_argument_count(); i++) { for (int i = 0; i < func->get_argument_count(); i++) {
PropertyInfo arginfo = func->get_argument_type(i); PropertyInfo arginfo = func->get_argument_type(i);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED