doc_data.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  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. bool is_deprecated = false;
  435. String deprecated_message;
  436. bool is_experimental = false;
  437. String experimental_message;
  438. String default_value;
  439. String keywords;
  440. bool operator<(const ThemeItemDoc &p_theme_item) const {
  441. // First sort by the data type, then by name.
  442. if (data_type == p_theme_item.data_type) {
  443. return name.naturalcasecmp_to(p_theme_item.name) < 0;
  444. }
  445. return data_type < p_theme_item.data_type;
  446. }
  447. static ThemeItemDoc from_dict(const Dictionary &p_dict) {
  448. ThemeItemDoc doc;
  449. if (p_dict.has("name")) {
  450. doc.name = p_dict["name"];
  451. }
  452. if (p_dict.has("type")) {
  453. doc.type = p_dict["type"];
  454. }
  455. if (p_dict.has("data_type")) {
  456. doc.data_type = p_dict["data_type"];
  457. }
  458. if (p_dict.has("description")) {
  459. doc.description = p_dict["description"];
  460. }
  461. if (p_dict.has("deprecated")) {
  462. doc.is_deprecated = true;
  463. doc.deprecated_message = p_dict["deprecated"];
  464. }
  465. if (p_dict.has("experimental")) {
  466. doc.is_experimental = true;
  467. doc.experimental_message = p_dict["experimental"];
  468. }
  469. if (p_dict.has("default_value")) {
  470. doc.default_value = p_dict["default_value"];
  471. }
  472. if (p_dict.has("keywords")) {
  473. doc.keywords = p_dict["keywords"];
  474. }
  475. return doc;
  476. }
  477. static Dictionary to_dict(const ThemeItemDoc &p_doc) {
  478. Dictionary dict;
  479. if (!p_doc.name.is_empty()) {
  480. dict["name"] = p_doc.name;
  481. }
  482. if (!p_doc.type.is_empty()) {
  483. dict["type"] = p_doc.type;
  484. }
  485. if (!p_doc.data_type.is_empty()) {
  486. dict["data_type"] = p_doc.data_type;
  487. }
  488. if (!p_doc.description.is_empty()) {
  489. dict["description"] = p_doc.description;
  490. }
  491. if (p_doc.is_deprecated) {
  492. dict["deprecated"] = p_doc.deprecated_message;
  493. }
  494. if (p_doc.is_experimental) {
  495. dict["experimental"] = p_doc.experimental_message;
  496. }
  497. if (!p_doc.default_value.is_empty()) {
  498. dict["default_value"] = p_doc.default_value;
  499. }
  500. if (!p_doc.keywords.is_empty()) {
  501. dict["keywords"] = p_doc.keywords;
  502. }
  503. return dict;
  504. }
  505. };
  506. struct TutorialDoc {
  507. String link;
  508. String title;
  509. static TutorialDoc from_dict(const Dictionary &p_dict) {
  510. TutorialDoc doc;
  511. if (p_dict.has("link")) {
  512. doc.link = p_dict["link"];
  513. }
  514. if (p_dict.has("title")) {
  515. doc.title = p_dict["title"];
  516. }
  517. return doc;
  518. }
  519. static Dictionary to_dict(const TutorialDoc &p_doc) {
  520. Dictionary dict;
  521. if (!p_doc.link.is_empty()) {
  522. dict["link"] = p_doc.link;
  523. }
  524. if (!p_doc.title.is_empty()) {
  525. dict["title"] = p_doc.title;
  526. }
  527. return dict;
  528. }
  529. };
  530. struct EnumDoc {
  531. String description;
  532. bool is_deprecated = false;
  533. String deprecated_message;
  534. bool is_experimental = false;
  535. String experimental_message;
  536. static EnumDoc from_dict(const Dictionary &p_dict) {
  537. EnumDoc doc;
  538. if (p_dict.has("description")) {
  539. doc.description = p_dict["description"];
  540. }
  541. #ifndef DISABLE_DEPRECATED
  542. if (p_dict.has("is_deprecated")) {
  543. doc.is_deprecated = p_dict["is_deprecated"];
  544. }
  545. if (p_dict.has("is_experimental")) {
  546. doc.is_experimental = p_dict["is_experimental"];
  547. }
  548. #endif
  549. if (p_dict.has("deprecated")) {
  550. doc.is_deprecated = true;
  551. doc.deprecated_message = p_dict["deprecated"];
  552. }
  553. if (p_dict.has("experimental")) {
  554. doc.is_experimental = true;
  555. doc.experimental_message = p_dict["experimental"];
  556. }
  557. return doc;
  558. }
  559. static Dictionary to_dict(const EnumDoc &p_doc) {
  560. Dictionary dict;
  561. if (!p_doc.description.is_empty()) {
  562. dict["description"] = p_doc.description;
  563. }
  564. if (p_doc.is_deprecated) {
  565. dict["deprecated"] = p_doc.deprecated_message;
  566. }
  567. if (p_doc.is_experimental) {
  568. dict["experimental"] = p_doc.experimental_message;
  569. }
  570. return dict;
  571. }
  572. };
  573. struct ClassDoc {
  574. String name;
  575. String inherits;
  576. String brief_description;
  577. String description;
  578. String keywords;
  579. Vector<TutorialDoc> tutorials;
  580. Vector<MethodDoc> constructors;
  581. Vector<MethodDoc> methods;
  582. Vector<MethodDoc> operators;
  583. Vector<MethodDoc> signals;
  584. Vector<ConstantDoc> constants;
  585. HashMap<String, EnumDoc> enums;
  586. Vector<PropertyDoc> properties;
  587. Vector<MethodDoc> annotations;
  588. Vector<ThemeItemDoc> theme_properties;
  589. bool is_deprecated = false;
  590. String deprecated_message;
  591. bool is_experimental = false;
  592. String experimental_message;
  593. bool is_script_doc = false;
  594. String script_path;
  595. bool operator<(const ClassDoc &p_class) const {
  596. return name < p_class.name;
  597. }
  598. static ClassDoc from_dict(const Dictionary &p_dict) {
  599. ClassDoc doc;
  600. if (p_dict.has("name")) {
  601. doc.name = p_dict["name"];
  602. }
  603. if (p_dict.has("inherits")) {
  604. doc.inherits = p_dict["inherits"];
  605. }
  606. if (p_dict.has("brief_description")) {
  607. doc.brief_description = p_dict["brief_description"];
  608. }
  609. if (p_dict.has("description")) {
  610. doc.description = p_dict["description"];
  611. }
  612. if (p_dict.has("keywords")) {
  613. doc.keywords = p_dict["keywords"];
  614. }
  615. Array tutorials;
  616. if (p_dict.has("tutorials")) {
  617. tutorials = p_dict["tutorials"];
  618. }
  619. for (int i = 0; i < tutorials.size(); i++) {
  620. doc.tutorials.push_back(TutorialDoc::from_dict(tutorials[i]));
  621. }
  622. Array constructors;
  623. if (p_dict.has("constructors")) {
  624. constructors = p_dict["constructors"];
  625. }
  626. for (int i = 0; i < constructors.size(); i++) {
  627. doc.constructors.push_back(MethodDoc::from_dict(constructors[i]));
  628. }
  629. Array methods;
  630. if (p_dict.has("methods")) {
  631. methods = p_dict["methods"];
  632. }
  633. for (int i = 0; i < methods.size(); i++) {
  634. doc.methods.push_back(MethodDoc::from_dict(methods[i]));
  635. }
  636. Array operators;
  637. if (p_dict.has("operators")) {
  638. operators = p_dict["operators"];
  639. }
  640. for (int i = 0; i < operators.size(); i++) {
  641. doc.operators.push_back(MethodDoc::from_dict(operators[i]));
  642. }
  643. Array signals;
  644. if (p_dict.has("signals")) {
  645. signals = p_dict["signals"];
  646. }
  647. for (int i = 0; i < signals.size(); i++) {
  648. doc.signals.push_back(MethodDoc::from_dict(signals[i]));
  649. }
  650. Array constants;
  651. if (p_dict.has("constants")) {
  652. constants = p_dict["constants"];
  653. }
  654. for (int i = 0; i < constants.size(); i++) {
  655. doc.constants.push_back(ConstantDoc::from_dict(constants[i]));
  656. }
  657. Dictionary enums;
  658. if (p_dict.has("enums")) {
  659. enums = p_dict["enums"];
  660. }
  661. for (int i = 0; i < enums.size(); i++) {
  662. doc.enums[enums.get_key_at_index(i)] = EnumDoc::from_dict(enums.get_value_at_index(i));
  663. }
  664. Array properties;
  665. if (p_dict.has("properties")) {
  666. properties = p_dict["properties"];
  667. }
  668. for (int i = 0; i < properties.size(); i++) {
  669. doc.properties.push_back(PropertyDoc::from_dict(properties[i]));
  670. }
  671. Array annotations;
  672. if (p_dict.has("annotations")) {
  673. annotations = p_dict["annotations"];
  674. }
  675. for (int i = 0; i < annotations.size(); i++) {
  676. doc.annotations.push_back(MethodDoc::from_dict(annotations[i]));
  677. }
  678. Array theme_properties;
  679. if (p_dict.has("theme_properties")) {
  680. theme_properties = p_dict["theme_properties"];
  681. }
  682. for (int i = 0; i < theme_properties.size(); i++) {
  683. doc.theme_properties.push_back(ThemeItemDoc::from_dict(theme_properties[i]));
  684. }
  685. #ifndef DISABLE_DEPRECATED
  686. if (p_dict.has("is_deprecated")) {
  687. doc.is_deprecated = p_dict["is_deprecated"];
  688. }
  689. if (p_dict.has("is_experimental")) {
  690. doc.is_experimental = p_dict["is_experimental"];
  691. }
  692. #endif
  693. if (p_dict.has("deprecated")) {
  694. doc.is_deprecated = true;
  695. doc.deprecated_message = p_dict["deprecated"];
  696. }
  697. if (p_dict.has("experimental")) {
  698. doc.is_experimental = true;
  699. doc.experimental_message = p_dict["experimental"];
  700. }
  701. if (p_dict.has("is_script_doc")) {
  702. doc.is_script_doc = p_dict["is_script_doc"];
  703. }
  704. if (p_dict.has("script_path")) {
  705. doc.script_path = p_dict["script_path"];
  706. }
  707. return doc;
  708. }
  709. static Dictionary to_dict(const ClassDoc &p_doc) {
  710. Dictionary dict;
  711. if (!p_doc.name.is_empty()) {
  712. dict["name"] = p_doc.name;
  713. }
  714. if (!p_doc.inherits.is_empty()) {
  715. dict["inherits"] = p_doc.inherits;
  716. }
  717. if (!p_doc.brief_description.is_empty()) {
  718. dict["brief_description"] = p_doc.brief_description;
  719. }
  720. if (!p_doc.description.is_empty()) {
  721. dict["description"] = p_doc.description;
  722. }
  723. if (!p_doc.tutorials.is_empty()) {
  724. Array tutorials;
  725. for (int i = 0; i < p_doc.tutorials.size(); i++) {
  726. tutorials.push_back(TutorialDoc::to_dict(p_doc.tutorials[i]));
  727. }
  728. dict["tutorials"] = tutorials;
  729. }
  730. if (!p_doc.constructors.is_empty()) {
  731. Array constructors;
  732. for (int i = 0; i < p_doc.constructors.size(); i++) {
  733. constructors.push_back(MethodDoc::to_dict(p_doc.constructors[i]));
  734. }
  735. dict["constructors"] = constructors;
  736. }
  737. if (!p_doc.methods.is_empty()) {
  738. Array methods;
  739. for (int i = 0; i < p_doc.methods.size(); i++) {
  740. methods.push_back(MethodDoc::to_dict(p_doc.methods[i]));
  741. }
  742. dict["methods"] = methods;
  743. }
  744. if (!p_doc.operators.is_empty()) {
  745. Array operators;
  746. for (int i = 0; i < p_doc.operators.size(); i++) {
  747. operators.push_back(MethodDoc::to_dict(p_doc.operators[i]));
  748. }
  749. dict["operators"] = operators;
  750. }
  751. if (!p_doc.signals.is_empty()) {
  752. Array signals;
  753. for (int i = 0; i < p_doc.signals.size(); i++) {
  754. signals.push_back(MethodDoc::to_dict(p_doc.signals[i]));
  755. }
  756. dict["signals"] = signals;
  757. }
  758. if (!p_doc.constants.is_empty()) {
  759. Array constants;
  760. for (int i = 0; i < p_doc.constants.size(); i++) {
  761. constants.push_back(ConstantDoc::to_dict(p_doc.constants[i]));
  762. }
  763. dict["constants"] = constants;
  764. }
  765. if (!p_doc.enums.is_empty()) {
  766. Dictionary enums;
  767. for (const KeyValue<String, EnumDoc> &E : p_doc.enums) {
  768. enums[E.key] = EnumDoc::to_dict(E.value);
  769. }
  770. dict["enums"] = enums;
  771. }
  772. if (!p_doc.properties.is_empty()) {
  773. Array properties;
  774. for (int i = 0; i < p_doc.properties.size(); i++) {
  775. properties.push_back(PropertyDoc::to_dict(p_doc.properties[i]));
  776. }
  777. dict["properties"] = properties;
  778. }
  779. if (!p_doc.annotations.is_empty()) {
  780. Array annotations;
  781. for (int i = 0; i < p_doc.annotations.size(); i++) {
  782. annotations.push_back(MethodDoc::to_dict(p_doc.annotations[i]));
  783. }
  784. dict["annotations"] = annotations;
  785. }
  786. if (!p_doc.theme_properties.is_empty()) {
  787. Array theme_properties;
  788. for (int i = 0; i < p_doc.theme_properties.size(); i++) {
  789. theme_properties.push_back(ThemeItemDoc::to_dict(p_doc.theme_properties[i]));
  790. }
  791. dict["theme_properties"] = theme_properties;
  792. }
  793. if (p_doc.is_deprecated) {
  794. dict["deprecated"] = p_doc.deprecated_message;
  795. }
  796. if (p_doc.is_experimental) {
  797. dict["experimental"] = p_doc.experimental_message;
  798. }
  799. dict["is_script_doc"] = p_doc.is_script_doc;
  800. if (!p_doc.script_path.is_empty()) {
  801. dict["script_path"] = p_doc.script_path;
  802. }
  803. if (!p_doc.keywords.is_empty()) {
  804. dict["keywords"] = p_doc.keywords;
  805. }
  806. return dict;
  807. }
  808. };
  809. static String get_default_value_string(const Variant &p_value);
  810. static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo);
  811. static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo);
  812. static void property_doc_from_scriptmemberinfo(DocData::PropertyDoc &p_property, const ScriptMemberInfo &p_memberinfo);
  813. static void method_doc_from_methodinfo(DocData::MethodDoc &p_method, const MethodInfo &p_methodinfo, const String &p_desc);
  814. static void constant_doc_from_variant(DocData::ConstantDoc &p_const, const StringName &p_name, const Variant &p_value, const String &p_desc);
  815. static void signal_doc_from_methodinfo(DocData::MethodDoc &p_signal, const MethodInfo &p_methodinfo, const String &p_desc);
  816. };
  817. #endif // DOC_DATA_H