Fix classes.xml sorting
Make methods, signals, theme items and constants sort correctly
(cherry picked from commit 9bde4e5652
+ a needed change from e8eb396d7cfec8a96efb78719c0556f1beccf68)
This commit is contained in:
parent
1a3d408f52
commit
2389712638
|
@ -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<String,ClassDoc>::Element *E=class_list.front();E;E=E->next()) {
|
||||
|
@ -938,6 +953,8 @@ Error DocData::save(const String& p_path) {
|
|||
_write_string(f,1,"</description>");
|
||||
_write_string(f,1,"<methods>");
|
||||
|
||||
c.methods.sort();
|
||||
|
||||
for(int i=0;i<c.methods.size();i++) {
|
||||
|
||||
MethodDoc &m=c.methods[i];
|
||||
|
@ -980,6 +997,8 @@ Error DocData::save(const String& p_path) {
|
|||
if (c.properties.size()) {
|
||||
_write_string(f,1,"<members>");
|
||||
|
||||
c.properties.sort();
|
||||
|
||||
for(int i=0;i<c.properties.size();i++) {
|
||||
|
||||
|
||||
|
@ -995,6 +1014,8 @@ Error DocData::save(const String& p_path) {
|
|||
|
||||
if (c.signals.size()) {
|
||||
|
||||
c.signals.sort();
|
||||
|
||||
_write_string(f,1,"<signals>");
|
||||
for(int i=0;i<c.signals.size();i++) {
|
||||
|
||||
|
@ -1021,6 +1042,8 @@ Error DocData::save(const String& p_path) {
|
|||
|
||||
_write_string(f,1,"<constants>");
|
||||
|
||||
c.constants.sort_custom<_ConstantComparator>();
|
||||
|
||||
for(int i=0;i<c.constants.size();i++) {
|
||||
|
||||
ConstantDoc &k=c.constants[i];
|
||||
|
@ -1033,6 +1056,9 @@ Error DocData::save(const String& p_path) {
|
|||
_write_string(f,1,"</constants>");
|
||||
|
||||
if (c.theme_properties.size()) {
|
||||
|
||||
c.theme_properties.sort();
|
||||
|
||||
_write_string(f,1,"<theme_items>");
|
||||
for(int i=0;i<c.theme_properties.size();i++) {
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
String qualifiers;
|
||||
String description;
|
||||
Vector<ArgumentDoc> arguments;
|
||||
bool operator<(const MethodDoc& p_md) const {
|
||||
return name<p_md.name;
|
||||
}
|
||||
};
|
||||
|
||||
struct ConstantDoc {
|
||||
|
@ -64,6 +67,9 @@ public:
|
|||
String name;
|
||||
String type;
|
||||
String description;
|
||||
bool operator<(const PropertyDoc& p_prop) const {
|
||||
return name<p_prop.name;
|
||||
}
|
||||
};
|
||||
|
||||
struct ClassDoc {
|
||||
|
|
Loading…
Reference in New Issue