Merge pull request #78649 from MewPurPur/dont-link-to-own-page

Tweak documentation to use bold font when a class is referencing itself
This commit is contained in:
Yuri Sizov 2023-07-12 17:16:47 +02:00
commit 22b4861d7b
1 changed files with 17 additions and 10 deletions

View File

@ -1906,7 +1906,7 @@ void EditorHelp::_help_callback(const String &p_topic) {
} }
} }
static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control *p_owner_node) { static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control *p_owner_node, const String &p_class = "") {
DocTools *doc = EditorHelp::get_doc_data(); DocTools *doc = EditorHelp::get_doc_data();
String base_path; String base_path;
@ -2107,21 +2107,28 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control
p_rt->pop(); // font p_rt->pop(); // font
pos = brk_end + 1; pos = brk_end + 1;
} else if (tag == p_class) {
// Use a bold font when class reference tags are in their own page.
p_rt->push_font(doc_bold_font);
p_rt->add_text(tag);
p_rt->pop();
pos = brk_end + 1;
} else if (doc->class_list.has(tag)) { } else if (doc->class_list.has(tag)) {
// Class reference tag such as [Node2D] or [SceneTree]. // Use a monospace font for class reference tags such as [Node2D] or [SceneTree].
// Use monospace font to make clickable references
// easier to distinguish from inline code and other text.
p_rt->push_font(doc_code_font); p_rt->push_font(doc_code_font);
p_rt->push_font_size(doc_code_font_size); p_rt->push_font_size(doc_code_font_size);
p_rt->push_color(type_color); p_rt->push_color(type_color);
p_rt->push_meta("#" + tag); p_rt->push_meta("#" + tag);
p_rt->add_text(tag); p_rt->add_text(tag);
p_rt->pop();
p_rt->pop();
p_rt->pop(); // font size p_rt->pop();
p_rt->pop(); // font p_rt->pop();
p_rt->pop(); // Font size
p_rt->pop(); // Font
pos = brk_end + 1; pos = brk_end + 1;
} else if (tag == "b") { } else if (tag == "b") {
@ -2252,7 +2259,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control
} }
void EditorHelp::_add_text(const String &p_bbcode) { void EditorHelp::_add_text(const String &p_bbcode) {
_add_text_to_rt(p_bbcode, class_desc, this); _add_text_to_rt(p_bbcode, class_desc, this, edited_class);
} }
Thread EditorHelp::thread; Thread EditorHelp::thread;