diff options
author | Zher Huei Lee <lee.zh.92@gmail.com> | 2017-10-11 16:27:54 +0800 |
---|---|---|
committer | Zher Huei Lee <lee.zh.92@gmail.com> | 2017-11-01 07:20:20 +0800 |
commit | 0804dd53364107001f31948a9ec9fe331bc92a4a (patch) | |
tree | b40719054bdae31832e870a17d88ab7a20ff8ba9 /editor | |
parent | 29ea79e065cb1ecffec6b8ad17d9996f21abf1cb (diff) |
Added String::dedent() to remove text indentation
This functions similarly to Python's textwrap.dedent()
It's also been applied to doc_data.cpp to remove extra whitespace while
parsing the XML.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/doc/doc_data.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index d35dc53ae1..057b2d827d 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -615,6 +615,11 @@ void DocData::generate(bool p_basic_types) { } } +static String _format_description(const String &string) { + + return string.dedent().strip_edges().replace("\n", "\n\n"); +} + static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &methods) { String section = parser->get_node_name(); @@ -661,7 +666,7 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> & parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - method.description = parser->get_node_data().strip_edges(); + method.description = _format_description(parser->get_node_data()); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == element) @@ -776,12 +781,12 @@ Error DocData::_load(Ref<XMLParser> parser) { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.brief_description = parser->get_node_data().strip_edges(); + c.brief_description = _format_description(parser->get_node_data()); } else if (name == "description") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.description = parser->get_node_data().strip_edges(); + c.description = _format_description(parser->get_node_data()); } else if (name == "tutorials") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) @@ -823,7 +828,7 @@ Error DocData::_load(Ref<XMLParser> parser) { prop.enumeration = parser->get_attribute_value("enum"); parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - prop.description = parser->get_node_data().strip_edges(); + prop.description = _format_description(parser->get_node_data()); c.properties.push_back(prop); } else { ERR_EXPLAIN("Invalid tag in doc file: " + name); |