1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add keywords to the class reference

Allows for finding methods, properties, signals, constants,
theme items and annotations more easily.

- Allow "keywords" attribute in aforementioned locations
  in the class reference XMLs
- Extends doctool, to preserve these attributes
- Update the XSD schema for the class reference
- Update the RST generator to include a meta tag for class keywords
- Update the editor help to support filtering by keywords
This commit is contained in:
RedMser
2023-07-03 18:18:46 +02:00
parent 94dbf69f5d
commit db798b29b2
6 changed files with 163 additions and 29 deletions

View File

@@ -117,6 +117,7 @@ public:
bool is_experimental = false;
Vector<ArgumentDoc> arguments;
Vector<int> errors_returned;
String keywords;
bool operator<(const MethodDoc &p_method) const {
if (name == p_method.name) {
// Must be an operator or a constructor since there is no other overloading
@@ -195,6 +196,10 @@ public:
doc.errors_returned.push_back(errors_returned[i]);
}
if (p_dict.has("keywords")) {
doc.keywords = p_dict["keywords"];
}
return doc;
}
static Dictionary to_dict(const MethodDoc &p_doc) {
@@ -225,6 +230,10 @@ public:
dict["is_experimental"] = p_doc.is_experimental;
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
}
if (!p_doc.arguments.is_empty()) {
Array arguments;
for (int i = 0; i < p_doc.arguments.size(); i++) {
@@ -254,6 +263,7 @@ public:
String description;
bool is_deprecated = false;
bool is_experimental = false;
String keywords;
bool operator<(const ConstantDoc &p_const) const {
return name < p_const.name;
}
@@ -291,6 +301,10 @@ public:
doc.is_experimental = p_dict["is_experimental"];
}
if (p_dict.has("keywords")) {
doc.keywords = p_dict["keywords"];
}
return doc;
}
static Dictionary to_dict(const ConstantDoc &p_doc) {
@@ -319,6 +333,10 @@ public:
dict["is_experimental"] = p_doc.is_experimental;
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
}
return dict;
}
};
@@ -335,6 +353,7 @@ public:
String overrides;
bool is_deprecated = false;
bool is_experimental = false;
String keywords;
bool operator<(const PropertyDoc &p_prop) const {
return name.naturalcasecmp_to(p_prop.name) < 0;
}
@@ -388,6 +407,10 @@ public:
doc.is_experimental = p_dict["is_experimental"];
}
if (p_dict.has("keywords")) {
doc.keywords = p_dict["keywords"];
}
return doc;
}
static Dictionary to_dict(const PropertyDoc &p_doc) {
@@ -432,6 +455,10 @@ public:
dict["is_experimental"] = p_doc.is_experimental;
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
}
return dict;
}
};
@@ -442,6 +469,7 @@ public:
String data_type;
String description;
String default_value;
String keywords;
bool operator<(const ThemeItemDoc &p_theme_item) const {
// First sort by the data type, then by name.
if (data_type == p_theme_item.data_type) {
@@ -472,6 +500,10 @@ public:
doc.default_value = p_dict["default_value"];
}
if (p_dict.has("keywords")) {
doc.keywords = p_dict["keywords"];
}
return doc;
}
static Dictionary to_dict(const ThemeItemDoc &p_doc) {
@@ -497,6 +529,10 @@ public:
dict["default_value"] = p_doc.default_value;
}
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
}
return dict;
}
};
@@ -573,6 +609,7 @@ public:
String inherits;
String brief_description;
String description;
String keywords;
Vector<TutorialDoc> tutorials;
Vector<MethodDoc> constructors;
Vector<MethodDoc> methods;
@@ -609,6 +646,10 @@ public:
doc.description = p_dict["description"];
}
if (p_dict.has("keywords")) {
doc.keywords = p_dict["keywords"];
}
Array tutorials;
if (p_dict.has("tutorials")) {
tutorials = p_dict["tutorials"];
@@ -816,6 +857,10 @@ public:
dict["script_path"] = p_doc.script_path;
}
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
}
return dict;
}
};