You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Implement error return documetation
Adds ability to add error return documetation to the binder and class reference.
Usage example:
```C++
void MyClass::_bind_method() {
[..]
BIND_METHOD_ERR_RETURN_DOC("load", ERR_FILE_CANT_OPEN, ERR_FILE_UNRECOGNIZED);
}
```
One function of ConfigFile was changed as example.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "editor_help.h"
|
||||
|
||||
#include "core/core_constants.h"
|
||||
#include "core/input/input.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "doc_data_compressed.gen.h"
|
||||
@@ -695,7 +696,7 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->pop(); //cell
|
||||
}
|
||||
|
||||
if (m[i].description != "") {
|
||||
if (m[i].description != "" || m[i].errors_returned.size() > 0) {
|
||||
method_descr = true;
|
||||
}
|
||||
|
||||
@@ -1227,6 +1228,31 @@ void EditorHelp::_update_doc() {
|
||||
class_desc->push_color(text_color);
|
||||
class_desc->push_font(doc_font);
|
||||
class_desc->push_indent(1);
|
||||
if (methods_filtered[i].errors_returned.size()) {
|
||||
class_desc->append_bbcode(TTR("Error codes returned:"));
|
||||
class_desc->add_newline();
|
||||
class_desc->push_list(0, RichTextLabel::LIST_DOTS, false);
|
||||
for (int j = 0; j < methods_filtered[i].errors_returned.size(); j++) {
|
||||
if (j > 0) {
|
||||
class_desc->add_newline();
|
||||
}
|
||||
int val = methods_filtered[i].errors_returned[j];
|
||||
String text = itos(val);
|
||||
for (int k = 0; k < CoreConstants::get_global_constant_count(); k++) {
|
||||
if (CoreConstants::get_global_constant_value(k) == val && CoreConstants::get_global_constant_enum(k) == SNAME("Error")) {
|
||||
text = CoreConstants::get_global_constant_name(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
class_desc->push_bold();
|
||||
class_desc->append_bbcode(text);
|
||||
class_desc->pop();
|
||||
}
|
||||
class_desc->pop();
|
||||
class_desc->add_newline();
|
||||
class_desc->add_newline();
|
||||
}
|
||||
if (!methods_filtered[i].description.strip_edges().is_empty()) {
|
||||
_add_text(DTR(methods_filtered[i].description));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user