diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-06-13 14:29:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-13 14:29:45 +0200 |
commit | f0fa5902100b5b2a6207b1656cf90af3c36bd213 (patch) | |
tree | b901e9760a7bade5ad0c0c48d55c21e5c1c7d39f /editor | |
parent | 62b75a94ec9c746aa6f58dad39ca2917428a38f1 (diff) | |
parent | 98b59cf2a387e469851eee137cc6310cfc4b2a6d (diff) |
Merge pull request #19526 from robojumper/fix_tutorials
Add support for tutorial links to makerst.py
Diffstat (limited to 'editor')
-rw-r--r-- | editor/doc/doc_data.cpp | 25 | ||||
-rw-r--r-- | editor/doc/doc_data.h | 2 | ||||
-rw-r--r-- | editor/editor_help.cpp | 7 |
3 files changed, 25 insertions, 9 deletions
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index bbd83f5099..3a32c3f40f 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -817,9 +817,24 @@ Error DocData::_load(Ref<XMLParser> parser) { if (parser->get_node_type() == XMLParser::NODE_TEXT) c.description = parser->get_node_data(); } else if (name == "tutorials") { - parser->read(); - if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.tutorials = parser->get_node_data(); + while (parser->read() == OK) { + + if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { + + String name = parser->get_node_name(); + + if (name == "link") { + + parser->read(); + if (parser->get_node_type() == XMLParser::NODE_TEXT) + c.tutorials.push_back(parser->get_node_data().strip_edges()); + } else { + ERR_EXPLAIN("Invalid tag in doc file: " + name); + ERR_FAIL_V(ERR_FILE_CORRUPT); + } + } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "tutorials") + break; //end of <tutorials> + } } else if (name == "demos") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) @@ -994,7 +1009,9 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri _write_string(f, 2, c.description.strip_edges().xml_escape()); _write_string(f, 1, "</description>"); _write_string(f, 1, "<tutorials>"); - _write_string(f, 2, c.tutorials.strip_edges().xml_escape()); + for (int i = 0; i < c.tutorials.size(); i++) { + _write_string(f, 2, "<link>" + c.tutorials.get(i).xml_escape() + "</link>"); + } _write_string(f, 1, "</tutorials>"); _write_string(f, 1, "<demos>"); _write_string(f, 2, c.demos.strip_edges().xml_escape()); diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h index 0461133f9f..c7b70b5fb9 100644 --- a/editor/doc/doc_data.h +++ b/editor/doc/doc_data.h @@ -85,7 +85,7 @@ public: String category; String brief_description; String description; - String tutorials; + Vector<String> tutorials; String demos; Vector<MethodDoc> methods; Vector<MethodDoc> signals; diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index b49c2d26d0..65e50560bc 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1280,11 +1280,10 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->add_newline(); // class_desc->add_newline(); - Vector<String> tutorials = cd.tutorials.split_spaces(); - if (tutorials.size() != 0) { + if (cd.tutorials.size() != 0) { - for (int i = 0; i < tutorials.size(); i++) { - String link = tutorials[i]; + for (int i = 0; i < cd.tutorials.size(); i++) { + String link = cd.tutorials[i]; String linktxt = link; int seppos = linktxt.find("//"); if (seppos != -1) { |