doc_data.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  1. /**************************************************************************/
  2. /* doc_data.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #pragma once
  31. #include "core/io/xml_parser.h"
  32. #include "core/variant/variant.h"
  33. class DocData {
  34. public:
  35. struct ArgumentDoc {
  36. String name;
  37. String type;
  38. String enumeration;
  39. bool is_bitfield = false;
  40. String default_value;
  41. bool operator<(const ArgumentDoc &p_arg) const {
  42. if (name == p_arg.name) {
  43. return type < p_arg.type;
  44. }
  45. return name < p_arg.name;
  46. }
  47. static ArgumentDoc from_dict(const Dictionary &p_dict) {
  48. ArgumentDoc doc;
  49. if (p_dict.has("name")) {
  50. doc.name = p_dict["name"];
  51. }
  52. if (p_dict.has("type")) {
  53. doc.type = p_dict["type"];
  54. }
  55. if (p_dict.has("enumeration")) {
  56. doc.enumeration = p_dict["enumeration"];
  57. if (p_dict.has("is_bitfield")) {
  58. doc.is_bitfield = p_dict["is_bitfield"];
  59. }
  60. }
  61. if (p_dict.has("default_value")) {
  62. doc.default_value = p_dict["default_value"];
  63. }
  64. return doc;
  65. }
  66. static Dictionary to_dict(const ArgumentDoc &p_doc) {
  67. Dictionary dict;
  68. if (!p_doc.name.is_empty()) {
  69. dict["name"] = p_doc.name;
  70. }
  71. if (!p_doc.type.is_empty()) {
  72. dict["type"] = p_doc.type;
  73. }
  74. if (!p_doc.enumeration.is_empty()) {
  75. dict["enumeration"] = p_doc.enumeration;
  76. dict["is_bitfield"] = p_doc.is_bitfield;
  77. }
  78. if (!p_doc.default_value.is_empty()) {
  79. dict["default_value"] = p_doc.default_value;
  80. }
  81. return dict;
  82. }
  83. };
  84. struct MethodDoc {
  85. String name;
  86. String return_type;
  87. String return_enum;
  88. bool return_is_bitfield = false;
  89. String qualifiers;
  90. String description;
  91. bool is_deprecated = false;
  92. String deprecated_message;
  93. bool is_experimental = false;
  94. String experimental_message;
  95. Vector<ArgumentDoc> arguments;
  96. Vector<int> errors_returned;
  97. String keywords;
  98. bool operator<(const MethodDoc &p_method) const {
  99. if (name == p_method.name) {
  100. // Must be an operator or a constructor since there is no other overloading
  101. if (name.left(8) == "operator") {
  102. if (arguments.size() == p_method.arguments.size()) {
  103. if (arguments.size() == 0) {
  104. return false;
  105. }
  106. return arguments[0].type < p_method.arguments[0].type;
  107. }
  108. return arguments.size() < p_method.arguments.size();
  109. } else {
  110. // Must be a constructor
  111. // We want this arbitrary order for a class "Foo":
  112. // - 1. Default constructor: Foo()
  113. // - 2. Copy constructor: Foo(Foo)
  114. // - 3+. Other constructors Foo(Bar, ...) based on first argument's name
  115. if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1.
  116. return arguments.size() < p_method.arguments.size();
  117. }
  118. if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2.
  119. return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type);
  120. }
  121. return arguments[0] < p_method.arguments[0];
  122. }
  123. }
  124. return name.naturalcasecmp_to(p_method.name) < 0;
  125. }
  126. static MethodDoc from_dict(const Dictionary &p_dict) {
  127. MethodDoc doc;
  128. if (p_dict.has("name")) {
  129. doc.name = p_dict["name"];
  130. }
  131. if (p_dict.has("return_type")) {
  132. doc.return_type = p_dict["return_type"];
  133. }
  134. if (p_dict.has("return_enum")) {
  135. doc.return_enum = p_dict["return_enum"];
  136. if (p_dict.has("return_is_bitfield")) {
  137. doc.return_is_bitfield = p_dict["return_is_bitfield"];
  138. }
  139. }
  140. if (p_dict.has("qualifiers")) {
  141. doc.qualifiers = p_dict["qualifiers"];
  142. }
  143. if (p_dict.has("description")) {
  144. doc.description = p_dict["description"];
  145. }
  146. #ifndef DISABLE_DEPRECATED
  147. if (p_dict.has("is_deprecated")) {
  148. doc.is_deprecated = p_dict["is_deprecated"];
  149. }
  150. if (p_dict.has("is_experimental")) {
  151. doc.is_experimental = p_dict["is_experimental"];
  152. }
  153. #endif
  154. if (p_dict.has("deprecated")) {
  155. doc.is_deprecated = true;
  156. doc.deprecated_message = p_dict["deprecated"];
  157. }
  158. if (p_dict.has("experimental")) {
  159. doc.is_experimental = true;
  160. doc.experimental_message = p_dict["experimental"];
  161. }
  162. Array arguments;
  163. if (p_dict.has("arguments")) {
  164. arguments = p_dict["arguments"];
  165. }
  166. for (int i = 0; i < arguments.size(); i++) {
  167. doc.arguments.push_back(ArgumentDoc::from_dict(arguments[i]));
  168. }
  169. Array errors_returned;
  170. if (p_dict.has("errors_returned")) {
  171. errors_returned = p_dict["errors_returned"];
  172. }
  173. for (int i = 0; i < errors_returned.size(); i++) {
  174. doc.errors_returned.push_back(errors_returned[i]);
  175. }
  176. if (p_dict.has("keywords")) {
  177. doc.keywords = p_dict["keywords"];
  178. }
  179. return doc;
  180. }
  181. static Dictionary to_dict(const MethodDoc &p_doc) {
  182. Dictionary dict;
  183. if (!p_doc.name.is_empty()) {
  184. dict["name"] = p_doc.name;
  185. }
  186. if (!p_doc.return_type.is_empty()) {
  187. dict["return_type"] = p_doc.return_type;
  188. }
  189. if (!p_doc.return_enum.is_empty()) {
  190. dict["return_enum"] = p_doc.return_enum;
  191. dict["return_is_bitfield"] = p_doc.return_is_bitfield;
  192. }
  193. if (!p_doc.qualifiers.is_empty()) {
  194. dict["qualifiers"] = p_doc.qualifiers;
  195. }
  196. if (!p_doc.description.is_empty()) {
  197. dict["description"] = p_doc.description;
  198. }
  199. if (p_doc.is_deprecated) {
  200. dict["deprecated"] = p_doc.deprecated_message;
  201. }
  202. if (p_doc.is_experimental) {
  203. dict["experimental"] = p_doc.experimental_message;
  204. }
  205. if (!p_doc.keywords.is_empty()) {
  206. dict["keywords"] = p_doc.keywords;
  207. }
  208. if (!p_doc.arguments.is_empty()) {
  209. Array arguments;
  210. for (int i = 0; i < p_doc.arguments.size(); i++) {
  211. arguments.push_back(ArgumentDoc::to_dict(p_doc.arguments[i]));
  212. }
  213. dict["arguments"] = arguments;
  214. }
  215. if (!p_doc.errors_returned.is_empty()) {
  216. Array errors_returned;
  217. for (int i = 0; i < p_doc.errors_returned.size(); i++) {
  218. errors_returned.push_back(p_doc.errors_returned[i]);
  219. }
  220. dict["errors_returned"] = errors_returned;
  221. }
  222. return dict;
  223. }
  224. };
  225. struct ConstantDoc {
  226. String name;
  227. String value;
  228. bool is_value_valid = false;
  229. String type;
  230. String enumeration;
  231. bool is_bitfield = false;
  232. String description;
  233. bool is_deprecated = false;
  234. String deprecated_message;
  235. bool is_experimental = false;
  236. String experimental_message;
  237. String keywords;
  238. bool operator<(const ConstantDoc &p_const) const {
  239. return name < p_const.name;
  240. }
  241. static ConstantDoc from_dict(const Dictionary &p_dict) {
  242. ConstantDoc doc;
  243. if (p_dict.has("name")) {
  244. doc.name = p_dict["name"];
  245. }
  246. if (p_dict.has("value")) {
  247. doc.value = p_dict["value"];
  248. }
  249. if (p_dict.has("is_value_valid")) {
  250. doc.is_value_valid = p_dict["is_value_valid"];
  251. }
  252. if (p_dict.has("type")) {
  253. doc.type = p_dict["type"];
  254. }
  255. if (p_dict.has("enumeration")) {
  256. doc.enumeration = p_dict["enumeration"];
  257. if (p_dict.has("is_bitfield")) {
  258. doc.is_bitfield = p_dict["is_bitfield"];
  259. }
  260. }
  261. if (p_dict.has("description")) {
  262. doc.description = p_dict["description"];
  263. }
  264. #ifndef DISABLE_DEPRECATED
  265. if (p_dict.has("is_deprecated")) {
  266. doc.is_deprecated = p_dict["is_deprecated"];
  267. }
  268. if (p_dict.has("is_experimental")) {
  269. doc.is_experimental = p_dict["is_experimental"];
  270. }
  271. #endif
  272. if (p_dict.has("deprecated")) {
  273. doc.is_deprecated = true;
  274. doc.deprecated_message = p_dict["deprecated"];
  275. }
  276. if (p_dict.has("experimental")) {
  277. doc.is_experimental = true;
  278. doc.experimental_message = p_dict["experimental"];
  279. }
  280. if (p_dict.has("keywords")) {
  281. doc.keywords = p_dict["keywords"];
  282. }
  283. return doc;
  284. }
  285. static Dictionary to_dict(const ConstantDoc &p_doc) {
  286. Dictionary dict;
  287. if (!p_doc.name.is_empty()) {
  288. dict["name"] = p_doc.name;
  289. }
  290. if (!p_doc.value.is_empty()) {
  291. dict["value"] = p_doc.value;
  292. }
  293. dict["is_value_valid"] = p_doc.is_value_valid;
  294. dict["type"] = p_doc.type;
  295. if (!p_doc.enumeration.is_empty()) {
  296. dict["enumeration"] = p_doc.enumeration;
  297. dict["is_bitfield"] = p_doc.is_bitfield;
  298. }
  299. if (!p_doc.description.is_empty()) {
  300. dict["description"] = p_doc.description;
  301. }
  302. if (p_doc.is_deprecated) {
  303. dict["deprecated"] = p_doc.deprecated_message;
  304. }
  305. if (p_doc.is_experimental) {
  306. dict["experimental"] = p_doc.experimental_message;
  307. }
  308. if (!p_doc.keywords.is_empty()) {
  309. dict["keywords"] = p_doc.keywords;
  310. }
  311. return dict;
  312. }
  313. };
  314. struct PropertyDoc {
  315. String name;
  316. String type;
  317. String enumeration;
  318. bool is_bitfield = false;
  319. String description;
  320. String setter, getter;
  321. String default_value;
  322. bool overridden = false;
  323. String overrides;
  324. bool is_deprecated = false;
  325. String deprecated_message;
  326. bool is_experimental = false;
  327. String experimental_message;
  328. String keywords;
  329. bool operator<(const PropertyDoc &p_prop) const {
  330. return name.naturalcasecmp_to(p_prop.name) < 0;
  331. }
  332. static PropertyDoc from_dict(const Dictionary &p_dict) {
  333. PropertyDoc doc;
  334. if (p_dict.has("name")) {
  335. doc.name = p_dict["name"];
  336. }
  337. if (p_dict.has("type")) {
  338. doc.type = p_dict["type"];
  339. }
  340. if (p_dict.has("enumeration")) {
  341. doc.enumeration = p_dict["enumeration"];
  342. if (p_dict.has("is_bitfield")) {
  343. doc.is_bitfield = p_dict["is_bitfield"];
  344. }
  345. }
  346. if (p_dict.has("description")) {
  347. doc.description = p_dict["description"];
  348. }
  349. if (p_dict.has("setter")) {
  350. doc.setter = p_dict["setter"];
  351. }
  352. if (p_dict.has("getter")) {
  353. doc.getter = p_dict["getter"];
  354. }
  355. if (p_dict.has("default_value")) {
  356. doc.default_value = p_dict["default_value"];
  357. }
  358. if (p_dict.has("overridden")) {
  359. doc.overridden = p_dict["overridden"];
  360. }
  361. if (p_dict.has("overrides")) {
  362. doc.overrides = p_dict["overrides"];
  363. }
  364. #ifndef DISABLE_DEPRECATED
  365. if (p_dict.has("is_deprecated")) {
  366. doc.is_deprecated = p_dict["is_deprecated"];
  367. }
  368. if (p_dict.has("is_experimental")) {
  369. doc.is_experimental = p_dict["is_experimental"];
  370. }
  371. #endif
  372. if (p_dict.has("deprecated")) {
  373. doc.is_deprecated = true;
  374. doc.deprecated_message = p_dict["deprecated"];
  375. }
  376. if (p_dict.has("experimental")) {
  377. doc.is_experimental = true;
  378. doc.experimental_message = p_dict["experimental"];
  379. }
  380. if (p_dict.has("keywords")) {
  381. doc.keywords = p_dict["keywords"];
  382. }
  383. return doc;
  384. }
  385. static Dictionary to_dict(const PropertyDoc &p_doc) {
  386. Dictionary dict;
  387. if (!p_doc.name.is_empty()) {
  388. dict["name"] = p_doc.name;
  389. }
  390. if (!p_doc.type.is_empty()) {
  391. dict["type"] = p_doc.type;
  392. }
  393. if (!p_doc.enumeration.is_empty()) {
  394. dict["enumeration"] = p_doc.enumeration;
  395. dict["is_bitfield"] = p_doc.is_bitfield;
  396. }
  397. if (!p_doc.description.is_empty()) {
  398. dict["description"] = p_doc.description;
  399. }
  400. if (!p_doc.setter.is_empty()) {
  401. dict["setter"] = p_doc.setter;
  402. }
  403. if (!p_doc.getter.is_empty()) {
  404. dict["getter"] = p_doc.getter;
  405. }
  406. if (!p_doc.default_value.is_empty()) {
  407. dict["default_value"] = p_doc.default_value;
  408. }
  409. dict["overridden"] = p_doc.overridden;
  410. if (!p_doc.overrides.is_empty()) {
  411. dict["overrides"] = p_doc.overrides;
  412. }
  413. if (p_doc.is_deprecated) {
  414. dict["deprecated"] = p_doc.deprecated_message;
  415. }
  416. if (p_doc.is_experimental) {
  417. dict["experimental"] = p_doc.experimental_message;
  418. }
  419. if (!p_doc.keywords.is_empty()) {
  420. dict["keywords"] = p_doc.keywords;
  421. }
  422. return dict;
  423. }
  424. };
  425. struct ThemeItemDoc {
  426. String name;
  427. String type;
  428. String data_type;
  429. String description;
  430. bool is_deprecated = false;
  431. String deprecated_message;
  432. bool is_experimental = false;
  433. String experimental_message;
  434. String default_value;
  435. String keywords;
  436. bool operator<(const ThemeItemDoc &p_theme_item) const {
  437. // First sort by the data type, then by name.
  438. if (data_type == p_theme_item.data_type) {
  439. return name.naturalcasecmp_to(p_theme_item.name) < 0;
  440. }
  441. return data_type < p_theme_item.data_type;
  442. }
  443. static ThemeItemDoc from_dict(const Dictionary &p_dict) {
  444. ThemeItemDoc doc;
  445. if (p_dict.has("name")) {
  446. doc.name = p_dict["name"];
  447. }
  448. if (p_dict.has("type")) {
  449. doc.type = p_dict["type"];
  450. }
  451. if (p_dict.has("data_type")) {
  452. doc.data_type = p_dict["data_type"];
  453. }
  454. if (p_dict.has("description")) {
  455. doc.description = p_dict["description"];
  456. }
  457. if (p_dict.has("deprecated")) {
  458. doc.is_deprecated = true;
  459. doc.deprecated_message = p_dict["deprecated"];
  460. }
  461. if (p_dict.has("experimental")) {
  462. doc.is_experimental = true;
  463. doc.experimental_message = p_dict["experimental"];
  464. }
  465. if (p_dict.has("default_value")) {
  466. doc.default_value = p_dict["default_value"];
  467. }
  468. if (p_dict.has("keywords")) {
  469. doc.keywords = p_dict["keywords"];
  470. }
  471. return doc;
  472. }
  473. static Dictionary to_dict(const ThemeItemDoc &p_doc) {
  474. Dictionary dict;
  475. if (!p_doc.name.is_empty()) {
  476. dict["name"] = p_doc.name;
  477. }
  478. if (!p_doc.type.is_empty()) {
  479. dict["type"] = p_doc.type;
  480. }
  481. if (!p_doc.data_type.is_empty()) {
  482. dict["data_type"] = p_doc.data_type;
  483. }
  484. if (!p_doc.description.is_empty()) {
  485. dict["description"] = p_doc.description;
  486. }
  487. if (p_doc.is_deprecated) {
  488. dict["deprecated"] = p_doc.deprecated_message;
  489. }
  490. if (p_doc.is_experimental) {
  491. dict["experimental"] = p_doc.experimental_message;
  492. }
  493. if (!p_doc.default_value.is_empty()) {
  494. dict["default_value"] = p_doc.default_value;
  495. }
  496. if (!p_doc.keywords.is_empty()) {
  497. dict["keywords"] = p_doc.keywords;
  498. }
  499. return dict;
  500. }
  501. };
  502. struct TutorialDoc {
  503. String link;
  504. String title;
  505. static TutorialDoc from_dict(const Dictionary &p_dict) {
  506. TutorialDoc doc;
  507. if (p_dict.has("link")) {
  508. doc.link = p_dict["link"];
  509. }
  510. if (p_dict.has("title")) {
  511. doc.title = p_dict["title"];
  512. }
  513. return doc;
  514. }
  515. static Dictionary to_dict(const TutorialDoc &p_doc) {
  516. Dictionary dict;
  517. if (!p_doc.link.is_empty()) {
  518. dict["link"] = p_doc.link;
  519. }
  520. if (!p_doc.title.is_empty()) {
  521. dict["title"] = p_doc.title;
  522. }
  523. return dict;
  524. }
  525. };
  526. struct EnumDoc {
  527. String description;
  528. bool is_deprecated = false;
  529. String deprecated_message;
  530. bool is_experimental = false;
  531. String experimental_message;
  532. static EnumDoc from_dict(const Dictionary &p_dict) {
  533. EnumDoc doc;
  534. if (p_dict.has("description")) {
  535. doc.description = p_dict["description"];
  536. }
  537. #ifndef DISABLE_DEPRECATED
  538. if (p_dict.has("is_deprecated")) {
  539. doc.is_deprecated = p_dict["is_deprecated"];
  540. }
  541. if (p_dict.has("is_experimental")) {
  542. doc.is_experimental = p_dict["is_experimental"];
  543. }
  544. #endif
  545. if (p_dict.has("deprecated")) {
  546. doc.is_deprecated = true;
  547. doc.deprecated_message = p_dict["deprecated"];
  548. }
  549. if (p_dict.has("experimental")) {
  550. doc.is_experimental = true;
  551. doc.experimental_message = p_dict["experimental"];
  552. }
  553. return doc;
  554. }
  555. static Dictionary to_dict(const EnumDoc &p_doc) {
  556. Dictionary dict;
  557. if (!p_doc.description.is_empty()) {
  558. dict["description"] = p_doc.description;
  559. }
  560. if (p_doc.is_deprecated) {
  561. dict["deprecated"] = p_doc.deprecated_message;
  562. }
  563. if (p_doc.is_experimental) {
  564. dict["experimental"] = p_doc.experimental_message;
  565. }
  566. return dict;
  567. }
  568. };
  569. struct ClassDoc {
  570. String name;
  571. String inherits;
  572. String brief_description;
  573. String description;
  574. String keywords;
  575. Vector<TutorialDoc> tutorials;
  576. Vector<MethodDoc> constructors;
  577. Vector<MethodDoc> methods;
  578. Vector<MethodDoc> operators;
  579. Vector<MethodDoc> signals;
  580. Vector<ConstantDoc> constants;
  581. HashMap<String, EnumDoc> enums;
  582. Vector<PropertyDoc> properties;
  583. Vector<MethodDoc> annotations;
  584. Vector<ThemeItemDoc> theme_properties;
  585. bool is_deprecated = false;
  586. String deprecated_message;
  587. bool is_experimental = false;
  588. String experimental_message;
  589. bool is_script_doc = false;
  590. String script_path;
  591. bool operator<(const ClassDoc &p_class) const {
  592. return name < p_class.name;
  593. }
  594. static ClassDoc from_dict(const Dictionary &p_dict) {
  595. ClassDoc doc;
  596. if (p_dict.has("name")) {
  597. doc.name = p_dict["name"];
  598. }
  599. if (p_dict.has("inherits")) {
  600. doc.inherits = p_dict["inherits"];
  601. }
  602. if (p_dict.has("brief_description")) {
  603. doc.brief_description = p_dict["brief_description"];
  604. }
  605. if (p_dict.has("description")) {
  606. doc.description = p_dict["description"];
  607. }
  608. if (p_dict.has("keywords")) {
  609. doc.keywords = p_dict["keywords"];
  610. }
  611. Array tutorials;
  612. if (p_dict.has("tutorials")) {
  613. tutorials = p_dict["tutorials"];
  614. }
  615. for (int i = 0; i < tutorials.size(); i++) {
  616. doc.tutorials.push_back(TutorialDoc::from_dict(tutorials[i]));
  617. }
  618. Array constructors;
  619. if (p_dict.has("constructors")) {
  620. constructors = p_dict["constructors"];
  621. }
  622. for (int i = 0; i < constructors.size(); i++) {
  623. doc.constructors.push_back(MethodDoc::from_dict(constructors[i]));
  624. }
  625. Array methods;
  626. if (p_dict.has("methods")) {
  627. methods = p_dict["methods"];
  628. }
  629. for (int i = 0; i < methods.size(); i++) {
  630. doc.methods.push_back(MethodDoc::from_dict(methods[i]));
  631. }
  632. Array operators;
  633. if (p_dict.has("operators")) {
  634. operators = p_dict["operators"];
  635. }
  636. for (int i = 0; i < operators.size(); i++) {
  637. doc.operators.push_back(MethodDoc::from_dict(operators[i]));
  638. }
  639. Array signals;
  640. if (p_dict.has("signals")) {
  641. signals = p_dict["signals"];
  642. }
  643. for (int i = 0; i < signals.size(); i++) {
  644. doc.signals.push_back(MethodDoc::from_dict(signals[i]));
  645. }
  646. Array constants;
  647. if (p_dict.has("constants")) {
  648. constants = p_dict["constants"];
  649. }
  650. for (int i = 0; i < constants.size(); i++) {
  651. doc.constants.push_back(ConstantDoc::from_dict(constants[i]));
  652. }
  653. Dictionary enums;
  654. if (p_dict.has("enums")) {
  655. enums = p_dict["enums"];
  656. }
  657. for (int i = 0; i < enums.size(); i++) {
  658. doc.enums[enums.get_key_at_index(i)] = EnumDoc::from_dict(enums.get_value_at_index(i));
  659. }
  660. Array properties;
  661. if (p_dict.has("properties")) {
  662. properties = p_dict["properties"];
  663. }
  664. for (int i = 0; i < properties.size(); i++) {
  665. doc.properties.push_back(PropertyDoc::from_dict(properties[i]));
  666. }
  667. Array annotations;
  668. if (p_dict.has("annotations")) {
  669. annotations = p_dict["annotations"];
  670. }
  671. for (int i = 0; i < annotations.size(); i++) {
  672. doc.annotations.push_back(MethodDoc::from_dict(annotations[i]));
  673. }
  674. Array theme_properties;
  675. if (p_dict.has("theme_properties")) {
  676. theme_properties = p_dict["theme_properties"];
  677. }
  678. for (int i = 0; i < theme_properties.size(); i++) {
  679. doc.theme_properties.push_back(ThemeItemDoc::from_dict(theme_properties[i]));
  680. }
  681. #ifndef DISABLE_DEPRECATED
  682. if (p_dict.has("is_deprecated")) {
  683. doc.is_deprecated = p_dict["is_deprecated"];
  684. }
  685. if (p_dict.has("is_experimental")) {
  686. doc.is_experimental = p_dict["is_experimental"];
  687. }
  688. #endif
  689. if (p_dict.has("deprecated")) {
  690. doc.is_deprecated = true;
  691. doc.deprecated_message = p_dict["deprecated"];
  692. }
  693. if (p_dict.has("experimental")) {
  694. doc.is_experimental = true;
  695. doc.experimental_message = p_dict["experimental"];
  696. }
  697. if (p_dict.has("is_script_doc")) {
  698. doc.is_script_doc = p_dict["is_script_doc"];
  699. }
  700. if (p_dict.has("script_path")) {
  701. doc.script_path = p_dict["script_path"];
  702. }
  703. return doc;
  704. }
  705. static Dictionary to_dict(const ClassDoc &p_doc) {
  706. Dictionary dict;
  707. if (!p_doc.name.is_empty()) {
  708. dict["name"] = p_doc.name;
  709. }
  710. if (!p_doc.inherits.is_empty()) {
  711. dict["inherits"] = p_doc.inherits;
  712. }
  713. if (!p_doc.brief_description.is_empty()) {
  714. dict["brief_description"] = p_doc.brief_description;
  715. }
  716. if (!p_doc.description.is_empty()) {
  717. dict["description"] = p_doc.description;
  718. }
  719. if (!p_doc.tutorials.is_empty()) {
  720. Array tutorials;
  721. for (int i = 0; i < p_doc.tutorials.size(); i++) {
  722. tutorials.push_back(TutorialDoc::to_dict(p_doc.tutorials[i]));
  723. }
  724. dict["tutorials"] = tutorials;
  725. }
  726. if (!p_doc.constructors.is_empty()) {
  727. Array constructors;
  728. for (int i = 0; i < p_doc.constructors.size(); i++) {
  729. constructors.push_back(MethodDoc::to_dict(p_doc.constructors[i]));
  730. }
  731. dict["constructors"] = constructors;
  732. }
  733. if (!p_doc.methods.is_empty()) {
  734. Array methods;
  735. for (int i = 0; i < p_doc.methods.size(); i++) {
  736. methods.push_back(MethodDoc::to_dict(p_doc.methods[i]));
  737. }
  738. dict["methods"] = methods;
  739. }
  740. if (!p_doc.operators.is_empty()) {
  741. Array operators;
  742. for (int i = 0; i < p_doc.operators.size(); i++) {
  743. operators.push_back(MethodDoc::to_dict(p_doc.operators[i]));
  744. }
  745. dict["operators"] = operators;
  746. }
  747. if (!p_doc.signals.is_empty()) {
  748. Array signals;
  749. for (int i = 0; i < p_doc.signals.size(); i++) {
  750. signals.push_back(MethodDoc::to_dict(p_doc.signals[i]));
  751. }
  752. dict["signals"] = signals;
  753. }
  754. if (!p_doc.constants.is_empty()) {
  755. Array constants;
  756. for (int i = 0; i < p_doc.constants.size(); i++) {
  757. constants.push_back(ConstantDoc::to_dict(p_doc.constants[i]));
  758. }
  759. dict["constants"] = constants;
  760. }
  761. if (!p_doc.enums.is_empty()) {
  762. Dictionary enums;
  763. for (const KeyValue<String, EnumDoc> &E : p_doc.enums) {
  764. enums[E.key] = EnumDoc::to_dict(E.value);
  765. }
  766. dict["enums"] = enums;
  767. }
  768. if (!p_doc.properties.is_empty()) {
  769. Array properties;
  770. for (int i = 0; i < p_doc.properties.size(); i++) {
  771. properties.push_back(PropertyDoc::to_dict(p_doc.properties[i]));
  772. }
  773. dict["properties"] = properties;
  774. }
  775. if (!p_doc.annotations.is_empty()) {
  776. Array annotations;
  777. for (int i = 0; i < p_doc.annotations.size(); i++) {
  778. annotations.push_back(MethodDoc::to_dict(p_doc.annotations[i]));
  779. }
  780. dict["annotations"] = annotations;
  781. }
  782. if (!p_doc.theme_properties.is_empty()) {
  783. Array theme_properties;
  784. for (int i = 0; i < p_doc.theme_properties.size(); i++) {
  785. theme_properties.push_back(ThemeItemDoc::to_dict(p_doc.theme_properties[i]));
  786. }
  787. dict["theme_properties"] = theme_properties;
  788. }
  789. if (p_doc.is_deprecated) {
  790. dict["deprecated"] = p_doc.deprecated_message;
  791. }
  792. if (p_doc.is_experimental) {
  793. dict["experimental"] = p_doc.experimental_message;
  794. }
  795. dict["is_script_doc"] = p_doc.is_script_doc;
  796. if (!p_doc.script_path.is_empty()) {
  797. dict["script_path"] = p_doc.script_path;
  798. }
  799. if (!p_doc.keywords.is_empty()) {
  800. dict["keywords"] = p_doc.keywords;
  801. }
  802. return dict;
  803. }
  804. };
  805. static String get_default_value_string(const Variant &p_value);
  806. static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo);
  807. static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo);
  808. static void method_doc_from_methodinfo(DocData::MethodDoc &p_method, const MethodInfo &p_methodinfo, const String &p_desc);
  809. };