2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* doc_data.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef DOC_DATA_H
|
|
|
|
#define DOC_DATA_H
|
|
|
|
|
2018-09-11 18:13:45 +02:00
|
|
|
#include "core/io/xml_parser.h"
|
2020-11-07 23:33:38 +01:00
|
|
|
#include "core/variant/variant.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-11-29 03:37:57 +01:00
|
|
|
struct ScriptMemberInfo {
|
|
|
|
PropertyInfo propinfo;
|
|
|
|
String doc_string;
|
|
|
|
StringName setter;
|
|
|
|
StringName getter;
|
|
|
|
|
|
|
|
bool has_default_value = false;
|
|
|
|
Variant default_value;
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
class DocData {
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
|
|
|
struct ArgumentDoc {
|
|
|
|
String name;
|
|
|
|
String type;
|
2017-08-24 00:10:32 +02:00
|
|
|
String enumeration;
|
2014-02-10 02:10:30 +01:00
|
|
|
String default_value;
|
2020-05-20 14:34:49 +02:00
|
|
|
bool operator<(const ArgumentDoc &p_arg) const {
|
2020-11-09 17:46:03 +01:00
|
|
|
if (name == p_arg.name) {
|
|
|
|
return type < p_arg.type;
|
|
|
|
}
|
2020-05-20 14:34:49 +02:00
|
|
|
return name < p_arg.name;
|
|
|
|
}
|
2022-10-10 21:58:25 +02:00
|
|
|
static ArgumentDoc from_dict(const Dictionary &p_dict) {
|
|
|
|
ArgumentDoc doc;
|
|
|
|
|
|
|
|
if (p_dict.has("name")) {
|
|
|
|
doc.name = p_dict["name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("type")) {
|
|
|
|
doc.type = p_dict["type"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("enumeration")) {
|
|
|
|
doc.enumeration = p_dict["enumeration"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("default_value")) {
|
|
|
|
doc.default_value = p_dict["default_value"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2023-02-07 21:14:00 +01:00
|
|
|
static Dictionary to_dict(const ArgumentDoc &p_doc) {
|
|
|
|
Dictionary dict;
|
|
|
|
|
|
|
|
if (!p_doc.name.is_empty()) {
|
|
|
|
dict["name"] = p_doc.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.type.is_empty()) {
|
|
|
|
dict["type"] = p_doc.type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.enumeration.is_empty()) {
|
|
|
|
dict["enumeration"] = p_doc.enumeration;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.default_value.is_empty()) {
|
|
|
|
dict["default_value"] = p_doc.default_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MethodDoc {
|
|
|
|
String name;
|
|
|
|
String return_type;
|
2017-08-24 00:10:32 +02:00
|
|
|
String return_enum;
|
2014-02-10 02:10:30 +01:00
|
|
|
String qualifiers;
|
|
|
|
String description;
|
2022-08-28 08:17:25 +02:00
|
|
|
bool is_deprecated = false;
|
|
|
|
bool is_experimental = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<ArgumentDoc> arguments;
|
2021-08-24 20:16:25 +02:00
|
|
|
Vector<int> errors_returned;
|
2020-05-20 14:34:49 +02:00
|
|
|
bool operator<(const MethodDoc &p_method) const {
|
2020-11-09 17:46:03 +01:00
|
|
|
if (name == p_method.name) {
|
2021-11-28 09:48:57 +01:00
|
|
|
// Must be an operator or a constructor since there is no other overloading
|
|
|
|
if (name.left(8) == "operator") {
|
|
|
|
if (arguments.size() == p_method.arguments.size()) {
|
|
|
|
if (arguments.size() == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return arguments[0].type < p_method.arguments[0].type;
|
|
|
|
}
|
2020-11-09 17:46:03 +01:00
|
|
|
return arguments.size() < p_method.arguments.size();
|
2021-11-28 09:48:57 +01:00
|
|
|
} else {
|
|
|
|
// Must be a constructor
|
|
|
|
// We want this arbitrary order for a class "Foo":
|
|
|
|
// - 1. Default constructor: Foo()
|
|
|
|
// - 2. Copy constructor: Foo(Foo)
|
|
|
|
// - 3+. Other constructors Foo(Bar, ...) based on first argument's name
|
|
|
|
if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1.
|
|
|
|
return arguments.size() < p_method.arguments.size();
|
|
|
|
}
|
|
|
|
if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2.
|
|
|
|
return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type);
|
|
|
|
}
|
|
|
|
return arguments[0] < p_method.arguments[0];
|
2020-11-09 17:46:03 +01:00
|
|
|
}
|
|
|
|
}
|
2023-05-04 15:18:56 +02:00
|
|
|
return name.naturalcasecmp_to(p_method.name) < 0;
|
2016-05-29 16:37:26 +02:00
|
|
|
}
|
2022-10-10 21:58:25 +02:00
|
|
|
static MethodDoc from_dict(const Dictionary &p_dict) {
|
|
|
|
MethodDoc doc;
|
|
|
|
|
|
|
|
if (p_dict.has("name")) {
|
|
|
|
doc.name = p_dict["name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("return_type")) {
|
|
|
|
doc.return_type = p_dict["return_type"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("return_enum")) {
|
|
|
|
doc.return_enum = p_dict["return_enum"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("qualifiers")) {
|
|
|
|
doc.qualifiers = p_dict["qualifiers"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("description")) {
|
|
|
|
doc.description = p_dict["description"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_deprecated")) {
|
|
|
|
doc.is_deprecated = p_dict["is_deprecated"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_experimental")) {
|
|
|
|
doc.is_experimental = p_dict["is_experimental"];
|
|
|
|
}
|
|
|
|
|
|
|
|
Array arguments;
|
|
|
|
if (p_dict.has("arguments")) {
|
|
|
|
arguments = p_dict["arguments"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < arguments.size(); i++) {
|
|
|
|
doc.arguments.push_back(ArgumentDoc::from_dict(arguments[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array errors_returned;
|
|
|
|
if (p_dict.has("errors_returned")) {
|
|
|
|
errors_returned = p_dict["errors_returned"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < errors_returned.size(); i++) {
|
|
|
|
doc.errors_returned.push_back(errors_returned[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2023-02-07 21:14:00 +01:00
|
|
|
static Dictionary to_dict(const MethodDoc &p_doc) {
|
|
|
|
Dictionary dict;
|
|
|
|
|
|
|
|
if (!p_doc.name.is_empty()) {
|
|
|
|
dict["name"] = p_doc.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.return_type.is_empty()) {
|
|
|
|
dict["return_type"] = p_doc.return_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.return_enum.is_empty()) {
|
|
|
|
dict["return_enum"] = p_doc.return_enum;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.qualifiers.is_empty()) {
|
|
|
|
dict["qualifiers"] = p_doc.qualifiers;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.description.is_empty()) {
|
|
|
|
dict["description"] = p_doc.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
dict["is_deprecated"] = p_doc.is_deprecated;
|
|
|
|
|
|
|
|
dict["is_experimental"] = p_doc.is_experimental;
|
|
|
|
|
|
|
|
if (!p_doc.arguments.is_empty()) {
|
|
|
|
Array arguments;
|
|
|
|
for (int i = 0; i < p_doc.arguments.size(); i++) {
|
|
|
|
arguments.push_back(ArgumentDoc::to_dict(p_doc.arguments[i]));
|
|
|
|
}
|
|
|
|
dict["arguments"] = arguments;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.errors_returned.is_empty()) {
|
|
|
|
Array errors_returned;
|
|
|
|
for (int i = 0; i < p_doc.errors_returned.size(); i++) {
|
|
|
|
errors_returned.push_back(p_doc.errors_returned[i]);
|
|
|
|
}
|
|
|
|
dict["errors_returned"] = errors_returned;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ConstantDoc {
|
|
|
|
String name;
|
|
|
|
String value;
|
2020-11-24 10:12:55 +01:00
|
|
|
bool is_value_valid = false;
|
2017-08-24 00:10:32 +02:00
|
|
|
String enumeration;
|
2022-06-24 11:16:37 +02:00
|
|
|
bool is_bitfield = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
String description;
|
2022-08-28 08:17:25 +02:00
|
|
|
bool is_deprecated = false;
|
|
|
|
bool is_experimental = false;
|
2020-05-20 14:34:49 +02:00
|
|
|
bool operator<(const ConstantDoc &p_const) const {
|
|
|
|
return name < p_const.name;
|
|
|
|
}
|
2022-10-10 21:58:25 +02:00
|
|
|
static ConstantDoc from_dict(const Dictionary &p_dict) {
|
|
|
|
ConstantDoc doc;
|
|
|
|
|
|
|
|
if (p_dict.has("name")) {
|
|
|
|
doc.name = p_dict["name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("value")) {
|
|
|
|
doc.value = p_dict["value"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_value_valid")) {
|
|
|
|
doc.is_value_valid = p_dict["is_value_valid"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("enumeration")) {
|
|
|
|
doc.enumeration = p_dict["enumeration"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_bitfield")) {
|
|
|
|
doc.is_bitfield = p_dict["is_bitfield"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("description")) {
|
|
|
|
doc.description = p_dict["description"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_deprecated")) {
|
|
|
|
doc.is_deprecated = p_dict["is_deprecated"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_experimental")) {
|
|
|
|
doc.is_experimental = p_dict["is_experimental"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2023-02-07 21:14:00 +01:00
|
|
|
static Dictionary to_dict(const ConstantDoc &p_doc) {
|
|
|
|
Dictionary dict;
|
|
|
|
|
|
|
|
if (!p_doc.name.is_empty()) {
|
|
|
|
dict["name"] = p_doc.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.value.is_empty()) {
|
|
|
|
dict["value"] = p_doc.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
dict["is_value_valid"] = p_doc.is_value_valid;
|
|
|
|
|
|
|
|
if (!p_doc.enumeration.is_empty()) {
|
|
|
|
dict["enumeration"] = p_doc.enumeration;
|
|
|
|
}
|
|
|
|
|
|
|
|
dict["is_bitfield"] = p_doc.is_bitfield;
|
|
|
|
|
|
|
|
if (!p_doc.description.is_empty()) {
|
|
|
|
dict["description"] = p_doc.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
dict["is_deprecated"] = p_doc.is_deprecated;
|
|
|
|
|
|
|
|
dict["is_experimental"] = p_doc.is_experimental;
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PropertyDoc {
|
|
|
|
String name;
|
|
|
|
String type;
|
2017-08-24 00:10:32 +02:00
|
|
|
String enumeration;
|
2014-02-10 02:10:30 +01:00
|
|
|
String description;
|
2017-03-05 16:44:50 +01:00
|
|
|
String setter, getter;
|
2019-06-01 15:42:22 +02:00
|
|
|
String default_value;
|
2020-05-20 14:34:49 +02:00
|
|
|
bool overridden = false;
|
2021-12-02 20:38:49 +01:00
|
|
|
String overrides;
|
2022-08-28 08:17:25 +02:00
|
|
|
bool is_deprecated = false;
|
|
|
|
bool is_experimental = false;
|
2017-03-05 16:44:50 +01:00
|
|
|
bool operator<(const PropertyDoc &p_prop) const {
|
2023-05-04 15:18:56 +02:00
|
|
|
return name.naturalcasecmp_to(p_prop.name) < 0;
|
2016-06-21 22:20:34 +02:00
|
|
|
}
|
2022-10-10 21:58:25 +02:00
|
|
|
static PropertyDoc from_dict(const Dictionary &p_dict) {
|
|
|
|
PropertyDoc doc;
|
|
|
|
|
|
|
|
if (p_dict.has("name")) {
|
|
|
|
doc.name = p_dict["name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("type")) {
|
|
|
|
doc.type = p_dict["type"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("enumeration")) {
|
|
|
|
doc.enumeration = p_dict["enumeration"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("description")) {
|
|
|
|
doc.description = p_dict["description"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("setter")) {
|
|
|
|
doc.setter = p_dict["setter"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("getter")) {
|
|
|
|
doc.getter = p_dict["getter"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("default_value")) {
|
|
|
|
doc.default_value = p_dict["default_value"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("overridden")) {
|
|
|
|
doc.overridden = p_dict["overridden"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("overrides")) {
|
|
|
|
doc.overrides = p_dict["overrides"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_deprecated")) {
|
|
|
|
doc.is_deprecated = p_dict["is_deprecated"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_experimental")) {
|
|
|
|
doc.is_experimental = p_dict["is_experimental"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2023-02-07 21:14:00 +01:00
|
|
|
static Dictionary to_dict(const PropertyDoc &p_doc) {
|
|
|
|
Dictionary dict;
|
|
|
|
|
|
|
|
if (!p_doc.name.is_empty()) {
|
|
|
|
dict["name"] = p_doc.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.type.is_empty()) {
|
|
|
|
dict["type"] = p_doc.type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.enumeration.is_empty()) {
|
|
|
|
dict["enumeration"] = p_doc.enumeration;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.description.is_empty()) {
|
|
|
|
dict["description"] = p_doc.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.setter.is_empty()) {
|
|
|
|
dict["setter"] = p_doc.setter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.getter.is_empty()) {
|
|
|
|
dict["getter"] = p_doc.getter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.default_value.is_empty()) {
|
|
|
|
dict["default_value"] = p_doc.default_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
dict["overridden"] = p_doc.overridden;
|
|
|
|
|
|
|
|
if (!p_doc.overrides.is_empty()) {
|
|
|
|
dict["overrides"] = p_doc.overrides;
|
|
|
|
}
|
|
|
|
|
|
|
|
dict["is_deprecated"] = p_doc.is_deprecated;
|
|
|
|
|
|
|
|
dict["is_experimental"] = p_doc.is_experimental;
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-04 18:54:41 +02:00
|
|
|
struct ThemeItemDoc {
|
|
|
|
String name;
|
|
|
|
String type;
|
|
|
|
String data_type;
|
|
|
|
String description;
|
|
|
|
String default_value;
|
|
|
|
bool operator<(const ThemeItemDoc &p_theme_item) const {
|
2021-12-01 19:02:20 +01:00
|
|
|
// First sort by the data type, then by name.
|
|
|
|
if (data_type == p_theme_item.data_type) {
|
2023-05-04 15:18:56 +02:00
|
|
|
return name.naturalcasecmp_to(p_theme_item.name) < 0;
|
2021-12-01 19:02:20 +01:00
|
|
|
}
|
|
|
|
return data_type < p_theme_item.data_type;
|
2021-08-04 18:54:41 +02:00
|
|
|
}
|
2022-10-10 21:58:25 +02:00
|
|
|
static ThemeItemDoc from_dict(const Dictionary &p_dict) {
|
|
|
|
ThemeItemDoc doc;
|
|
|
|
|
|
|
|
if (p_dict.has("name")) {
|
|
|
|
doc.name = p_dict["name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("type")) {
|
|
|
|
doc.type = p_dict["type"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("data_type")) {
|
|
|
|
doc.data_type = p_dict["data_type"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("description")) {
|
|
|
|
doc.description = p_dict["description"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("default_value")) {
|
|
|
|
doc.default_value = p_dict["default_value"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2023-02-07 21:14:00 +01:00
|
|
|
static Dictionary to_dict(const ThemeItemDoc &p_doc) {
|
|
|
|
Dictionary dict;
|
|
|
|
|
|
|
|
if (!p_doc.name.is_empty()) {
|
|
|
|
dict["name"] = p_doc.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.type.is_empty()) {
|
|
|
|
dict["type"] = p_doc.type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.data_type.is_empty()) {
|
|
|
|
dict["data_type"] = p_doc.data_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.description.is_empty()) {
|
|
|
|
dict["description"] = p_doc.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.default_value.is_empty()) {
|
|
|
|
dict["default_value"] = p_doc.default_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
2021-08-04 18:54:41 +02:00
|
|
|
};
|
|
|
|
|
2020-06-07 03:26:35 +02:00
|
|
|
struct TutorialDoc {
|
|
|
|
String link;
|
|
|
|
String title;
|
2022-10-10 21:58:25 +02:00
|
|
|
static TutorialDoc from_dict(const Dictionary &p_dict) {
|
|
|
|
TutorialDoc doc;
|
|
|
|
|
|
|
|
if (p_dict.has("link")) {
|
|
|
|
doc.link = p_dict["link"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("title")) {
|
|
|
|
doc.title = p_dict["title"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2023-02-07 21:14:00 +01:00
|
|
|
static Dictionary to_dict(const TutorialDoc &p_doc) {
|
|
|
|
Dictionary dict;
|
|
|
|
|
|
|
|
if (!p_doc.link.is_empty()) {
|
|
|
|
dict["link"] = p_doc.link;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.title.is_empty()) {
|
|
|
|
dict["title"] = p_doc.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
2020-06-07 03:26:35 +02:00
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
struct ClassDoc {
|
2014-02-10 02:10:30 +01:00
|
|
|
String name;
|
|
|
|
String inherits;
|
|
|
|
String brief_description;
|
|
|
|
String description;
|
2020-06-07 03:26:35 +02:00
|
|
|
Vector<TutorialDoc> tutorials;
|
2021-09-21 04:49:02 +02:00
|
|
|
Vector<MethodDoc> constructors;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<MethodDoc> methods;
|
2021-09-21 04:49:02 +02:00
|
|
|
Vector<MethodDoc> operators;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<MethodDoc> signals;
|
|
|
|
Vector<ConstantDoc> constants;
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<String, String> enums;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<PropertyDoc> properties;
|
2022-07-04 17:56:34 +02:00
|
|
|
Vector<MethodDoc> annotations;
|
2021-08-04 18:54:41 +02:00
|
|
|
Vector<ThemeItemDoc> theme_properties;
|
2022-08-28 08:17:25 +02:00
|
|
|
bool is_deprecated = false;
|
|
|
|
bool is_experimental = false;
|
2020-11-29 03:37:57 +01:00
|
|
|
bool is_script_doc = false;
|
|
|
|
String script_path;
|
2020-05-20 14:34:49 +02:00
|
|
|
bool operator<(const ClassDoc &p_class) const {
|
|
|
|
return name < p_class.name;
|
|
|
|
}
|
2022-10-10 21:58:25 +02:00
|
|
|
static ClassDoc from_dict(const Dictionary &p_dict) {
|
|
|
|
ClassDoc doc;
|
|
|
|
|
|
|
|
if (p_dict.has("name")) {
|
|
|
|
doc.name = p_dict["name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("inherits")) {
|
|
|
|
doc.inherits = p_dict["inherits"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("brief_description")) {
|
|
|
|
doc.brief_description = p_dict["brief_description"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("description")) {
|
|
|
|
doc.description = p_dict["description"];
|
|
|
|
}
|
|
|
|
|
|
|
|
Array tutorials;
|
|
|
|
if (p_dict.has("tutorials")) {
|
|
|
|
tutorials = p_dict["tutorials"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < tutorials.size(); i++) {
|
|
|
|
doc.tutorials.push_back(TutorialDoc::from_dict(tutorials[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array constructors;
|
|
|
|
if (p_dict.has("constructors")) {
|
|
|
|
constructors = p_dict["constructors"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < constructors.size(); i++) {
|
|
|
|
doc.constructors.push_back(MethodDoc::from_dict(constructors[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array methods;
|
|
|
|
if (p_dict.has("methods")) {
|
|
|
|
methods = p_dict["methods"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < methods.size(); i++) {
|
|
|
|
doc.methods.push_back(MethodDoc::from_dict(methods[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array operators;
|
|
|
|
if (p_dict.has("operators")) {
|
|
|
|
operators = p_dict["operators"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < operators.size(); i++) {
|
|
|
|
doc.operators.push_back(MethodDoc::from_dict(operators[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array signals;
|
|
|
|
if (p_dict.has("signals")) {
|
|
|
|
signals = p_dict["signals"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < signals.size(); i++) {
|
|
|
|
doc.signals.push_back(MethodDoc::from_dict(signals[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array constants;
|
|
|
|
if (p_dict.has("constants")) {
|
|
|
|
constants = p_dict["constants"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < constants.size(); i++) {
|
|
|
|
doc.constants.push_back(ConstantDoc::from_dict(constants[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary enums;
|
|
|
|
if (p_dict.has("enums")) {
|
|
|
|
enums = p_dict["enums"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < enums.size(); i++) {
|
|
|
|
doc.enums[enums.get_key_at_index(i)] = enums.get_value_at_index(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
Array properties;
|
|
|
|
if (p_dict.has("properties")) {
|
|
|
|
properties = p_dict["properties"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < properties.size(); i++) {
|
|
|
|
doc.properties.push_back(PropertyDoc::from_dict(properties[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array annotations;
|
|
|
|
if (p_dict.has("annotations")) {
|
|
|
|
annotations = p_dict["annotations"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < annotations.size(); i++) {
|
|
|
|
doc.annotations.push_back(MethodDoc::from_dict(annotations[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
Array theme_properties;
|
|
|
|
if (p_dict.has("theme_properties")) {
|
|
|
|
theme_properties = p_dict["theme_properties"];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < theme_properties.size(); i++) {
|
|
|
|
doc.theme_properties.push_back(ThemeItemDoc::from_dict(theme_properties[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_deprecated")) {
|
|
|
|
doc.is_deprecated = p_dict["is_deprecated"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_experimental")) {
|
|
|
|
doc.is_experimental = p_dict["is_experimental"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("is_script_doc")) {
|
|
|
|
doc.is_script_doc = p_dict["is_script_doc"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_dict.has("script_path")) {
|
|
|
|
doc.script_path = p_dict["script_path"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2023-02-07 21:14:00 +01:00
|
|
|
static Dictionary to_dict(const ClassDoc &p_doc) {
|
|
|
|
Dictionary dict;
|
|
|
|
|
|
|
|
if (!p_doc.name.is_empty()) {
|
|
|
|
dict["name"] = p_doc.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.inherits.is_empty()) {
|
|
|
|
dict["inherits"] = p_doc.inherits;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.brief_description.is_empty()) {
|
|
|
|
dict["brief_description"] = p_doc.brief_description;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.description.is_empty()) {
|
|
|
|
dict["description"] = p_doc.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.tutorials.is_empty()) {
|
|
|
|
Array tutorials;
|
|
|
|
for (int i = 0; i < p_doc.tutorials.size(); i++) {
|
|
|
|
tutorials.push_back(TutorialDoc::to_dict(p_doc.tutorials[i]));
|
|
|
|
}
|
|
|
|
dict["tutorials"] = tutorials;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.constructors.is_empty()) {
|
|
|
|
Array constructors;
|
|
|
|
for (int i = 0; i < p_doc.constructors.size(); i++) {
|
|
|
|
constructors.push_back(MethodDoc::to_dict(p_doc.constructors[i]));
|
|
|
|
}
|
|
|
|
dict["constructors"] = constructors;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.methods.is_empty()) {
|
|
|
|
Array methods;
|
|
|
|
for (int i = 0; i < p_doc.methods.size(); i++) {
|
|
|
|
methods.push_back(MethodDoc::to_dict(p_doc.methods[i]));
|
|
|
|
}
|
|
|
|
dict["methods"] = methods;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.operators.is_empty()) {
|
|
|
|
Array operators;
|
|
|
|
for (int i = 0; i < p_doc.operators.size(); i++) {
|
|
|
|
operators.push_back(MethodDoc::to_dict(p_doc.operators[i]));
|
|
|
|
}
|
|
|
|
dict["operators"] = operators;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.signals.is_empty()) {
|
|
|
|
Array signals;
|
|
|
|
for (int i = 0; i < p_doc.signals.size(); i++) {
|
|
|
|
signals.push_back(MethodDoc::to_dict(p_doc.signals[i]));
|
|
|
|
}
|
|
|
|
dict["signals"] = signals;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.constants.is_empty()) {
|
|
|
|
Array constants;
|
|
|
|
for (int i = 0; i < p_doc.constants.size(); i++) {
|
|
|
|
constants.push_back(ConstantDoc::to_dict(p_doc.constants[i]));
|
|
|
|
}
|
|
|
|
dict["constants"] = constants;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.enums.is_empty()) {
|
|
|
|
Dictionary enums;
|
|
|
|
for (const KeyValue<String, String> &E : p_doc.enums) {
|
|
|
|
enums[E.key] = E.value;
|
|
|
|
}
|
|
|
|
dict["enums"] = enums;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.properties.is_empty()) {
|
|
|
|
Array properties;
|
|
|
|
for (int i = 0; i < p_doc.properties.size(); i++) {
|
|
|
|
properties.push_back(PropertyDoc::to_dict(p_doc.properties[i]));
|
|
|
|
}
|
|
|
|
dict["properties"] = properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.annotations.is_empty()) {
|
|
|
|
Array annotations;
|
|
|
|
for (int i = 0; i < p_doc.annotations.size(); i++) {
|
|
|
|
annotations.push_back(MethodDoc::to_dict(p_doc.annotations[i]));
|
|
|
|
}
|
|
|
|
dict["annotations"] = annotations;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_doc.theme_properties.is_empty()) {
|
|
|
|
Array theme_properties;
|
|
|
|
for (int i = 0; i < p_doc.theme_properties.size(); i++) {
|
|
|
|
theme_properties.push_back(ThemeItemDoc::to_dict(p_doc.theme_properties[i]));
|
|
|
|
}
|
|
|
|
dict["theme_properties"] = theme_properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
dict["is_deprecated"] = p_doc.is_deprecated;
|
|
|
|
|
|
|
|
dict["is_experimental"] = p_doc.is_experimental;
|
|
|
|
|
|
|
|
dict["is_script_doc"] = p_doc.is_script_doc;
|
|
|
|
|
|
|
|
if (!p_doc.script_path.is_empty()) {
|
|
|
|
dict["script_path"] = p_doc.script_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2022-11-27 08:56:53 +01:00
|
|
|
static String get_default_value_string(const Variant &p_value);
|
|
|
|
|
2020-11-29 03:37:57 +01:00
|
|
|
static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo);
|
|
|
|
static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo);
|
|
|
|
static void property_doc_from_scriptmemberinfo(DocData::PropertyDoc &p_property, const ScriptMemberInfo &p_memberinfo);
|
|
|
|
static void method_doc_from_methodinfo(DocData::MethodDoc &p_method, const MethodInfo &p_methodinfo, const String &p_desc);
|
|
|
|
static void constant_doc_from_variant(DocData::ConstantDoc &p_const, const StringName &p_name, const Variant &p_value, const String &p_desc);
|
|
|
|
static void signal_doc_from_methodinfo(DocData::MethodDoc &p_signal, const MethodInfo &p_methodinfo, const String &p_desc);
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOC_DATA_H
|