summaryrefslogtreecommitdiff
path: root/editor/doc_tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/doc_tools.cpp')
-rw-r--r--editor/doc_tools.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index 6acf654b04..a9d18e9dcc 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -534,11 +534,11 @@ void DocTools::generate(bool p_basic_types) {
Vector<Error> errs = ClassDB::get_method_error_return_values(name, E.name);
if (errs.size()) {
- if (errs.find(OK) == -1) {
+ if (!errs.has(OK)) {
errs.insert(0, OK);
}
for (int i = 0; i < errs.size(); i++) {
- if (method.errors_returned.find(errs[i]) == -1) {
+ if (!method.errors_returned.has(errs[i])) {
method.errors_returned.push_back(errs[i]);
}
}
@@ -1356,7 +1356,12 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
header += " inherits=\"" + c.inherits + "\"";
}
header += String(" version=\"") + VERSION_BRANCH + "\"";
- header += ">";
+ // Reference the XML schema so editors can provide error checking.
+ // Modules are nested deep, so change the path to reference the same schema everywhere.
+ const String schema_path = save_path.find("modules/") != -1 ? "../../../doc/class.xsd" : "../class.xsd";
+ header += vformat(
+ R"( xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="%s">)",
+ schema_path);
_write_string(f, 0, header);
_write_string(f, 1, "<brief_description>");
@@ -1370,7 +1375,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
_write_string(f, 1, "<tutorials>");
for (int i = 0; i < c.tutorials.size(); i++) {
DocData::TutorialDoc tutorial = c.tutorials.get(i);
- String title_attribute = (!tutorial.title.is_empty()) ? " title=\"" + tutorial.title.xml_escape() + "\"" : "";
+ String title_attribute = (!tutorial.title.is_empty()) ? " title=\"" + _translate_doc_string(tutorial.title).xml_escape() + "\"" : "";
_write_string(f, 2, "<link" + title_attribute + ">" + tutorial.link.xml_escape() + "</link>");
}
_write_string(f, 1, "</tutorials>");
@@ -1463,7 +1468,8 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
Error DocTools::load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size) {
Vector<uint8_t> data;
data.resize(p_uncompressed_size);
- Compression::decompress(data.ptrw(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE);
+ int ret = Compression::decompress(data.ptrw(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE);
+ ERR_FAIL_COND_V_MSG(ret == -1, ERR_FILE_CORRUPT, "Compressed file is corrupt.");
class_list.clear();
Ref<XMLParser> parser = memnew(XMLParser);