| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/io/xml_parser.h" |
| 34 |
#include "core/variant/variant.h" |
| 35 |
|
| 36 |
class DocData { |
| 37 |
public: |
| 38 |
struct ArgumentDoc { |
| 39 |
String name; |
| 40 |
String type; |
| 41 |
String enumeration; |
| 42 |
bool is_bitfield = false; |
| 43 |
String default_value; |
| 44 |
bool operator<(const ArgumentDoc &p_arg) const { |
| 45 |
if (name == p_arg.name) { |
| 46 |
return type < p_arg.type; |
| 47 |
} |
| 48 |
return name < p_arg.name; |
| 49 |
} |
| 50 |
static ArgumentDoc from_dict(const Dictionary &p_dict) { |
| 51 |
ArgumentDoc doc; |
| 52 |
|
| 53 |
if (p_dict.has("name")) { |
| 54 |
doc.name = p_dict["name"]; |
| 55 |
} |
| 56 |
|
| 57 |
if (p_dict.has("type")) { |
| 58 |
doc.type = p_dict["type"]; |
| 59 |
} |
| 60 |
|
| 61 |
if (p_dict.has("enumeration")) { |
| 62 |
doc.enumeration = p_dict["enumeration"]; |
| 63 |
if (p_dict.has("is_bitfield")) { |
| 64 |
doc.is_bitfield = p_dict["is_bitfield"]; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
if (p_dict.has("default_value")) { |
| 69 |
doc.default_value = p_dict["default_value"]; |
| 70 |
} |
| 71 |
|
| 72 |
return doc; |
| 73 |
} |
| 74 |
static Dictionary to_dict(const ArgumentDoc &p_doc) { |
| 75 |
Dictionary dict; |
| 76 |
|
| 77 |
if (!p_doc.name.is_empty()) { |
| 78 |
dict["name"] = p_doc.name; |
| 79 |
} |
| 80 |
|
| 81 |
if (!p_doc.type.is_empty()) { |
| 82 |
dict["type"] = p_doc.type; |
| 83 |
} |
| 84 |
|
| 85 |
if (!p_doc.enumeration.is_empty()) { |
| 86 |
dict["enumeration"] = p_doc.enumeration; |
| 87 |
dict["is_bitfield"] = p_doc.is_bitfield; |
| 88 |
} |
| 89 |
|
| 90 |
if (!p_doc.default_value.is_empty()) { |
| 91 |
dict["default_value"] = p_doc.default_value; |
| 92 |
} |
| 93 |
|
| 94 |
return dict; |
| 95 |
} |
| 96 |
}; |
| 97 |
|
| 98 |
struct MethodDoc { |
| 99 |
String name; |
| 100 |
String return_type; |
| 101 |
String return_enum; |
| 102 |
bool return_is_bitfield = false; |
| 103 |
String qualifiers; |
| 104 |
String description; |
| 105 |
bool is_deprecated = false; |
| 106 |
String deprecated_message; |
| 107 |
bool is_experimental = false; |
| 108 |
String experimental_message; |
| 109 |
Vector<ArgumentDoc> arguments; |
| 110 |
|
| 111 |
ArgumentDoc rest_argument; |
| 112 |
Vector<int> errors_returned; |
| 113 |
String keywords; |
| 114 |
bool operator<(const MethodDoc &p_method) const { |
| 115 |
if (name == p_method.name) { |
| 116 |
|
| 117 |
if (name.left(8) == "operator") { |
| 118 |
if (arguments.size() == p_method.arguments.size()) { |
| 119 |
if (arguments.is_empty()) { |
| 120 |
return false; |
| 121 |
} |
| 122 |
return arguments[0].type < p_method.arguments[0].type; |
| 123 |
} |
| 124 |
return arguments.size() < p_method.arguments.size(); |
| 125 |
} else { |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
if (arguments.is_empty() || p_method.arguments.is_empty()) { |
| 132 |
return arguments.size() < p_method.arguments.size(); |
| 133 |
} |
| 134 |
if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { |
| 135 |
return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type); |
| 136 |
} |
| 137 |
return arguments[0] < p_method.arguments[0]; |
| 138 |
} |
| 139 |
} |
| 140 |
return name.naturalcasecmp_to(p_method.name) < 0; |
| 141 |
} |
| 142 |
static MethodDoc from_dict(const Dictionary &p_dict) { |
| 143 |
MethodDoc doc; |
| 144 |
|
| 145 |
if (p_dict.has("name")) { |
| 146 |
doc.name = p_dict["name"]; |
| 147 |
} |
| 148 |
|
| 149 |
if (p_dict.has("return_type")) { |
| 150 |
doc.return_type = p_dict["return_type"]; |
| 151 |
} |
| 152 |
|
| 153 |
if (p_dict.has("return_enum")) { |
| 154 |
doc.return_enum = p_dict["return_enum"]; |
| 155 |
if (p_dict.has("return_is_bitfield")) { |
| 156 |
doc.return_is_bitfield = p_dict["return_is_bitfield"]; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
if (p_dict.has("qualifiers")) { |
| 161 |
doc.qualifiers = p_dict["qualifiers"]; |
| 162 |
} |
| 163 |
|
| 164 |
if (p_dict.has("description")) { |
| 165 |
doc.description = p_dict["description"]; |
| 166 |
} |
| 167 |
|
| 168 |
#ifndef DISABLE_DEPRECATED |
| 169 |
if (p_dict.has("is_deprecated")) { |
| 170 |
doc.is_deprecated = p_dict["is_deprecated"]; |
| 171 |
} |
| 172 |
|
| 173 |
if (p_dict.has("is_experimental")) { |
| 174 |
doc.is_experimental = p_dict["is_experimental"]; |
| 175 |
} |
| 176 |
#endif |
| 177 |
|
| 178 |
if (p_dict.has("deprecated")) { |
| 179 |
doc.is_deprecated = true; |
| 180 |
doc.deprecated_message = p_dict["deprecated"]; |
| 181 |
} |
| 182 |
|
| 183 |
if (p_dict.has("experimental")) { |
| 184 |
doc.is_experimental = true; |
| 185 |
doc.experimental_message = p_dict["experimental"]; |
| 186 |
} |
| 187 |
|
| 188 |
Array arguments; |
| 189 |
if (p_dict.has("arguments")) { |
| 190 |
arguments = p_dict["arguments"]; |
| 191 |
} |
| 192 |
for (int i = 0; i < arguments.size(); i++) { |
| 193 |
doc.arguments.push_back(ArgumentDoc::from_dict(arguments[i])); |
| 194 |
} |
| 195 |
|
| 196 |
Array errors_returned; |
| 197 |
if (p_dict.has("errors_returned")) { |
| 198 |
errors_returned = p_dict["errors_returned"]; |
| 199 |
} |
| 200 |
for (int i = 0; i < errors_returned.size(); i++) { |
| 201 |
doc.errors_returned.push_back(errors_returned[i]); |
| 202 |
} |
| 203 |
|
| 204 |
if (p_dict.has("keywords")) { |
| 205 |
doc.keywords = p_dict["keywords"]; |
| 206 |
} |
| 207 |
|
| 208 |
return doc; |
| 209 |
} |
| 210 |
static Dictionary to_dict(const MethodDoc &p_doc) { |
| 211 |
Dictionary dict; |
| 212 |
|
| 213 |
if (!p_doc.name.is_empty()) { |
| 214 |
dict["name"] = p_doc.name; |
| 215 |
} |
| 216 |
|
| 217 |
if (!p_doc.return_type.is_empty()) { |
| 218 |
dict["return_type"] = p_doc.return_type; |
| 219 |
} |
| 220 |
|
| 221 |
if (!p_doc.return_enum.is_empty()) { |
| 222 |
dict["return_enum"] = p_doc.return_enum; |
| 223 |
dict["return_is_bitfield"] = p_doc.return_is_bitfield; |
| 224 |
} |
| 225 |
|
| 226 |
if (!p_doc.qualifiers.is_empty()) { |
| 227 |
dict["qualifiers"] = p_doc.qualifiers; |
| 228 |
} |
| 229 |
|
| 230 |
if (!p_doc.description.is_empty()) { |
| 231 |
dict["description"] = p_doc.description; |
| 232 |
} |
| 233 |
|
| 234 |
if (p_doc.is_deprecated) { |
| 235 |
dict["deprecated"] = p_doc.deprecated_message; |
| 236 |
} |
| 237 |
|
| 238 |
if (p_doc.is_experimental) { |
| 239 |
dict["experimental"] = p_doc.experimental_message; |
| 240 |
} |
| 241 |
|
| 242 |
if (!p_doc.keywords.is_empty()) { |
| 243 |
dict["keywords"] = p_doc.keywords; |
| 244 |
} |
| 245 |
|
| 246 |
if (!p_doc.arguments.is_empty()) { |
| 247 |
Array arguments; |
| 248 |
for (int i = 0; i < p_doc.arguments.size(); i++) { |
| 249 |
arguments.push_back(ArgumentDoc::to_dict(p_doc.arguments[i])); |
| 250 |
} |
| 251 |
dict["arguments"] = arguments; |
| 252 |
} |
| 253 |
|
| 254 |
if (!p_doc.errors_returned.is_empty()) { |
| 255 |
Array errors_returned; |
| 256 |
for (int i = 0; i < p_doc.errors_returned.size(); i++) { |
| 257 |
errors_returned.push_back(p_doc.errors_returned[i]); |
| 258 |
} |
| 259 |
dict["errors_returned"] = errors_returned; |
| 260 |
} |
| 261 |
|
| 262 |
return dict; |
| 263 |
} |
| 264 |
}; |
| 265 |
|
| 266 |
struct ConstantDoc { |
| 267 |
String name; |
| 268 |
String value; |
| 269 |
bool is_value_valid = false; |
| 270 |
String type; |
| 271 |
String enumeration; |
| 272 |
bool is_bitfield = false; |
| 273 |
String description; |
| 274 |
bool is_deprecated = false; |
| 275 |
String deprecated_message; |
| 276 |
bool is_experimental = false; |
| 277 |
String experimental_message; |
| 278 |
String keywords; |
| 279 |
bool operator<(const ConstantDoc &p_const) const { |
| 280 |
return name < p_const.name; |
| 281 |
} |
| 282 |
static ConstantDoc from_dict(const Dictionary &p_dict) { |
| 283 |
ConstantDoc doc; |
| 284 |
|
| 285 |
if (p_dict.has("name")) { |
| 286 |
doc.name = p_dict["name"]; |
| 287 |
} |
| 288 |
|
| 289 |
if (p_dict.has("value")) { |
| 290 |
doc.value = p_dict["value"]; |
| 291 |
} |
| 292 |
|
| 293 |
if (p_dict.has("is_value_valid")) { |
| 294 |
doc.is_value_valid = p_dict["is_value_valid"]; |
| 295 |
} |
| 296 |
|
| 297 |
if (p_dict.has("type")) { |
| 298 |
doc.type = p_dict["type"]; |
| 299 |
} |
| 300 |
|
| 301 |
if (p_dict.has("enumeration")) { |
| 302 |
doc.enumeration = p_dict["enumeration"]; |
| 303 |
if (p_dict.has("is_bitfield")) { |
| 304 |
doc.is_bitfield = p_dict["is_bitfield"]; |
| 305 |
} |
| 306 |
} |
| 307 |
|
| 308 |
if (p_dict.has("description")) { |
| 309 |
doc.description = p_dict["description"]; |
| 310 |
} |
| 311 |
|
| 312 |
#ifndef DISABLE_DEPRECATED |
| 313 |
if (p_dict.has("is_deprecated")) { |
| 314 |
doc.is_deprecated = p_dict["is_deprecated"]; |
| 315 |
} |
| 316 |
|
| 317 |
if (p_dict.has("is_experimental")) { |
| 318 |
doc.is_experimental = p_dict["is_experimental"]; |
| 319 |
} |
| 320 |
#endif |
| 321 |
|
| 322 |
if (p_dict.has("deprecated")) { |
| 323 |
doc.is_deprecated = true; |
| 324 |
doc.deprecated_message = p_dict["deprecated"]; |
| 325 |
} |
| 326 |
|
| 327 |
if (p_dict.has("experimental")) { |
| 328 |
doc.is_experimental = true; |
| 329 |
doc.experimental_message = p_dict["experimental"]; |
| 330 |
} |
| 331 |
|
| 332 |
if (p_dict.has("keywords")) { |
| 333 |
doc.keywords = p_dict["keywords"]; |
| 334 |
} |
| 335 |
|
| 336 |
return doc; |
| 337 |
} |
| 338 |
static Dictionary to_dict(const ConstantDoc &p_doc) { |
| 339 |
Dictionary dict; |
| 340 |
|
| 341 |
if (!p_doc.name.is_empty()) { |
| 342 |
dict["name"] = p_doc.name; |
| 343 |
} |
| 344 |
|
| 345 |
if (!p_doc.value.is_empty()) { |
| 346 |
dict["value"] = p_doc.value; |
| 347 |
} |
| 348 |
|
| 349 |
dict["is_value_valid"] = p_doc.is_value_valid; |
| 350 |
|
| 351 |
dict["type"] = p_doc.type; |
| 352 |
|
| 353 |
if (!p_doc.enumeration.is_empty()) { |
| 354 |
dict["enumeration"] = p_doc.enumeration; |
| 355 |
dict["is_bitfield"] = p_doc.is_bitfield; |
| 356 |
} |
| 357 |
|
| 358 |
if (!p_doc.description.is_empty()) { |
| 359 |
dict["description"] = p_doc.description; |
| 360 |
} |
| 361 |
|
| 362 |
if (p_doc.is_deprecated) { |
| 363 |
dict["deprecated"] = p_doc.deprecated_message; |
| 364 |
} |
| 365 |
|
| 366 |
if (p_doc.is_experimental) { |
| 367 |
dict["experimental"] = p_doc.experimental_message; |
| 368 |
} |
| 369 |
|
| 370 |
if (!p_doc.keywords.is_empty()) { |
| 371 |
dict["keywords"] = p_doc.keywords; |
| 372 |
} |
| 373 |
|
| 374 |
return dict; |
| 375 |
} |
| 376 |
}; |
| 377 |
|
| 378 |
struct PropertyDoc { |
| 379 |
String name; |
| 380 |
String type; |
| 381 |
String enumeration; |
| 382 |
bool is_bitfield = false; |
| 383 |
String description; |
| 384 |
String setter, getter; |
| 385 |
String default_value; |
| 386 |
bool overridden = false; |
| 387 |
String overrides; |
| 388 |
bool is_deprecated = false; |
| 389 |
String deprecated_message; |
| 390 |
bool is_experimental = false; |
| 391 |
String experimental_message; |
| 392 |
String keywords; |
| 393 |
bool operator<(const PropertyDoc &p_prop) const { |
| 394 |
return name.naturalcasecmp_to(p_prop.name) < 0; |
| 395 |
} |
| 396 |
static PropertyDoc from_dict(const Dictionary &p_dict) { |
| 397 |
PropertyDoc doc; |
| 398 |
|
| 399 |
if (p_dict.has("name")) { |
| 400 |
doc.name = p_dict["name"]; |
| 401 |
} |
| 402 |
|
| 403 |
if (p_dict.has("type")) { |
| 404 |
doc.type = p_dict["type"]; |
| 405 |
} |
| 406 |
|
| 407 |
if (p_dict.has("enumeration")) { |
| 408 |
doc.enumeration = p_dict["enumeration"]; |
| 409 |
if (p_dict.has("is_bitfield")) { |
| 410 |
doc.is_bitfield = p_dict["is_bitfield"]; |
| 411 |
} |
| 412 |
} |
| 413 |
|
| 414 |
if (p_dict.has("description")) { |
| 415 |
doc.description = p_dict["description"]; |
| 416 |
} |
| 417 |
|
| 418 |
if (p_dict.has("setter")) { |
| 419 |
doc.setter = p_dict["setter"]; |
| 420 |
} |
| 421 |
|
| 422 |
if (p_dict.has("getter")) { |
| 423 |
doc.getter = p_dict["getter"]; |
| 424 |
} |
| 425 |
|
| 426 |
if (p_dict.has("default_value")) { |
| 427 |
doc.default_value = p_dict["default_value"]; |
| 428 |
} |
| 429 |
|
| 430 |
if (p_dict.has("overridden")) { |
| 431 |
doc.overridden = p_dict["overridden"]; |
| 432 |
} |
| 433 |
|
| 434 |
if (p_dict.has("overrides")) { |
| 435 |
doc.overrides = p_dict["overrides"]; |
| 436 |
} |
| 437 |
|
| 438 |
#ifndef DISABLE_DEPRECATED |
| 439 |
if (p_dict.has("is_deprecated")) { |
| 440 |
doc.is_deprecated = p_dict["is_deprecated"]; |
| 441 |
} |
| 442 |
|
| 443 |
if (p_dict.has("is_experimental")) { |
| 444 |
doc.is_experimental = p_dict["is_experimental"]; |
| 445 |
} |
| 446 |
#endif |
| 447 |
|
| 448 |
if (p_dict.has("deprecated")) { |
| 449 |
doc.is_deprecated = true; |
| 450 |
doc.deprecated_message = p_dict["deprecated"]; |
| 451 |
} |
| 452 |
|
| 453 |
if (p_dict.has("experimental")) { |
| 454 |
doc.is_experimental = true; |
| 455 |
doc.experimental_message = p_dict["experimental"]; |
| 456 |
} |
| 457 |
|
| 458 |
if (p_dict.has("keywords")) { |
| 459 |
doc.keywords = p_dict["keywords"]; |
| 460 |
} |
| 461 |
|
| 462 |
return doc; |
| 463 |
} |
| 464 |
static Dictionary to_dict(const PropertyDoc &p_doc) { |
| 465 |
Dictionary dict; |
| 466 |
|
| 467 |
if (!p_doc.name.is_empty()) { |
| 468 |
dict["name"] = p_doc.name; |
| 469 |
} |
| 470 |
|
| 471 |
if (!p_doc.type.is_empty()) { |
| 472 |
dict["type"] = p_doc.type; |
| 473 |
} |
| 474 |
|
| 475 |
if (!p_doc.enumeration.is_empty()) { |
| 476 |
dict["enumeration"] = p_doc.enumeration; |
| 477 |
dict["is_bitfield"] = p_doc.is_bitfield; |
| 478 |
} |
| 479 |
|
| 480 |
if (!p_doc.description.is_empty()) { |
| 481 |
dict["description"] = p_doc.description; |
| 482 |
} |
| 483 |
|
| 484 |
if (!p_doc.setter.is_empty()) { |
| 485 |
dict["setter"] = p_doc.setter; |
| 486 |
} |
| 487 |
|
| 488 |
if (!p_doc.getter.is_empty()) { |
| 489 |
dict["getter"] = p_doc.getter; |
| 490 |
} |
| 491 |
|
| 492 |
if (!p_doc.default_value.is_empty()) { |
| 493 |
dict["default_value"] = p_doc.default_value; |
| 494 |
} |
| 495 |
|
| 496 |
dict["overridden"] = p_doc.overridden; |
| 497 |
|
| 498 |
if (!p_doc.overrides.is_empty()) { |
| 499 |
dict["overrides"] = p_doc.overrides; |
| 500 |
} |
| 501 |
|
| 502 |
if (p_doc.is_deprecated) { |
| 503 |
dict["deprecated"] = p_doc.deprecated_message; |
| 504 |
} |
| 505 |
|
| 506 |
if (p_doc.is_experimental) { |
| 507 |
dict["experimental"] = p_doc.experimental_message; |
| 508 |
} |
| 509 |
|
| 510 |
if (!p_doc.keywords.is_empty()) { |
| 511 |
dict["keywords"] = p_doc.keywords; |
| 512 |
} |
| 513 |
|
| 514 |
return dict; |
| 515 |
} |
| 516 |
}; |
| 517 |
|
| 518 |
struct ThemeItemDoc { |
| 519 |
String name; |
| 520 |
String type; |
| 521 |
String data_type; |
| 522 |
String description; |
| 523 |
bool is_deprecated = false; |
| 524 |
String deprecated_message; |
| 525 |
bool is_experimental = false; |
| 526 |
String experimental_message; |
| 527 |
String default_value; |
| 528 |
String keywords; |
| 529 |
bool operator<(const ThemeItemDoc &p_theme_item) const { |
| 530 |
|
| 531 |
if (data_type == p_theme_item.data_type) { |
| 532 |
return name.naturalcasecmp_to(p_theme_item.name) < 0; |
| 533 |
} |
| 534 |
return data_type < p_theme_item.data_type; |
| 535 |
} |
| 536 |
static ThemeItemDoc from_dict(const Dictionary &p_dict) { |
| 537 |
ThemeItemDoc doc; |
| 538 |
|
| 539 |
if (p_dict.has("name")) { |
| 540 |
doc.name = p_dict["name"]; |
| 541 |
} |
| 542 |
|
| 543 |
if (p_dict.has("type")) { |
| 544 |
doc.type = p_dict["type"]; |
| 545 |
} |
| 546 |
|
| 547 |
if (p_dict.has("data_type")) { |
| 548 |
doc.data_type = p_dict["data_type"]; |
| 549 |
} |
| 550 |
|
| 551 |
if (p_dict.has("description")) { |
| 552 |
doc.description = p_dict["description"]; |
| 553 |
} |
| 554 |
|
| 555 |
if (p_dict.has("deprecated")) { |
| 556 |
doc.is_deprecated = true; |
| 557 |
doc.deprecated_message = p_dict["deprecated"]; |
| 558 |
} |
| 559 |
|
| 560 |
if (p_dict.has("experimental")) { |
| 561 |
doc.is_experimental = true; |
| 562 |
doc.experimental_message = p_dict["experimental"]; |
| 563 |
} |
| 564 |
|
| 565 |
if (p_dict.has("default_value")) { |
| 566 |
doc.default_value = p_dict["default_value"]; |
| 567 |
} |
| 568 |
|
| 569 |
if (p_dict.has("keywords")) { |
| 570 |
doc.keywords = p_dict["keywords"]; |
| 571 |
} |
| 572 |
|
| 573 |
return doc; |
| 574 |
} |
| 575 |
static Dictionary to_dict(const ThemeItemDoc &p_doc) { |
| 576 |
Dictionary dict; |
| 577 |
|
| 578 |
if (!p_doc.name.is_empty()) { |
| 579 |
dict["name"] = p_doc.name; |
| 580 |
} |
| 581 |
|
| 582 |
if (!p_doc.type.is_empty()) { |
| 583 |
dict["type"] = p_doc.type; |
| 584 |
} |
| 585 |
|
| 586 |
if (!p_doc.data_type.is_empty()) { |
| 587 |
dict["data_type"] = p_doc.data_type; |
| 588 |
} |
| 589 |
|
| 590 |
if (!p_doc.description.is_empty()) { |
| 591 |
dict["description"] = p_doc.description; |
| 592 |
} |
| 593 |
|
| 594 |
if (p_doc.is_deprecated) { |
| 595 |
dict["deprecated"] = p_doc.deprecated_message; |
| 596 |
} |
| 597 |
|
| 598 |
if (p_doc.is_experimental) { |
| 599 |
dict["experimental"] = p_doc.experimental_message; |
| 600 |
} |
| 601 |
|
| 602 |
if (!p_doc.default_value.is_empty()) { |
| 603 |
dict["default_value"] = p_doc.default_value; |
| 604 |
} |
| 605 |
|
| 606 |
if (!p_doc.keywords.is_empty()) { |
| 607 |
dict["keywords"] = p_doc.keywords; |
| 608 |
} |
| 609 |
|
| 610 |
return dict; |
| 611 |
} |
| 612 |
}; |
| 613 |
|
| 614 |
struct TutorialDoc { |
| 615 |
String link; |
| 616 |
String title; |
| 617 |
static TutorialDoc from_dict(const Dictionary &p_dict) { |
| 618 |
TutorialDoc doc; |
| 619 |
|
| 620 |
if (p_dict.has("link")) { |
| 621 |
doc.link = p_dict["link"]; |
| 622 |
} |
| 623 |
|
| 624 |
if (p_dict.has("title")) { |
| 625 |
doc.title = p_dict["title"]; |
| 626 |
} |
| 627 |
|
| 628 |
return doc; |
| 629 |
} |
| 630 |
static Dictionary to_dict(const TutorialDoc &p_doc) { |
| 631 |
Dictionary dict; |
| 632 |
|
| 633 |
if (!p_doc.link.is_empty()) { |
| 634 |
dict["link"] = p_doc.link; |
| 635 |
} |
| 636 |
|
| 637 |
if (!p_doc.title.is_empty()) { |
| 638 |
dict["title"] = p_doc.title; |
| 639 |
} |
| 640 |
|
| 641 |
return dict; |
| 642 |
} |
| 643 |
}; |
| 644 |
|
| 645 |
struct EnumDoc { |
| 646 |
String description; |
| 647 |
bool is_deprecated = false; |
| 648 |
String deprecated_message; |
| 649 |
bool is_experimental = false; |
| 650 |
String experimental_message; |
| 651 |
static EnumDoc from_dict(const Dictionary &p_dict) { |
| 652 |
EnumDoc doc; |
| 653 |
|
| 654 |
if (p_dict.has("description")) { |
| 655 |
doc.description = p_dict["description"]; |
| 656 |
} |
| 657 |
|
| 658 |
#ifndef DISABLE_DEPRECATED |
| 659 |
if (p_dict.has("is_deprecated")) { |
| 660 |
doc.is_deprecated = p_dict["is_deprecated"]; |
| 661 |
} |
| 662 |
|
| 663 |
if (p_dict.has("is_experimental")) { |
| 664 |
doc.is_experimental = p_dict["is_experimental"]; |
| 665 |
} |
| 666 |
#endif |
| 667 |
|
| 668 |
if (p_dict.has("deprecated")) { |
| 669 |
doc.is_deprecated = true; |
| 670 |
doc.deprecated_message = p_dict["deprecated"]; |
| 671 |
} |
| 672 |
|
| 673 |
if (p_dict.has("experimental")) { |
| 674 |
doc.is_experimental = true; |
| 675 |
doc.experimental_message = p_dict["experimental"]; |
| 676 |
} |
| 677 |
|
| 678 |
return doc; |
| 679 |
} |
| 680 |
static Dictionary to_dict(const EnumDoc &p_doc) { |
| 681 |
Dictionary dict; |
| 682 |
|
| 683 |
if (!p_doc.description.is_empty()) { |
| 684 |
dict["description"] = p_doc.description; |
| 685 |
} |
| 686 |
|
| 687 |
if (p_doc.is_deprecated) { |
| 688 |
dict["deprecated"] = p_doc.deprecated_message; |
| 689 |
} |
| 690 |
|
| 691 |
if (p_doc.is_experimental) { |
| 692 |
dict["experimental"] = p_doc.experimental_message; |
| 693 |
} |
| 694 |
|
| 695 |
return dict; |
| 696 |
} |
| 697 |
}; |
| 698 |
|
| 699 |
struct ClassDoc { |
| 700 |
String name; |
| 701 |
String inherits; |
| 702 |
String brief_description; |
| 703 |
String description; |
| 704 |
String keywords; |
| 705 |
Vector<TutorialDoc> tutorials; |
| 706 |
Vector<MethodDoc> constructors; |
| 707 |
Vector<MethodDoc> methods; |
| 708 |
Vector<MethodDoc> operators; |
| 709 |
Vector<MethodDoc> signals; |
| 710 |
Vector<ConstantDoc> constants; |
| 711 |
HashMap<String, EnumDoc> enums; |
| 712 |
Vector<PropertyDoc> properties; |
| 713 |
Vector<MethodDoc> annotations; |
| 714 |
Vector<ThemeItemDoc> theme_properties; |
| 715 |
bool is_deprecated = false; |
| 716 |
String deprecated_message; |
| 717 |
bool is_experimental = false; |
| 718 |
String experimental_message; |
| 719 |
bool is_script_doc = false; |
| 720 |
String script_path; |
| 721 |
bool operator<(const ClassDoc &p_class) const { |
| 722 |
return name < p_class.name; |
| 723 |
} |
| 724 |
static ClassDoc from_dict(const Dictionary &p_dict) { |
| 725 |
ClassDoc doc; |
| 726 |
|
| 727 |
if (p_dict.has("name")) { |
| 728 |
doc.name = p_dict["name"]; |
| 729 |
} |
| 730 |
|
| 731 |
if (p_dict.has("inherits")) { |
| 732 |
doc.inherits = p_dict["inherits"]; |
| 733 |
} |
| 734 |
|
| 735 |
if (p_dict.has("brief_description")) { |
| 736 |
doc.brief_description = p_dict["brief_description"]; |
| 737 |
} |
| 738 |
|
| 739 |
if (p_dict.has("description")) { |
| 740 |
doc.description = p_dict["description"]; |
| 741 |
} |
| 742 |
|
| 743 |
if (p_dict.has("keywords")) { |
| 744 |
doc.keywords = p_dict["keywords"]; |
| 745 |
} |
| 746 |
|
| 747 |
Array tutorials; |
| 748 |
if (p_dict.has("tutorials")) { |
| 749 |
tutorials = p_dict["tutorials"]; |
| 750 |
} |
| 751 |
for (int i = 0; i < tutorials.size(); i++) { |
| 752 |
doc.tutorials.push_back(TutorialDoc::from_dict(tutorials[i])); |
| 753 |
} |
| 754 |
|
| 755 |
Array constructors; |
| 756 |
if (p_dict.has("constructors")) { |
| 757 |
constructors = p_dict["constructors"]; |
| 758 |
} |
| 759 |
for (int i = 0; i < constructors.size(); i++) { |
| 760 |
doc.constructors.push_back(MethodDoc::from_dict(constructors[i])); |
| 761 |
} |
| 762 |
|
| 763 |
Array methods; |
| 764 |
if (p_dict.has("methods")) { |
| 765 |
methods = p_dict["methods"]; |
| 766 |
} |
| 767 |
for (int i = 0; i < methods.size(); i++) { |
| 768 |
doc.methods.push_back(MethodDoc::from_dict(methods[i])); |
| 769 |
} |
| 770 |
|
| 771 |
Array operators; |
| 772 |
if (p_dict.has("operators")) { |
| 773 |
operators = p_dict["operators"]; |
| 774 |
} |
| 775 |
for (int i = 0; i < operators.size(); i++) { |
| 776 |
doc.operators.push_back(MethodDoc::from_dict(operators[i])); |
| 777 |
} |
| 778 |
|
| 779 |
Array signals; |
| 780 |
if (p_dict.has("signals")) { |
| 781 |
signals = p_dict["signals"]; |
| 782 |
} |
| 783 |
for (int i = 0; i < signals.size(); i++) { |
| 784 |
doc.signals.push_back(MethodDoc::from_dict(signals[i])); |
| 785 |
} |
| 786 |
|
| 787 |
Array constants; |
| 788 |
if (p_dict.has("constants")) { |
| 789 |
constants = p_dict["constants"]; |
| 790 |
} |
| 791 |
for (int i = 0; i < constants.size(); i++) { |
| 792 |
doc.constants.push_back(ConstantDoc::from_dict(constants[i])); |
| 793 |
} |
| 794 |
|
| 795 |
Dictionary enums; |
| 796 |
if (p_dict.has("enums")) { |
| 797 |
enums = p_dict["enums"]; |
| 798 |
} |
| 799 |
for (const KeyValue<Variant, Variant> &kv : enums) { |
| 800 |
doc.enums[kv.key] = EnumDoc::from_dict(kv.value); |
| 801 |
} |
| 802 |
|
| 803 |
Array properties; |
| 804 |
if (p_dict.has("properties")) { |
| 805 |
properties = p_dict["properties"]; |
| 806 |
} |
| 807 |
for (int i = 0; i < properties.size(); i++) { |
| 808 |
doc.properties.push_back(PropertyDoc::from_dict(properties[i])); |
| 809 |
} |
| 810 |
|
| 811 |
Array annotations; |
| 812 |
if (p_dict.has("annotations")) { |
| 813 |
annotations = p_dict["annotations"]; |
| 814 |
} |
| 815 |
for (int i = 0; i < annotations.size(); i++) { |
| 816 |
doc.annotations.push_back(MethodDoc::from_dict(annotations[i])); |
| 817 |
} |
| 818 |
|
| 819 |
Array theme_properties; |
| 820 |
if (p_dict.has("theme_properties")) { |
| 821 |
theme_properties = p_dict["theme_properties"]; |
| 822 |
} |
| 823 |
for (int i = 0; i < theme_properties.size(); i++) { |
| 824 |
doc.theme_properties.push_back(ThemeItemDoc::from_dict(theme_properties[i])); |
| 825 |
} |
| 826 |
|
| 827 |
#ifndef DISABLE_DEPRECATED |
| 828 |
if (p_dict.has("is_deprecated")) { |
| 829 |
doc.is_deprecated = p_dict["is_deprecated"]; |
| 830 |
} |
| 831 |
|
| 832 |
if (p_dict.has("is_experimental")) { |
| 833 |
doc.is_experimental = p_dict["is_experimental"]; |
| 834 |
} |
| 835 |
#endif |
| 836 |
|
| 837 |
if (p_dict.has("deprecated")) { |
| 838 |
doc.is_deprecated = true; |
| 839 |
doc.deprecated_message = p_dict["deprecated"]; |
| 840 |
} |
| 841 |
|
| 842 |
if (p_dict.has("experimental")) { |
| 843 |
doc.is_experimental = true; |
| 844 |
doc.experimental_message = p_dict["experimental"]; |
| 845 |
} |
| 846 |
|
| 847 |
if (p_dict.has("is_script_doc")) { |
| 848 |
doc.is_script_doc = p_dict["is_script_doc"]; |
| 849 |
} |
| 850 |
|
| 851 |
if (p_dict.has("script_path")) { |
| 852 |
doc.script_path = p_dict["script_path"]; |
| 853 |
} |
| 854 |
|
| 855 |
return doc; |
| 856 |
} |
| 857 |
static Dictionary to_dict(const ClassDoc &p_doc) { |
| 858 |
Dictionary dict; |
| 859 |
|
| 860 |
if (!p_doc.name.is_empty()) { |
| 861 |
dict["name"] = p_doc.name; |
| 862 |
} |
| 863 |
|
| 864 |
if (!p_doc.inherits.is_empty()) { |
| 865 |
dict["inherits"] = p_doc.inherits; |
| 866 |
} |
| 867 |
|
| 868 |
if (!p_doc.brief_description.is_empty()) { |
| 869 |
dict["brief_description"] = p_doc.brief_description; |
| 870 |
} |
| 871 |
|
| 872 |
if (!p_doc.description.is_empty()) { |
| 873 |
dict["description"] = p_doc.description; |
| 874 |
} |
| 875 |
|
| 876 |
if (!p_doc.tutorials.is_empty()) { |
| 877 |
Array tutorials; |
| 878 |
for (int i = 0; i < p_doc.tutorials.size(); i++) { |
| 879 |
tutorials.push_back(TutorialDoc::to_dict(p_doc.tutorials[i])); |
| 880 |
} |
| 881 |
dict["tutorials"] = tutorials; |
| 882 |
} |
| 883 |
|
| 884 |
if (!p_doc.constructors.is_empty()) { |
| 885 |
Array constructors; |
| 886 |
for (int i = 0; i < p_doc.constructors.size(); i++) { |
| 887 |
constructors.push_back(MethodDoc::to_dict(p_doc.constructors[i])); |
| 888 |
} |
| 889 |
dict["constructors"] = constructors; |
| 890 |
} |
| 891 |
|
| 892 |
if (!p_doc.methods.is_empty()) { |
| 893 |
Array methods; |
| 894 |
for (int i = 0; i < p_doc.methods.size(); i++) { |
| 895 |
methods.push_back(MethodDoc::to_dict(p_doc.methods[i])); |
| 896 |
} |
| 897 |
dict["methods"] = methods; |
| 898 |
} |
| 899 |
|
| 900 |
if (!p_doc.operators.is_empty()) { |
| 901 |
Array operators; |
| 902 |
for (int i = 0; i < p_doc.operators.size(); i++) { |
| 903 |
operators.push_back(MethodDoc::to_dict(p_doc.operators[i])); |
| 904 |
} |
| 905 |
dict["operators"] = operators; |
| 906 |
} |
| 907 |
|
| 908 |
if (!p_doc.signals.is_empty()) { |
| 909 |
Array signals; |
| 910 |
for (int i = 0; i < p_doc.signals.size(); i++) { |
| 911 |
signals.push_back(MethodDoc::to_dict(p_doc.signals[i])); |
| 912 |
} |
| 913 |
dict["signals"] = signals; |
| 914 |
} |
| 915 |
|
| 916 |
if (!p_doc.constants.is_empty()) { |
| 917 |
Array constants; |
| 918 |
for (int i = 0; i < p_doc.constants.size(); i++) { |
| 919 |
constants.push_back(ConstantDoc::to_dict(p_doc.constants[i])); |
| 920 |
} |
| 921 |
dict["constants"] = constants; |
| 922 |
} |
| 923 |
|
| 924 |
if (!p_doc.enums.is_empty()) { |
| 925 |
Dictionary enums; |
| 926 |
for (const KeyValue<String, EnumDoc> &E : p_doc.enums) { |
| 927 |
enums[E.key] = EnumDoc::to_dict(E.value); |
| 928 |
} |
| 929 |
dict["enums"] = enums; |
| 930 |
} |
| 931 |
|
| 932 |
if (!p_doc.properties.is_empty()) { |
| 933 |
Array properties; |
| 934 |
for (int i = 0; i < p_doc.properties.size(); i++) { |
| 935 |
properties.push_back(PropertyDoc::to_dict(p_doc.properties[i])); |
| 936 |
} |
| 937 |
dict["properties"] = properties; |
| 938 |
} |
| 939 |
|
| 940 |
if (!p_doc.annotations.is_empty()) { |
| 941 |
Array annotations; |
| 942 |
for (int i = 0; i < p_doc.annotations.size(); i++) { |
| 943 |
annotations.push_back(MethodDoc::to_dict(p_doc.annotations[i])); |
| 944 |
} |
| 945 |
dict["annotations"] = annotations; |
| 946 |
} |
| 947 |
|
| 948 |
if (!p_doc.theme_properties.is_empty()) { |
| 949 |
Array theme_properties; |
| 950 |
for (int i = 0; i < p_doc.theme_properties.size(); i++) { |
| 951 |
theme_properties.push_back(ThemeItemDoc::to_dict(p_doc.theme_properties[i])); |
| 952 |
} |
| 953 |
dict["theme_properties"] = theme_properties; |
| 954 |
} |
| 955 |
|
| 956 |
if (p_doc.is_deprecated) { |
| 957 |
dict["deprecated"] = p_doc.deprecated_message; |
| 958 |
} |
| 959 |
|
| 960 |
if (p_doc.is_experimental) { |
| 961 |
dict["experimental"] = p_doc.experimental_message; |
| 962 |
} |
| 963 |
|
| 964 |
dict["is_script_doc"] = p_doc.is_script_doc; |
| 965 |
|
| 966 |
if (!p_doc.script_path.is_empty()) { |
| 967 |
dict["script_path"] = p_doc.script_path; |
| 968 |
} |
| 969 |
|
| 970 |
if (!p_doc.keywords.is_empty()) { |
| 971 |
dict["keywords"] = p_doc.keywords; |
| 972 |
} |
| 973 |
|
| 974 |
return dict; |
| 975 |
} |
| 976 |
}; |
| 977 |
|
| 978 |
static String get_default_value_string(const Variant &p_value); |
| 979 |
|
| 980 |
static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo); |
| 981 |
static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo); |
| 982 |
static void method_doc_from_methodinfo(DocData::MethodDoc &p_method, const MethodInfo &p_methodinfo, const String &p_desc); |
| 983 |
}; |