summaryrefslogtreecommitdiff
path: root/editor/doc
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-09-24 13:34:03 +0200
committerRémi Verschelde <rverschelde@gmail.com>2019-09-24 13:34:05 +0200
commita7ac8ec8764aa745605a01fdb50882a60e8c69ba (patch)
tree8f3fa5689e57479f4414af96209b0694443b9a90 /editor/doc
parent2f52d73c21fb9e532dd8b71e9b18f31cd7996277 (diff)
doc: Fix parsing of self-closing XML tags
Follow-up to #31925, `<member />` tags just before `</members>` would cause a parsing issue, and we'd never notice that we're no longer parsing members. Also added space before closing `/>`.
Diffstat (limited to 'editor/doc')
-rw-r--r--editor/doc/doc_data.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp
index 1a0f8e5257..d472b41f2e 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc/doc_data.cpp
@@ -872,7 +872,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "tutorials")
- break; //end of <tutorials>
+ break; // End of <tutorials>.
}
} else if (name2 == "methods") {
@@ -905,16 +905,18 @@ Error DocData::_load(Ref<XMLParser> parser) {
prop2.getter = parser->get_attribute_value("getter");
if (parser->has_attribute("enum"))
prop2.enumeration = parser->get_attribute_value("enum");
- parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
- prop2.description = parser->get_node_data();
+ if (!parser->is_empty()) {
+ parser->read();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ prop2.description = parser->get_node_data();
+ }
c.properties.push_back(prop2);
} else {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members")
- break; //end of <constants>
+ break; // End of <members>.
}
} else if (name2 == "theme_items") {
@@ -933,16 +935,18 @@ Error DocData::_load(Ref<XMLParser> parser) {
prop2.name = parser->get_attribute_value("name");
ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
prop2.type = parser->get_attribute_value("type");
- parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
- prop2.description = parser->get_node_data();
+ if (!parser->is_empty()) {
+ parser->read();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ prop2.description = parser->get_node_data();
+ }
c.theme_properties.push_back(prop2);
} else {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items")
- break; //end of <constants>
+ break; // End of <theme_items>.
}
} else if (name2 == "constants") {
@@ -963,16 +967,18 @@ Error DocData::_load(Ref<XMLParser> parser) {
if (parser->has_attribute("enum")) {
constant2.enumeration = parser->get_attribute_value("enum");
}
- parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
- constant2.description = parser->get_node_data();
+ if (!parser->is_empty()) {
+ parser->read();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ constant2.description = parser->get_node_data();
+ }
c.constants.push_back(constant2);
} else {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants")
- break; //end of <constants>
+ break; // End of <constants>.
}
} else {
@@ -981,7 +987,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
}
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class")
- break; //end of <asset>
+ break; // End of <class>.
}
}
@@ -1109,7 +1115,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
const 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 + "\" override=\"true\"" + additional_attributes + "/>");
+ _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" override=\"true\"" + 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, 3, p.description.strip_edges().xml_escape());