Skip to content

Commit

Permalink
Change in-editor documentation style to be closer to online docs.
Browse files Browse the repository at this point in the history
(cherry picked from commit 1e3c02d)
  • Loading branch information
bruvzg authored and akien-mga committed Oct 7, 2021
1 parent 81da3b8 commit 583c6d3
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
if (p_overview) {
class_desc->push_cell();
class_desc->push_align(RichTextLabel::ALIGN_RIGHT);
} else {
static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
class_desc->add_text(String(prefix));
}

_add_type(p_method.return_type, p_method.return_enum);
Expand Down Expand Up @@ -367,7 +370,6 @@ void EditorHelp::_update_doc() {
class_desc->push_color(title_color);
class_desc->push_font(doc_font);
class_desc->add_text(TTR("Inherits:") + " ");
class_desc->pop();

String inherits = cd.inherits;

Expand All @@ -381,6 +383,7 @@ void EditorHelp::_update_doc() {
}
}

class_desc->pop();
class_desc->pop();
class_desc->add_newline();
}
Expand All @@ -390,13 +393,12 @@ void EditorHelp::_update_doc() {
bool found = false;
bool prev = false;

class_desc->push_font(doc_font);
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
if (E->get().inherits == cd.name) {
if (!found) {
class_desc->push_color(title_color);
class_desc->push_font(doc_font);
class_desc->add_text(TTR("Inherited by:") + " ");
class_desc->pop();
found = true;
}

Expand All @@ -408,6 +410,7 @@ void EditorHelp::_update_doc() {
prev = true;
}
}
class_desc->pop();

if (found) {
class_desc->pop();
Expand Down Expand Up @@ -747,6 +750,8 @@ void EditorHelp::_update_doc() {
signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
class_desc->push_font(doc_code_font); // monofont
class_desc->push_color(headline_color);
static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
class_desc->add_text(String(prefix));
_add_text(cd.signals[i].name);
class_desc->pop();
class_desc->push_color(symbol_color);
Expand Down Expand Up @@ -824,10 +829,10 @@ void EditorHelp::_update_doc() {
for (Map<String, Vector<DocData::ConstantDoc>>::Element *E = enums.front(); E; E = E->next()) {
enum_line[E->key()] = class_desc->get_line_count() - 2;

class_desc->push_font(doc_code_font);
class_desc->push_color(title_color);
class_desc->add_text("enum ");
class_desc->pop();
class_desc->push_font(doc_code_font);
String e = E->key();
if ((e.get_slice_count(".") > 1) && (e.get_slice(".", 0) == edited_class)) {
e = e.get_slice(".", 1);
Expand All @@ -840,6 +845,8 @@ void EditorHelp::_update_doc() {
class_desc->push_color(symbol_color);
class_desc->add_text(":");
class_desc->pop();

class_desc->add_newline();
class_desc->add_newline();

class_desc->push_indent(1);
Expand All @@ -858,6 +865,8 @@ void EditorHelp::_update_doc() {

class_desc->push_font(doc_code_font);
class_desc->push_color(headline_color);
static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
class_desc->add_text(String(prefix));
_add_text(enum_list[i].name);
class_desc->pop();
class_desc->push_color(symbol_color);
Expand All @@ -869,14 +878,15 @@ void EditorHelp::_update_doc() {
class_desc->pop();
if (enum_list[i].description != "") {
class_desc->push_font(doc_font);
//class_desc->add_text(" ");
class_desc->push_indent(1);
class_desc->push_color(comment_color);
static const CharType dash[6] = { ' ', ' ', 0x2013 /* en dash */, ' ', ' ', 0 };
class_desc->add_text(String(dash));
_add_text(DTR(enum_list[i].description));
class_desc->pop();
class_desc->pop();
class_desc->pop(); // indent
class_desc->add_newline();
if (DTR(enum_list[i].description).find("\n") > 0) {
class_desc->add_newline();
}
}

class_desc->add_newline();
Expand Down Expand Up @@ -920,6 +930,9 @@ void EditorHelp::_update_doc() {
class_desc->add_text(String(prefix));
class_desc->pop();
}
} else {
static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
class_desc->add_text(String(prefix));
}

class_desc->push_color(headline_color);
Expand All @@ -935,13 +948,15 @@ void EditorHelp::_update_doc() {
class_desc->pop();
if (constants[i].description != "") {
class_desc->push_font(doc_font);
class_desc->push_indent(1);
class_desc->push_color(comment_color);
static const CharType dash[6] = { ' ', ' ', 0x2013 /* en dash */, ' ', ' ', 0 };
class_desc->add_text(String(dash));
_add_text(DTR(constants[i].description));
class_desc->pop();
class_desc->pop();
class_desc->pop(); // indent
class_desc->add_newline();
if (DTR(constants[i].description).find("\n") > 0) {
class_desc->add_newline();
}
}

class_desc->add_newline();
Expand Down Expand Up @@ -976,6 +991,9 @@ void EditorHelp::_update_doc() {

class_desc->push_cell();
class_desc->push_font(doc_code_font);
static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
class_desc->add_text(String(prefix));

_add_type(cd.properties[i].type, cd.properties[i].enumeration);
class_desc->add_text(" ");
class_desc->pop(); // font
Expand Down

0 comments on commit 583c6d3

Please sign in to comment.