summaryrefslogtreecommitdiff
path: root/editor/editor_help.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_help.cpp')
-rw-r--r--editor/editor_help.cpp62
1 files changed, 48 insertions, 14 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 1842d5e1e9..5917869988 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -97,8 +97,10 @@ void EditorHelp::_class_desc_select(const String &p_select) {
emit_signal("go_to_help", "class_name:" + p_select.substr(1, p_select.length()));
return;
} else if (p_select.begins_with("@")) {
- String tag = p_select.substr(1, 6);
- String link = p_select.substr(7, p_select.length());
+ int tag_end = p_select.find(" ");
+
+ String tag = p_select.substr(1, tag_end - 1);
+ String link = p_select.substr(tag_end + 1, p_select.length()).lstrip(" ");
String topic;
Map<String, int> *table = NULL;
@@ -109,24 +111,50 @@ void EditorHelp::_class_desc_select(const String &p_select) {
} else if (tag == "member") {
topic = "class_property";
table = &this->property_line;
- } else if (tag == "enum ") {
+ } else if (tag == "enum") {
topic = "class_enum";
table = &this->enum_line;
} else if (tag == "signal") {
topic = "class_signal";
table = &this->signal_line;
+ } else if (tag == "constant") {
+ topic = "class_constant";
+ table = &this->constant_line;
} else {
return;
}
if (link.find(".") != -1) {
-
emit_signal("go_to_help", topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1));
} else {
-
- if (!table->has(link))
- return;
- class_desc->scroll_to_line((*table)[link]);
+ if (table->has(link)) {
+ // Found in the current page
+ class_desc->scroll_to_line((*table)[link]);
+ } else {
+ if (topic == "class_enum") {
+ // Try to find the enum in @GlobalScope
+ const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"];
+
+ for (int i = 0; i < cd.constants.size(); i++) {
+ if (cd.constants[i].enumeration == link) {
+ // Found in @GlobalScope
+ emit_signal("go_to_help", topic + ":@GlobalScope:" + link);
+ break;
+ }
+ }
+ } else if (topic == "class_constant") {
+ // Try to find the constant in @GlobalScope
+ const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"];
+
+ for (int i = 0; i < cd.constants.size(); i++) {
+ if (cd.constants[i].name == link) {
+ // Found in @GlobalScope
+ emit_signal("go_to_help", topic + ":@GlobalScope:" + link);
+ break;
+ }
+ }
+ }
+ }
}
} else if (p_select.begins_with("http")) {
OS::get_singleton()->shell_open(p_select);
@@ -204,7 +232,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
}
if (p_overview && p_method.description != "") {
- class_desc->push_meta("@method" + p_method.name);
+ class_desc->push_meta("@method " + p_method.name);
}
class_desc->push_color(headline_color);
@@ -442,7 +470,7 @@ void EditorHelp::_update_doc() {
}
class_desc->push_cell();
if (describe) {
- class_desc->push_meta("@member" + cd.properties[i].name);
+ class_desc->push_meta("@member " + cd.properties[i].name);
}
class_desc->push_font(doc_code_font);
@@ -734,6 +762,9 @@ void EditorHelp::_update_doc() {
if (cd.name == "@GlobalScope")
enumValuesContainer[enum_list[i].name] = enumStartingLine;
+ // Add the enum constant line to the constant_line map so we can locate it as a constant
+ constant_line[enum_list[i].name] = class_desc->get_line_count() - 2;
+
class_desc->push_font(doc_code_font);
class_desc->push_color(headline_color);
_add_text(enum_list[i].name);
@@ -1161,12 +1192,15 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
p_rt->add_text("[");
pos = brk_pos + 1;
- } else if (tag.begins_with("method ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ")) {
+ } else if (tag.begins_with("method ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ")) {
+
+ int tag_end = tag.find(" ");
+
+ String link_tag = tag.substr(0, tag_end);
+ String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" ");
- String link_target = tag.substr(tag.find(" ") + 1, tag.length());
- String link_tag = tag.substr(0, tag.find(" ")).rpad(6);
p_rt->push_color(link_color);
- p_rt->push_meta("@" + link_tag + link_target);
+ p_rt->push_meta("@" + link_tag + " " + link_target);
p_rt->add_text(link_target + (tag.begins_with("method ") ? "()" : ""));
p_rt->pop();
p_rt->pop();