doc_data.h 25 KB

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