|
@@ -1403,7 +1403,7 @@ static void _write_method_doc(Ref<FileAccess> f, const String &p_name, Vector<Do
|
|
|
if (!m.return_enum.is_empty()) {
|
|
|
enum_text = " enum=\"" + m.return_enum + "\"";
|
|
|
}
|
|
|
- _write_string(f, 3, "<return type=\"" + m.return_type + "\"" + enum_text + " />");
|
|
|
+ _write_string(f, 3, "<return type=\"" + m.return_type.xml_escape(true) + "\"" + enum_text + " />");
|
|
|
}
|
|
|
if (m.errors_returned.size() > 0) {
|
|
|
for (int j = 0; j < m.errors_returned.size(); j++) {
|
|
@@ -1420,9 +1420,9 @@ static void _write_method_doc(Ref<FileAccess> f, const String &p_name, Vector<Do
|
|
|
}
|
|
|
|
|
|
if (!a.default_value.is_empty()) {
|
|
|
- _write_string(f, 3, "<param index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\" />");
|
|
|
+ _write_string(f, 3, "<param index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape(true) + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\" />");
|
|
|
} else {
|
|
|
- _write_string(f, 3, "<param index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " />");
|
|
|
+ _write_string(f, 3, "<param index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape(true) + "\"" + enum_text + " />");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1437,7 +1437,7 @@ static void _write_method_doc(Ref<FileAccess> f, const String &p_name, Vector<Do
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Error DocTools::save_classes(const String &p_default_path, const HashMap<String, String> &p_class_path) {
|
|
|
+Error DocTools::save_classes(const String &p_default_path, const HashMap<String, String> &p_class_path, bool p_include_xml_schema) {
|
|
|
for (KeyValue<String, DocData::ClassDoc> &E : class_list) {
|
|
|
DocData::ClassDoc &c = E.value;
|
|
|
|
|
@@ -1449,16 +1449,16 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
|
|
|
}
|
|
|
|
|
|
Error err;
|
|
|
- String save_file = save_path.path_join(c.name + ".xml");
|
|
|
+ String save_file = save_path.path_join(c.name.replace("\"", "").replace("/", "--") + ".xml");
|
|
|
Ref<FileAccess> f = FileAccess::open(save_file, FileAccess::WRITE, &err);
|
|
|
|
|
|
ERR_CONTINUE_MSG(err != OK, "Can't write doc file: " + save_file + ".");
|
|
|
|
|
|
_write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
|
|
|
|
|
|
- String header = "<class name=\"" + c.name + "\"";
|
|
|
+ String header = "<class name=\"" + c.name.xml_escape(true) + "\"";
|
|
|
if (!c.inherits.is_empty()) {
|
|
|
- header += " inherits=\"" + c.inherits + "\"";
|
|
|
+ header += " inherits=\"" + c.inherits.xml_escape(true) + "\"";
|
|
|
if (c.is_deprecated) {
|
|
|
header += " is_deprecated=\"true\"";
|
|
|
}
|
|
@@ -1467,12 +1467,15 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
|
|
|
}
|
|
|
}
|
|
|
header += String(" version=\"") + VERSION_BRANCH + "\"";
|
|
|
- // 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);
|
|
|
+ if (p_include_xml_schema) {
|
|
|
+ // 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);
|
|
|
+ }
|
|
|
+ header += ">";
|
|
|
_write_string(f, 0, header);
|
|
|
|
|
|
_write_string(f, 1, "<brief_description>");
|
|
@@ -1518,9 +1521,9 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
|
|
|
const DocData::PropertyDoc &p = c.properties[i];
|
|
|
|
|
|
if (c.properties[i].overridden) {
|
|
|
- _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" overrides=\"" + p.overrides + "\"" + additional_attributes + " />");
|
|
|
+ _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type.xml_escape(true) + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" overrides=\"" + p.overrides + "\"" + additional_attributes + " />");
|
|
|
} else {
|
|
|
- _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">");
|
|
|
+ _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type.xml_escape(true) + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">");
|
|
|
_write_string(f, 3, _translate_doc_string(p.description).strip_edges().xml_escape());
|
|
|
_write_string(f, 2, "</member>");
|
|
|
}
|
|
@@ -1546,12 +1549,12 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
|
|
|
if (k.is_value_valid) {
|
|
|
if (!k.enumeration.is_empty()) {
|
|
|
if (k.is_bitfield) {
|
|
|
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\" is_bitfield=\"true\"" + additional_attributes + ">");
|
|
|
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value.xml_escape(true) + "\" enum=\"" + k.enumeration + "\" is_bitfield=\"true\"" + additional_attributes + ">");
|
|
|
} else {
|
|
|
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\"" + additional_attributes + ">");
|
|
|
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value.xml_escape(true) + "\" enum=\"" + k.enumeration + "\"" + additional_attributes + ">");
|
|
|
}
|
|
|
} else {
|
|
|
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\"" + additional_attributes + ">");
|
|
|
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value.xml_escape(true) + "\"" + additional_attributes + ">");
|
|
|
}
|
|
|
} else {
|
|
|
if (!k.enumeration.is_empty()) {
|