From 2389712638cfc95155a9e062253cfc7e44c6c0dc Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 21 Jun 2016 17:20:34 -0300 Subject: [PATCH] Fix classes.xml sorting Make methods, signals, theme items and constants sort correctly (cherry picked from commit 9bde4e565237b60f3543491839a38211ca717e9d + a needed change from e8eb396d7cfec8a96efb78719c0556f1beccf68) --- tools/doc/doc_data.cpp | 26 ++++++++++++++++++++++++++ tools/doc/doc_data.h | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp index a26690a02fd..a08f3b7b7b2 100644 --- a/tools/doc/doc_data.cpp +++ b/tools/doc/doc_data.cpp @@ -36,6 +36,21 @@ #include "io/compression.h" #include "scene/resources/theme.h" +struct _ConstantComparator { + + inline bool operator()(const DocData::ConstantDoc &a, const DocData::ConstantDoc &b) const { + String left_a = a.name.find("_") == -1 ? a.name : a.name.substr(0, a.name.find("_")); + String left_b = b.name.find("_") == -1 ? b.name : b.name.substr(0, b.name.find("_")); + if (left_a == left_b) // If they have the same prefix + if (a.value == b.value) + return a.name < b.name; // Sort by name if the values are the same + else + return a.value < b.value; // Sort by value otherwise + else + return left_a < left_b; // Sort by name if the prefixes aren't the same + } +}; + void DocData::merge_from(const DocData& p_data) { for( Map::Element *E=class_list.front();E;E=E->next()) { @@ -938,6 +953,8 @@ Error DocData::save(const String& p_path) { _write_string(f,1,""); _write_string(f,1,""); + c.methods.sort(); + for(int i=0;i"); + c.properties.sort(); + for(int i=0;i"); for(int i=0;i"); + c.constants.sort_custom<_ConstantComparator>(); + for(int i=0;i"); if (c.theme_properties.size()) { + + c.theme_properties.sort(); + _write_string(f,1,""); for(int i=0;i arguments; + bool operator<(const MethodDoc& p_md) const { + return name