doc_data.h 24 KB

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