doc_data.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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. bool is_experimental = false;
  102. Vector<ArgumentDoc> arguments;
  103. Vector<int> errors_returned;
  104. bool operator<(const MethodDoc &p_method) const {
  105. if (name == p_method.name) {
  106. // Must be an operator or a constructor since there is no other overloading
  107. if (name.left(8) == "operator") {
  108. if (arguments.size() == p_method.arguments.size()) {
  109. if (arguments.size() == 0) {
  110. return false;
  111. }
  112. return arguments[0].type < p_method.arguments[0].type;
  113. }
  114. return arguments.size() < p_method.arguments.size();
  115. } else {
  116. // Must be a constructor
  117. // We want this arbitrary order for a class "Foo":
  118. // - 1. Default constructor: Foo()
  119. // - 2. Copy constructor: Foo(Foo)
  120. // - 3+. Other constructors Foo(Bar, ...) based on first argument's name
  121. if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1.
  122. return arguments.size() < p_method.arguments.size();
  123. }
  124. if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2.
  125. return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type);
  126. }
  127. return arguments[0] < p_method.arguments[0];
  128. }
  129. }
  130. return name.naturalcasecmp_to(p_method.name) < 0;
  131. }
  132. static MethodDoc from_dict(const Dictionary &p_dict) {
  133. MethodDoc doc;
  134. if (p_dict.has("name")) {
  135. doc.name = p_dict["name"];
  136. }
  137. if (p_dict.has("return_type")) {
  138. doc.return_type = p_dict["return_type"];
  139. }
  140. if (p_dict.has("return_enum")) {
  141. doc.return_enum = p_dict["return_enum"];
  142. if (p_dict.has("return_is_bitfield")) {
  143. doc.return_is_bitfield = p_dict["return_is_bitfield"];
  144. }
  145. }
  146. if (p_dict.has("qualifiers")) {
  147. doc.qualifiers = p_dict["qualifiers"];
  148. }
  149. if (p_dict.has("description")) {
  150. doc.description = p_dict["description"];
  151. }
  152. if (p_dict.has("is_deprecated")) {
  153. doc.is_deprecated = p_dict["is_deprecated"];
  154. }
  155. if (p_dict.has("is_experimental")) {
  156. doc.is_experimental = p_dict["is_experimental"];
  157. }
  158. Array arguments;
  159. if (p_dict.has("arguments")) {
  160. arguments = p_dict["arguments"];
  161. }
  162. for (int i = 0; i < arguments.size(); i++) {
  163. doc.arguments.push_back(ArgumentDoc::from_dict(arguments[i]));
  164. }
  165. Array errors_returned;
  166. if (p_dict.has("errors_returned")) {
  167. errors_returned = p_dict["errors_returned"];
  168. }
  169. for (int i = 0; i < errors_returned.size(); i++) {
  170. doc.errors_returned.push_back(errors_returned[i]);
  171. }
  172. return doc;
  173. }
  174. static Dictionary to_dict(const MethodDoc &p_doc) {
  175. Dictionary dict;
  176. if (!p_doc.name.is_empty()) {
  177. dict["name"] = p_doc.name;
  178. }
  179. if (!p_doc.return_type.is_empty()) {
  180. dict["return_type"] = p_doc.return_type;
  181. }
  182. if (!p_doc.return_enum.is_empty()) {
  183. dict["return_enum"] = p_doc.return_enum;
  184. dict["return_is_bitfield"] = p_doc.return_is_bitfield;
  185. }
  186. if (!p_doc.qualifiers.is_empty()) {
  187. dict["qualifiers"] = p_doc.qualifiers;
  188. }
  189. if (!p_doc.description.is_empty()) {
  190. dict["description"] = p_doc.description;
  191. }
  192. dict["is_deprecated"] = p_doc.is_deprecated;
  193. dict["is_experimental"] = p_doc.is_experimental;
  194. if (!p_doc.arguments.is_empty()) {
  195. Array arguments;
  196. for (int i = 0; i < p_doc.arguments.size(); i++) {
  197. arguments.push_back(ArgumentDoc::to_dict(p_doc.arguments[i]));
  198. }
  199. dict["arguments"] = arguments;
  200. }
  201. if (!p_doc.errors_returned.is_empty()) {
  202. Array errors_returned;
  203. for (int i = 0; i < p_doc.errors_returned.size(); i++) {
  204. errors_returned.push_back(p_doc.errors_returned[i]);
  205. }
  206. dict["errors_returned"] = errors_returned;
  207. }
  208. return dict;
  209. }
  210. };
  211. struct ConstantDoc {
  212. String name;
  213. String value;
  214. bool is_value_valid = false;
  215. String enumeration;
  216. bool is_bitfield = false;
  217. String description;
  218. bool is_deprecated = false;
  219. bool is_experimental = false;
  220. bool operator<(const ConstantDoc &p_const) const {
  221. return name < p_const.name;
  222. }
  223. static ConstantDoc from_dict(const Dictionary &p_dict) {
  224. ConstantDoc doc;
  225. if (p_dict.has("name")) {
  226. doc.name = p_dict["name"];
  227. }
  228. if (p_dict.has("value")) {
  229. doc.value = p_dict["value"];
  230. }
  231. if (p_dict.has("is_value_valid")) {
  232. doc.is_value_valid = p_dict["is_value_valid"];
  233. }
  234. if (p_dict.has("enumeration")) {
  235. doc.enumeration = p_dict["enumeration"];
  236. if (p_dict.has("is_bitfield")) {
  237. doc.is_bitfield = p_dict["is_bitfield"];
  238. }
  239. }
  240. if (p_dict.has("description")) {
  241. doc.description = p_dict["description"];
  242. }
  243. if (p_dict.has("is_deprecated")) {
  244. doc.is_deprecated = p_dict["is_deprecated"];
  245. }
  246. if (p_dict.has("is_experimental")) {
  247. doc.is_experimental = p_dict["is_experimental"];
  248. }
  249. return doc;
  250. }
  251. static Dictionary to_dict(const ConstantDoc &p_doc) {
  252. Dictionary dict;
  253. if (!p_doc.name.is_empty()) {
  254. dict["name"] = p_doc.name;
  255. }
  256. if (!p_doc.value.is_empty()) {
  257. dict["value"] = p_doc.value;
  258. }
  259. dict["is_value_valid"] = p_doc.is_value_valid;
  260. if (!p_doc.enumeration.is_empty()) {
  261. dict["enumeration"] = p_doc.enumeration;
  262. dict["is_bitfield"] = p_doc.is_bitfield;
  263. }
  264. if (!p_doc.description.is_empty()) {
  265. dict["description"] = p_doc.description;
  266. }
  267. dict["is_deprecated"] = p_doc.is_deprecated;
  268. dict["is_experimental"] = p_doc.is_experimental;
  269. return dict;
  270. }
  271. };
  272. struct PropertyDoc {
  273. String name;
  274. String type;
  275. String enumeration;
  276. bool is_bitfield = false;
  277. String description;
  278. String setter, getter;
  279. String default_value;
  280. bool overridden = false;
  281. String overrides;
  282. bool is_deprecated = false;
  283. bool is_experimental = false;
  284. bool operator<(const PropertyDoc &p_prop) const {
  285. return name.naturalcasecmp_to(p_prop.name) < 0;
  286. }
  287. static PropertyDoc from_dict(const Dictionary &p_dict) {
  288. PropertyDoc doc;
  289. if (p_dict.has("name")) {
  290. doc.name = p_dict["name"];
  291. }
  292. if (p_dict.has("type")) {
  293. doc.type = p_dict["type"];
  294. }
  295. if (p_dict.has("enumeration")) {
  296. doc.enumeration = p_dict["enumeration"];
  297. if (p_dict.has("is_bitfield")) {
  298. doc.is_bitfield = p_dict["is_bitfield"];
  299. }
  300. }
  301. if (p_dict.has("description")) {
  302. doc.description = p_dict["description"];
  303. }
  304. if (p_dict.has("setter")) {
  305. doc.setter = p_dict["setter"];
  306. }
  307. if (p_dict.has("getter")) {
  308. doc.getter = p_dict["getter"];
  309. }
  310. if (p_dict.has("default_value")) {
  311. doc.default_value = p_dict["default_value"];
  312. }
  313. if (p_dict.has("overridden")) {
  314. doc.overridden = p_dict["overridden"];
  315. }
  316. if (p_dict.has("overrides")) {
  317. doc.overrides = p_dict["overrides"];
  318. }
  319. if (p_dict.has("is_deprecated")) {
  320. doc.is_deprecated = p_dict["is_deprecated"];
  321. }
  322. if (p_dict.has("is_experimental")) {
  323. doc.is_experimental = p_dict["is_experimental"];
  324. }
  325. return doc;
  326. }
  327. static Dictionary to_dict(const PropertyDoc &p_doc) {
  328. Dictionary dict;
  329. if (!p_doc.name.is_empty()) {
  330. dict["name"] = p_doc.name;
  331. }
  332. if (!p_doc.type.is_empty()) {
  333. dict["type"] = p_doc.type;
  334. }
  335. if (!p_doc.enumeration.is_empty()) {
  336. dict["enumeration"] = p_doc.enumeration;
  337. dict["is_bitfield"] = p_doc.is_bitfield;
  338. }
  339. if (!p_doc.description.is_empty()) {
  340. dict["description"] = p_doc.description;
  341. }
  342. if (!p_doc.setter.is_empty()) {
  343. dict["setter"] = p_doc.setter;
  344. }
  345. if (!p_doc.getter.is_empty()) {
  346. dict["getter"] = p_doc.getter;
  347. }
  348. if (!p_doc.default_value.is_empty()) {
  349. dict["default_value"] = p_doc.default_value;
  350. }
  351. dict["overridden"] = p_doc.overridden;
  352. if (!p_doc.overrides.is_empty()) {
  353. dict["overrides"] = p_doc.overrides;
  354. }
  355. dict["is_deprecated"] = p_doc.is_deprecated;
  356. dict["is_experimental"] = p_doc.is_experimental;
  357. return dict;
  358. }
  359. };
  360. struct ThemeItemDoc {
  361. String name;
  362. String type;
  363. String data_type;
  364. String description;
  365. String default_value;
  366. bool operator<(const ThemeItemDoc &p_theme_item) const {
  367. // First sort by the data type, then by name.
  368. if (data_type == p_theme_item.data_type) {
  369. return name.naturalcasecmp_to(p_theme_item.name) < 0;
  370. }
  371. return data_type < p_theme_item.data_type;
  372. }
  373. static ThemeItemDoc from_dict(const Dictionary &p_dict) {
  374. ThemeItemDoc doc;
  375. if (p_dict.has("name")) {
  376. doc.name = p_dict["name"];
  377. }
  378. if (p_dict.has("type")) {
  379. doc.type = p_dict["type"];
  380. }
  381. if (p_dict.has("data_type")) {
  382. doc.data_type = p_dict["data_type"];
  383. }
  384. if (p_dict.has("description")) {
  385. doc.description = p_dict["description"];
  386. }
  387. if (p_dict.has("default_value")) {
  388. doc.default_value = p_dict["default_value"];
  389. }
  390. return doc;
  391. }
  392. static Dictionary to_dict(const ThemeItemDoc &p_doc) {
  393. Dictionary dict;
  394. if (!p_doc.name.is_empty()) {
  395. dict["name"] = p_doc.name;
  396. }
  397. if (!p_doc.type.is_empty()) {
  398. dict["type"] = p_doc.type;
  399. }
  400. if (!p_doc.data_type.is_empty()) {
  401. dict["data_type"] = p_doc.data_type;
  402. }
  403. if (!p_doc.description.is_empty()) {
  404. dict["description"] = p_doc.description;
  405. }
  406. if (!p_doc.default_value.is_empty()) {
  407. dict["default_value"] = p_doc.default_value;
  408. }
  409. return dict;
  410. }
  411. };
  412. struct TutorialDoc {
  413. String link;
  414. String title;
  415. static TutorialDoc from_dict(const Dictionary &p_dict) {
  416. TutorialDoc doc;
  417. if (p_dict.has("link")) {
  418. doc.link = p_dict["link"];
  419. }
  420. if (p_dict.has("title")) {
  421. doc.title = p_dict["title"];
  422. }
  423. return doc;
  424. }
  425. static Dictionary to_dict(const TutorialDoc &p_doc) {
  426. Dictionary dict;
  427. if (!p_doc.link.is_empty()) {
  428. dict["link"] = p_doc.link;
  429. }
  430. if (!p_doc.title.is_empty()) {
  431. dict["title"] = p_doc.title;
  432. }
  433. return dict;
  434. }
  435. };
  436. struct ClassDoc {
  437. String name;
  438. String inherits;
  439. String brief_description;
  440. String description;
  441. Vector<TutorialDoc> tutorials;
  442. Vector<MethodDoc> constructors;
  443. Vector<MethodDoc> methods;
  444. Vector<MethodDoc> operators;
  445. Vector<MethodDoc> signals;
  446. Vector<ConstantDoc> constants;
  447. HashMap<String, String> enums;
  448. Vector<PropertyDoc> properties;
  449. Vector<MethodDoc> annotations;
  450. Vector<ThemeItemDoc> theme_properties;
  451. bool is_deprecated = false;
  452. bool is_experimental = false;
  453. bool is_script_doc = false;
  454. String script_path;
  455. bool operator<(const ClassDoc &p_class) const {
  456. return name < p_class.name;
  457. }
  458. static ClassDoc from_dict(const Dictionary &p_dict) {
  459. ClassDoc doc;
  460. if (p_dict.has("name")) {
  461. doc.name = p_dict["name"];
  462. }
  463. if (p_dict.has("inherits")) {
  464. doc.inherits = p_dict["inherits"];
  465. }
  466. if (p_dict.has("brief_description")) {
  467. doc.brief_description = p_dict["brief_description"];
  468. }
  469. if (p_dict.has("description")) {
  470. doc.description = p_dict["description"];
  471. }
  472. Array tutorials;
  473. if (p_dict.has("tutorials")) {
  474. tutorials = p_dict["tutorials"];
  475. }
  476. for (int i = 0; i < tutorials.size(); i++) {
  477. doc.tutorials.push_back(TutorialDoc::from_dict(tutorials[i]));
  478. }
  479. Array constructors;
  480. if (p_dict.has("constructors")) {
  481. constructors = p_dict["constructors"];
  482. }
  483. for (int i = 0; i < constructors.size(); i++) {
  484. doc.constructors.push_back(MethodDoc::from_dict(constructors[i]));
  485. }
  486. Array methods;
  487. if (p_dict.has("methods")) {
  488. methods = p_dict["methods"];
  489. }
  490. for (int i = 0; i < methods.size(); i++) {
  491. doc.methods.push_back(MethodDoc::from_dict(methods[i]));
  492. }
  493. Array operators;
  494. if (p_dict.has("operators")) {
  495. operators = p_dict["operators"];
  496. }
  497. for (int i = 0; i < operators.size(); i++) {
  498. doc.operators.push_back(MethodDoc::from_dict(operators[i]));
  499. }
  500. Array signals;
  501. if (p_dict.has("signals")) {
  502. signals = p_dict["signals"];
  503. }
  504. for (int i = 0; i < signals.size(); i++) {
  505. doc.signals.push_back(MethodDoc::from_dict(signals[i]));
  506. }
  507. Array constants;
  508. if (p_dict.has("constants")) {
  509. constants = p_dict["constants"];
  510. }
  511. for (int i = 0; i < constants.size(); i++) {
  512. doc.constants.push_back(ConstantDoc::from_dict(constants[i]));
  513. }
  514. Dictionary enums;
  515. if (p_dict.has("enums")) {
  516. enums = p_dict["enums"];
  517. }
  518. for (int i = 0; i < enums.size(); i++) {
  519. doc.enums[enums.get_key_at_index(i)] = enums.get_value_at_index(i);
  520. }
  521. Array properties;
  522. if (p_dict.has("properties")) {
  523. properties = p_dict["properties"];
  524. }
  525. for (int i = 0; i < properties.size(); i++) {
  526. doc.properties.push_back(PropertyDoc::from_dict(properties[i]));
  527. }
  528. Array annotations;
  529. if (p_dict.has("annotations")) {
  530. annotations = p_dict["annotations"];
  531. }
  532. for (int i = 0; i < annotations.size(); i++) {
  533. doc.annotations.push_back(MethodDoc::from_dict(annotations[i]));
  534. }
  535. Array theme_properties;
  536. if (p_dict.has("theme_properties")) {
  537. theme_properties = p_dict["theme_properties"];
  538. }
  539. for (int i = 0; i < theme_properties.size(); i++) {
  540. doc.theme_properties.push_back(ThemeItemDoc::from_dict(theme_properties[i]));
  541. }
  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. if (p_dict.has("is_script_doc")) {
  549. doc.is_script_doc = p_dict["is_script_doc"];
  550. }
  551. if (p_dict.has("script_path")) {
  552. doc.script_path = p_dict["script_path"];
  553. }
  554. return doc;
  555. }
  556. static Dictionary to_dict(const ClassDoc &p_doc) {
  557. Dictionary dict;
  558. if (!p_doc.name.is_empty()) {
  559. dict["name"] = p_doc.name;
  560. }
  561. if (!p_doc.inherits.is_empty()) {
  562. dict["inherits"] = p_doc.inherits;
  563. }
  564. if (!p_doc.brief_description.is_empty()) {
  565. dict["brief_description"] = p_doc.brief_description;
  566. }
  567. if (!p_doc.description.is_empty()) {
  568. dict["description"] = p_doc.description;
  569. }
  570. if (!p_doc.tutorials.is_empty()) {
  571. Array tutorials;
  572. for (int i = 0; i < p_doc.tutorials.size(); i++) {
  573. tutorials.push_back(TutorialDoc::to_dict(p_doc.tutorials[i]));
  574. }
  575. dict["tutorials"] = tutorials;
  576. }
  577. if (!p_doc.constructors.is_empty()) {
  578. Array constructors;
  579. for (int i = 0; i < p_doc.constructors.size(); i++) {
  580. constructors.push_back(MethodDoc::to_dict(p_doc.constructors[i]));
  581. }
  582. dict["constructors"] = constructors;
  583. }
  584. if (!p_doc.methods.is_empty()) {
  585. Array methods;
  586. for (int i = 0; i < p_doc.methods.size(); i++) {
  587. methods.push_back(MethodDoc::to_dict(p_doc.methods[i]));
  588. }
  589. dict["methods"] = methods;
  590. }
  591. if (!p_doc.operators.is_empty()) {
  592. Array operators;
  593. for (int i = 0; i < p_doc.operators.size(); i++) {
  594. operators.push_back(MethodDoc::to_dict(p_doc.operators[i]));
  595. }
  596. dict["operators"] = operators;
  597. }
  598. if (!p_doc.signals.is_empty()) {
  599. Array signals;
  600. for (int i = 0; i < p_doc.signals.size(); i++) {
  601. signals.push_back(MethodDoc::to_dict(p_doc.signals[i]));
  602. }
  603. dict["signals"] = signals;
  604. }
  605. if (!p_doc.constants.is_empty()) {
  606. Array constants;
  607. for (int i = 0; i < p_doc.constants.size(); i++) {
  608. constants.push_back(ConstantDoc::to_dict(p_doc.constants[i]));
  609. }
  610. dict["constants"] = constants;
  611. }
  612. if (!p_doc.enums.is_empty()) {
  613. Dictionary enums;
  614. for (const KeyValue<String, String> &E : p_doc.enums) {
  615. enums[E.key] = E.value;
  616. }
  617. dict["enums"] = enums;
  618. }
  619. if (!p_doc.properties.is_empty()) {
  620. Array properties;
  621. for (int i = 0; i < p_doc.properties.size(); i++) {
  622. properties.push_back(PropertyDoc::to_dict(p_doc.properties[i]));
  623. }
  624. dict["properties"] = properties;
  625. }
  626. if (!p_doc.annotations.is_empty()) {
  627. Array annotations;
  628. for (int i = 0; i < p_doc.annotations.size(); i++) {
  629. annotations.push_back(MethodDoc::to_dict(p_doc.annotations[i]));
  630. }
  631. dict["annotations"] = annotations;
  632. }
  633. if (!p_doc.theme_properties.is_empty()) {
  634. Array theme_properties;
  635. for (int i = 0; i < p_doc.theme_properties.size(); i++) {
  636. theme_properties.push_back(ThemeItemDoc::to_dict(p_doc.theme_properties[i]));
  637. }
  638. dict["theme_properties"] = theme_properties;
  639. }
  640. dict["is_deprecated"] = p_doc.is_deprecated;
  641. dict["is_experimental"] = p_doc.is_experimental;
  642. dict["is_script_doc"] = p_doc.is_script_doc;
  643. if (!p_doc.script_path.is_empty()) {
  644. dict["script_path"] = p_doc.script_path;
  645. }
  646. return dict;
  647. }
  648. };
  649. static String get_default_value_string(const Variant &p_value);
  650. static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo);
  651. static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo);
  652. static void property_doc_from_scriptmemberinfo(DocData::PropertyDoc &p_property, const ScriptMemberInfo &p_memberinfo);
  653. static void method_doc_from_methodinfo(DocData::MethodDoc &p_method, const MethodInfo &p_methodinfo, const String &p_desc);
  654. static void constant_doc_from_variant(DocData::ConstantDoc &p_const, const StringName &p_name, const Variant &p_value, const String &p_desc);
  655. static void signal_doc_from_methodinfo(DocData::MethodDoc &p_signal, const MethodInfo &p_methodinfo, const String &p_desc);
  656. };
  657. #endif // DOC_DATA_H