Added a "title" attribute for the link tag in the docs xml
(cherry picked from commit 18c08f65d6
)
This commit is contained in:
parent
24b3bf0637
commit
fda49b74a1
|
@ -9,7 +9,7 @@
|
||||||
[b]Kinematic characters:[/b] KinematicBody2D also has an API for moving objects (the [method move_and_collide] and [method move_and_slide] methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
|
[b]Kinematic characters:[/b] KinematicBody2D also has an API for moving objects (the [method move_and_collide] and [method move_and_slide] methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
<link>https://docs.godotengine.org/en/latest/tutorials/physics/kinematic_character_2d.html</link>
|
<link title="Kinematic character (2D)">https://docs.godotengine.org/en/latest/tutorials/physics/kinematic_character_2d.html</link>
|
||||||
<link>https://docs.godotengine.org/en/latest/tutorials/physics/using_kinematic_body_2d.html</link>
|
<link>https://docs.godotengine.org/en/latest/tutorials/physics/using_kinematic_body_2d.html</link>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<methods>
|
<methods>
|
||||||
|
|
|
@ -873,10 +873,15 @@ Error DocData::_load(Ref<XMLParser> parser) {
|
||||||
String name3 = parser->get_node_name();
|
String name3 = parser->get_node_name();
|
||||||
|
|
||||||
if (name3 == "link") {
|
if (name3 == "link") {
|
||||||
|
TutorialDoc tutorial;
|
||||||
|
if (parser->has_attribute("title")) {
|
||||||
|
tutorial.title = parser->get_attribute_value("title");
|
||||||
|
}
|
||||||
parser->read();
|
parser->read();
|
||||||
if (parser->get_node_type() == XMLParser::NODE_TEXT)
|
if (parser->get_node_type() == XMLParser::NODE_TEXT) {
|
||||||
c.tutorials.push_back(parser->get_node_data().strip_edges());
|
tutorial.link = parser->get_node_data().strip_edges();
|
||||||
|
c.tutorials.push_back(tutorial);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
|
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1056,9 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
|
||||||
|
|
||||||
_write_string(f, 1, "<tutorials>");
|
_write_string(f, 1, "<tutorials>");
|
||||||
for (int i = 0; i < c.tutorials.size(); i++) {
|
for (int i = 0; i < c.tutorials.size(); i++) {
|
||||||
_write_string(f, 2, "<link>" + c.tutorials.get(i).xml_escape() + "</link>");
|
TutorialDoc tutorial = c.tutorials.get(i);
|
||||||
|
String title_attribute = (!tutorial.title.empty()) ? " title=\"" + tutorial.title.xml_escape() + "\"" : "";
|
||||||
|
_write_string(f, 2, "<link" + title_attribute + ">" + tutorial.link.xml_escape() + "</link>");
|
||||||
}
|
}
|
||||||
_write_string(f, 1, "</tutorials>");
|
_write_string(f, 1, "</tutorials>");
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,11 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TutorialDoc {
|
||||||
|
String link;
|
||||||
|
String title;
|
||||||
|
};
|
||||||
|
|
||||||
struct ClassDoc {
|
struct ClassDoc {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
|
@ -90,7 +95,7 @@ public:
|
||||||
String category;
|
String category;
|
||||||
String brief_description;
|
String brief_description;
|
||||||
String description;
|
String description;
|
||||||
Vector<String> tutorials;
|
Vector<TutorialDoc> tutorials;
|
||||||
Vector<MethodDoc> methods;
|
Vector<MethodDoc> methods;
|
||||||
Vector<MethodDoc> signals;
|
Vector<MethodDoc> signals;
|
||||||
Vector<ConstantDoc> constants;
|
Vector<ConstantDoc> constants;
|
||||||
|
|
|
@ -478,8 +478,8 @@ void EditorHelp::_update_doc() {
|
||||||
class_desc->add_newline();
|
class_desc->add_newline();
|
||||||
|
|
||||||
for (int i = 0; i < cd.tutorials.size(); i++) {
|
for (int i = 0; i < cd.tutorials.size(); i++) {
|
||||||
const String link = cd.tutorials[i];
|
const String link = cd.tutorials[i].link;
|
||||||
String linktxt = link;
|
String linktxt = (cd.tutorials[i].title.empty()) ? link : cd.tutorials[i].title;
|
||||||
const int seppos = linktxt.find("//");
|
const int seppos = linktxt.find("//");
|
||||||
if (seppos != -1) {
|
if (seppos != -1) {
|
||||||
linktxt = link.right(seppos + 2);
|
linktxt = link.right(seppos + 2);
|
||||||
|
|
Loading…
Reference in New Issue