aas-core-codegen 0.0.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (604) hide show
  1. aas_core_codegen/__init__.py +6 -0
  2. aas_core_codegen/__main__.py +8 -0
  3. aas_core_codegen/common.py +500 -0
  4. aas_core_codegen/cpp/__init__.py +1 -0
  5. aas_core_codegen/cpp/aas_common/__init__.py +6 -0
  6. aas_core_codegen/cpp/aas_common/_generate.py +713 -0
  7. aas_core_codegen/cpp/common.py +681 -0
  8. aas_core_codegen/cpp/constants/__init__.py +6 -0
  9. aas_core_codegen/cpp/constants/_generate.py +568 -0
  10. aas_core_codegen/cpp/description.py +654 -0
  11. aas_core_codegen/cpp/enhancing/__init__.py +4 -0
  12. aas_core_codegen/cpp/enhancing/_generate.py +993 -0
  13. aas_core_codegen/cpp/iteration/__init__.py +6 -0
  14. aas_core_codegen/cpp/iteration/_generate.py +2332 -0
  15. aas_core_codegen/cpp/jsonization/__init__.py +6 -0
  16. aas_core_codegen/cpp/jsonization/_generate.py +2619 -0
  17. aas_core_codegen/cpp/main.py +694 -0
  18. aas_core_codegen/cpp/naming.py +170 -0
  19. aas_core_codegen/cpp/optionaling.py +557 -0
  20. aas_core_codegen/cpp/pattern/__init__.py +6 -0
  21. aas_core_codegen/cpp/pattern/_generate.py +508 -0
  22. aas_core_codegen/cpp/revm/__init__.py +6 -0
  23. aas_core_codegen/cpp/revm/_generate.py +1149 -0
  24. aas_core_codegen/cpp/stringification/__init__.py +5 -0
  25. aas_core_codegen/cpp/stringification/_generate.py +955 -0
  26. aas_core_codegen/cpp/structure/__init__.py +7 -0
  27. aas_core_codegen/cpp/structure/_generate.py +1503 -0
  28. aas_core_codegen/cpp/transpilation.py +1383 -0
  29. aas_core_codegen/cpp/unrolling.py +159 -0
  30. aas_core_codegen/cpp/verification/__init__.py +6 -0
  31. aas_core_codegen/cpp/verification/_generate.py +3073 -0
  32. aas_core_codegen/cpp/visitation/__init__.py +6 -0
  33. aas_core_codegen/cpp/visitation/_generate.py +521 -0
  34. aas_core_codegen/cpp/wstringification/__init__.py +5 -0
  35. aas_core_codegen/cpp/wstringification/_generate.py +586 -0
  36. aas_core_codegen/cpp/xmlization/__init__.py +6 -0
  37. aas_core_codegen/cpp/xmlization/_generate.py +5373 -0
  38. aas_core_codegen/cpp/yielding.py +201 -0
  39. aas_core_codegen/csharp/__init__.py +1 -0
  40. aas_core_codegen/csharp/common.py +224 -0
  41. aas_core_codegen/csharp/constants/__init__.py +5 -0
  42. aas_core_codegen/csharp/constants/_generate.py +409 -0
  43. aas_core_codegen/csharp/copying/__init__.py +4 -0
  44. aas_core_codegen/csharp/copying/_generate.py +498 -0
  45. aas_core_codegen/csharp/description.py +1103 -0
  46. aas_core_codegen/csharp/enhancing/__init__.py +4 -0
  47. aas_core_codegen/csharp/enhancing/_generate.py +667 -0
  48. aas_core_codegen/csharp/jsonization/__init__.py +4 -0
  49. aas_core_codegen/csharp/jsonization/_generate.py +1630 -0
  50. aas_core_codegen/csharp/main.py +421 -0
  51. aas_core_codegen/csharp/naming.py +157 -0
  52. aas_core_codegen/csharp/reporting/__init__.py +4 -0
  53. aas_core_codegen/csharp/reporting/_generate.py +266 -0
  54. aas_core_codegen/csharp/stringification/__init__.py +4 -0
  55. aas_core_codegen/csharp/stringification/_generate.py +243 -0
  56. aas_core_codegen/csharp/structure/__init__.py +6 -0
  57. aas_core_codegen/csharp/structure/_generate.py +1341 -0
  58. aas_core_codegen/csharp/transpilation.py +990 -0
  59. aas_core_codegen/csharp/unrolling.py +211 -0
  60. aas_core_codegen/csharp/verification/__init__.py +6 -0
  61. aas_core_codegen/csharp/verification/_generate.py +1457 -0
  62. aas_core_codegen/csharp/visitation/__init__.py +5 -0
  63. aas_core_codegen/csharp/visitation/_generate.py +579 -0
  64. aas_core_codegen/csharp/xmlization/__init__.py +4 -0
  65. aas_core_codegen/csharp/xmlization/_generate.py +1980 -0
  66. aas_core_codegen/golang/__init__.py +1 -0
  67. aas_core_codegen/golang/aas_common/__init__.py +4 -0
  68. aas_core_codegen/golang/aas_common/_generate.py +152 -0
  69. aas_core_codegen/golang/common.py +303 -0
  70. aas_core_codegen/golang/constants/__init__.py +5 -0
  71. aas_core_codegen/golang/constants/_generate.py +339 -0
  72. aas_core_codegen/golang/description.py +501 -0
  73. aas_core_codegen/golang/enhancing/__init__.py +4 -0
  74. aas_core_codegen/golang/enhancing/_generate.py +527 -0
  75. aas_core_codegen/golang/jsonization/__init__.py +4 -0
  76. aas_core_codegen/golang/jsonization/_generate.py +1740 -0
  77. aas_core_codegen/golang/main.py +368 -0
  78. aas_core_codegen/golang/naming.py +412 -0
  79. aas_core_codegen/golang/pointering.py +631 -0
  80. aas_core_codegen/golang/reporting/__init__.py +4 -0
  81. aas_core_codegen/golang/reporting/_generate.py +218 -0
  82. aas_core_codegen/golang/stringification/__init__.py +4 -0
  83. aas_core_codegen/golang/stringification/_generate.py +394 -0
  84. aas_core_codegen/golang/structure/__init__.py +6 -0
  85. aas_core_codegen/golang/structure/_generate.py +1493 -0
  86. aas_core_codegen/golang/transpilation.py +1191 -0
  87. aas_core_codegen/golang/unrolling.py +159 -0
  88. aas_core_codegen/golang/verification/__init__.py +6 -0
  89. aas_core_codegen/golang/verification/_generate.py +1513 -0
  90. aas_core_codegen/golang/xmlization/__init__.py +4 -0
  91. aas_core_codegen/golang/xmlization/_generate.py +2507 -0
  92. aas_core_codegen/infer_for_schema/__init__.py +21 -0
  93. aas_core_codegen/infer_for_schema/_inline.py +693 -0
  94. aas_core_codegen/infer_for_schema/_len.py +527 -0
  95. aas_core_codegen/infer_for_schema/_pattern.py +311 -0
  96. aas_core_codegen/infer_for_schema/_set.py +394 -0
  97. aas_core_codegen/infer_for_schema/_stringify.py +201 -0
  98. aas_core_codegen/infer_for_schema/_types.py +135 -0
  99. aas_core_codegen/infer_for_schema/match.py +122 -0
  100. aas_core_codegen/intermediate/__init__.py +78 -0
  101. aas_core_codegen/intermediate/_hierarchy.py +397 -0
  102. aas_core_codegen/intermediate/_stringify.py +989 -0
  103. aas_core_codegen/intermediate/_translate.py +5128 -0
  104. aas_core_codegen/intermediate/_types.py +2901 -0
  105. aas_core_codegen/intermediate/construction.py +750 -0
  106. aas_core_codegen/intermediate/doc.py +344 -0
  107. aas_core_codegen/intermediate/pattern_verification.py +428 -0
  108. aas_core_codegen/intermediate/revm.py +985 -0
  109. aas_core_codegen/intermediate/type_inference.py +2266 -0
  110. aas_core_codegen/java/__init__.py +1 -0
  111. aas_core_codegen/java/common.py +197 -0
  112. aas_core_codegen/java/constants/__init__.py +5 -0
  113. aas_core_codegen/java/constants/_generate.py +334 -0
  114. aas_core_codegen/java/copying/__init__.py +4 -0
  115. aas_core_codegen/java/copying/_generate.py +502 -0
  116. aas_core_codegen/java/description.py +774 -0
  117. aas_core_codegen/java/enhancing/__init__.py +4 -0
  118. aas_core_codegen/java/enhancing/_generate.py +820 -0
  119. aas_core_codegen/java/generation/__init__.py +5 -0
  120. aas_core_codegen/java/generation/_generate.py +285 -0
  121. aas_core_codegen/java/jsonization/__init__.py +4 -0
  122. aas_core_codegen/java/jsonization/_generate.py +1472 -0
  123. aas_core_codegen/java/main.py +438 -0
  124. aas_core_codegen/java/naming.py +187 -0
  125. aas_core_codegen/java/optional.py +514 -0
  126. aas_core_codegen/java/reporting/__init__.py +4 -0
  127. aas_core_codegen/java/reporting/_generate.py +248 -0
  128. aas_core_codegen/java/stringification/__init__.py +4 -0
  129. aas_core_codegen/java/stringification/_generate.py +212 -0
  130. aas_core_codegen/java/structure/__init__.py +6 -0
  131. aas_core_codegen/java/structure/_generate.py +1767 -0
  132. aas_core_codegen/java/transpilation.py +1111 -0
  133. aas_core_codegen/java/verification/__init__.py +6 -0
  134. aas_core_codegen/java/verification/_generate.py +1536 -0
  135. aas_core_codegen/java/visitation/__init__.py +5 -0
  136. aas_core_codegen/java/visitation/_generate.py +689 -0
  137. aas_core_codegen/java/xmlization/__init__.py +4 -0
  138. aas_core_codegen/java/xmlization/_generate.py +2274 -0
  139. aas_core_codegen/jsonld/__init__.py +1 -0
  140. aas_core_codegen/jsonld/main.py +455 -0
  141. aas_core_codegen/jsonschema/__init__.py +1 -0
  142. aas_core_codegen/jsonschema/main.py +982 -0
  143. aas_core_codegen/main.py +245 -0
  144. aas_core_codegen/naming.py +133 -0
  145. aas_core_codegen/opcua/__init__.py +1 -0
  146. aas_core_codegen/opcua/main.py +1525 -0
  147. aas_core_codegen/opcua/naming.py +126 -0
  148. aas_core_codegen/parse/__init__.py +46 -0
  149. aas_core_codegen/parse/_rules.py +796 -0
  150. aas_core_codegen/parse/_stringify.py +532 -0
  151. aas_core_codegen/parse/_translate.py +3940 -0
  152. aas_core_codegen/parse/_types.py +973 -0
  153. aas_core_codegen/parse/retree/__init__.py +46 -0
  154. aas_core_codegen/parse/retree/_fix.py +434 -0
  155. aas_core_codegen/parse/retree/_parse.py +1143 -0
  156. aas_core_codegen/parse/retree/_render.py +298 -0
  157. aas_core_codegen/parse/retree/_stringify.py +199 -0
  158. aas_core_codegen/parse/retree/_types.py +362 -0
  159. aas_core_codegen/parse/retree/_visitor.py +70 -0
  160. aas_core_codegen/parse/tree.py +1303 -0
  161. aas_core_codegen/protobuf/__init__.py +1 -0
  162. aas_core_codegen/protobuf/common.py +225 -0
  163. aas_core_codegen/protobuf/description.py +1102 -0
  164. aas_core_codegen/protobuf/main.py +115 -0
  165. aas_core_codegen/protobuf/naming.py +143 -0
  166. aas_core_codegen/protobuf/structure/__init__.py +6 -0
  167. aas_core_codegen/protobuf/structure/_generate.py +502 -0
  168. aas_core_codegen/py.typed +1 -0
  169. aas_core_codegen/python/__init__.py +1 -0
  170. aas_core_codegen/python/aas_common/__init__.py +4 -0
  171. aas_core_codegen/python/aas_common/_generate.py +63 -0
  172. aas_core_codegen/python/common.py +406 -0
  173. aas_core_codegen/python/constants/__init__.py +5 -0
  174. aas_core_codegen/python/constants/_generate.py +377 -0
  175. aas_core_codegen/python/description.py +508 -0
  176. aas_core_codegen/python/jsonization/__init__.py +4 -0
  177. aas_core_codegen/python/jsonization/_generate.py +1391 -0
  178. aas_core_codegen/python/main.py +323 -0
  179. aas_core_codegen/python/naming.py +255 -0
  180. aas_core_codegen/python/stringification/__init__.py +4 -0
  181. aas_core_codegen/python/stringification/_generate.py +129 -0
  182. aas_core_codegen/python/structure/__init__.py +6 -0
  183. aas_core_codegen/python/structure/_generate.py +1801 -0
  184. aas_core_codegen/python/transpilation.py +958 -0
  185. aas_core_codegen/python/unrolling.py +156 -0
  186. aas_core_codegen/python/verification/__init__.py +6 -0
  187. aas_core_codegen/python/verification/_generate.py +1471 -0
  188. aas_core_codegen/python/xmlization/__init__.py +4 -0
  189. aas_core_codegen/python/xmlization/_generate.py +3003 -0
  190. aas_core_codegen/python_protobuf/__init__.py +1 -0
  191. aas_core_codegen/python_protobuf/main.py +1424 -0
  192. aas_core_codegen/python_protobuf/naming.py +85 -0
  193. aas_core_codegen/rdf_shacl/__init__.py +1 -0
  194. aas_core_codegen/rdf_shacl/_description.py +351 -0
  195. aas_core_codegen/rdf_shacl/common.py +206 -0
  196. aas_core_codegen/rdf_shacl/main.py +114 -0
  197. aas_core_codegen/rdf_shacl/naming.py +145 -0
  198. aas_core_codegen/rdf_shacl/rdf.py +435 -0
  199. aas_core_codegen/rdf_shacl/shacl.py +453 -0
  200. aas_core_codegen/run.py +124 -0
  201. aas_core_codegen/smoke/__init__.py +1 -0
  202. aas_core_codegen/smoke/main.py +219 -0
  203. aas_core_codegen/specific_implementations.py +72 -0
  204. aas_core_codegen/stringify.py +333 -0
  205. aas_core_codegen/typescript/__init__.py +1 -0
  206. aas_core_codegen/typescript/aas_common/__init__.py +4 -0
  207. aas_core_codegen/typescript/aas_common/_generate.py +472 -0
  208. aas_core_codegen/typescript/common.py +340 -0
  209. aas_core_codegen/typescript/constants/__init__.py +5 -0
  210. aas_core_codegen/typescript/constants/_generate.py +347 -0
  211. aas_core_codegen/typescript/description.py +530 -0
  212. aas_core_codegen/typescript/jsonization/__init__.py +4 -0
  213. aas_core_codegen/typescript/jsonization/_generate.py +1510 -0
  214. aas_core_codegen/typescript/main.py +258 -0
  215. aas_core_codegen/typescript/naming.py +189 -0
  216. aas_core_codegen/typescript/stringification/__init__.py +4 -0
  217. aas_core_codegen/typescript/stringification/_generate.py +367 -0
  218. aas_core_codegen/typescript/structure/__init__.py +6 -0
  219. aas_core_codegen/typescript/structure/_generate.py +2500 -0
  220. aas_core_codegen/typescript/transpilation.py +1051 -0
  221. aas_core_codegen/typescript/unrolling.py +159 -0
  222. aas_core_codegen/typescript/verification/__init__.py +6 -0
  223. aas_core_codegen/typescript/verification/_generate.py +1578 -0
  224. aas_core_codegen/xsd/__init__.py +1 -0
  225. aas_core_codegen/xsd/main.py +1187 -0
  226. aas_core_codegen/xsd/naming.py +83 -0
  227. aas_core_codegen/yielding/__init__.py +1 -0
  228. aas_core_codegen/yielding/flow.py +139 -0
  229. aas_core_codegen/yielding/linear.py +754 -0
  230. aas_core_codegen-0.0.16.dist-info/METADATA +211 -0
  231. aas_core_codegen-0.0.16.dist-info/RECORD +604 -0
  232. aas_core_codegen-0.0.16.dist-info/WHEEL +5 -0
  233. aas_core_codegen-0.0.16.dist-info/entry_points.txt +3 -0
  234. aas_core_codegen-0.0.16.dist-info/licenses/AUTHORS +9 -0
  235. aas_core_codegen-0.0.16.dist-info/licenses/LICENSE +23 -0
  236. aas_core_codegen-0.0.16.dist-info/top_level.txt +2 -0
  237. dev/continuous_integration/__init__.py +1 -0
  238. dev/continuous_integration/check_help_in_readme.py +208 -0
  239. dev/continuous_integration/check_init_and_pyproject_consistent.py +154 -0
  240. dev/continuous_integration/precommit.py +400 -0
  241. dev/dev_scripts/__init__.py +1 -0
  242. dev/dev_scripts/compare_rendered_regexes_against_source_py.py +42 -0
  243. dev/dev_scripts/copy_to_aas_core3_cpp.py +100 -0
  244. dev/dev_scripts/copy_to_aas_core3_java.py +90 -0
  245. dev/dev_scripts/download_latest_aas_core_meta_v3.py +114 -0
  246. dev/dev_scripts/draw_bipartite_graph_based_on_lines.py +37 -0
  247. dev/dev_scripts/run_tests_with_rerecord.py +69 -0
  248. dev/dev_scripts/update_to_aas_core_meta.py +174 -0
  249. dev/integration_tests/input/jsonschema/boilerplate/main.py +55 -0
  250. dev/integration_tests/input/meta_model.py +38 -0
  251. dev/integration_tests/input/python/boilerplate/main.py +153 -0
  252. dev/integration_tests/main.py +258 -0
  253. dev/test_data/csharp/test_structure/concrete_class_with_descendants/meta_model.py +15 -0
  254. dev/test_data/csharp/test_structure/constructor_without_arguments/all_properties_optional/meta_model.py +9 -0
  255. dev/test_data/csharp/test_structure/constructor_without_arguments/no_properties/meta_model.py +6 -0
  256. dev/test_data/csharp/test_verification/builtin_functions/len/on_list/meta_model.py +20 -0
  257. dev/test_data/csharp/test_verification/builtin_functions/len/on_str/meta_model.py +16 -0
  258. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_prefix/meta_model.py +8 -0
  259. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_suffix/meta_model.py +8 -0
  260. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_group_with_quantifier/meta_model.py +8 -0
  261. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_the_middle/meta_model.py +8 -0
  262. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_union/meta_model.py +8 -0
  263. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/single_utf32_literal/meta_model.py +8 -0
  264. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_within_group/meta_model.py +8 -0
  265. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_without_group/meta_model.py +8 -0
  266. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_beginning/meta_model.py +8 -0
  267. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_end/meta_model.py +8 -0
  268. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/in_the_middle/meta_model.py +8 -0
  269. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/multiple/meta_model.py +8 -0
  270. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single/meta_model.py +8 -0
  271. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single_with_quantifier/meta_model.py +8 -0
  272. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/mixed_with_non_utf32/meta_model.py +8 -0
  273. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/more_than_two_high_surrogates/meta_model.py +8 -0
  274. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges/meta_model.py +8 -0
  275. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges_mixed_with_non_utf32/meta_model.py +8 -0
  276. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate/meta_model.py +8 -0
  277. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate_with_quantifier/meta_model.py +8 -0
  278. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/two_high_surrogates/meta_model.py +8 -0
  279. dev/test_data/intermediate/expected/class/empty/meta_model.py +6 -0
  280. dev/test_data/intermediate/expected/class/implementation_specific_method/meta_model.py +8 -0
  281. dev/test_data/intermediate/expected/class/inheritance/meta_model.py +41 -0
  282. dev/test_data/intermediate/expected/class/methods_with_contracts/meta_model.py +15 -0
  283. dev/test_data/intermediate/expected/class/only_method_no_property/meta_model.py +7 -0
  284. dev/test_data/intermediate/expected/class/only_property_no_method/meta_model.py +9 -0
  285. dev/test_data/intermediate/expected/constant/constant_set/of_enum/meta_model.py +12 -0
  286. dev/test_data/intermediate/expected/constant/constant_set/of_str/meta_model.py +4 -0
  287. dev/test_data/intermediate/expected/constant/constant_set/with_description/meta_model.py +6 -0
  288. dev/test_data/intermediate/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
  289. dev/test_data/intermediate/expected/constant/constant_str/only_value/meta_model.py +7 -0
  290. dev/test_data/intermediate/expected/constant/constant_str/with_description/meta_model.py +5 -0
  291. dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_in_literal/meta_model.py +20 -0
  292. dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_outside_literal/meta_model.py +20 -0
  293. dev/test_data/intermediate/expected/empty/meta_model.py +2 -0
  294. dev/test_data/intermediate/expected/enumeration/meta_model.py +9 -0
  295. dev/test_data/intermediate/expected/interface/basic/meta_model.py +14 -0
  296. dev/test_data/intermediate/expected/interface/empty/meta_model.py +7 -0
  297. dev/test_data/intermediate/expected/interface/inheritance/meta_model.py +27 -0
  298. dev/test_data/intermediate/expected/interface/method_signature/meta_model.py +10 -0
  299. dev/test_data/intermediate/expected/interface/only_constructor/meta_model.py +11 -0
  300. dev/test_data/intermediate/expected/method/non_mutating/implementation_specific/meta_model.py +12 -0
  301. dev/test_data/intermediate/expected/method/non_mutating/understood/meta_model.py +11 -0
  302. dev/test_data/intermediate/expected/type_annotation/atomic/meta_model.py +9 -0
  303. dev/test_data/intermediate/expected/type_annotation/subscripted/class/meta_model.py +13 -0
  304. dev/test_data/intermediate/expected/type_annotation/subscripted/primitive/meta_model.py +9 -0
  305. dev/test_data/intermediate/unexpected/constant_set/of_enum/enumeration_literals_in_subset_outside_of_superset/meta_model.py +20 -0
  306. dev/test_data/intermediate/unexpected/constant_set/of_enum/invalid_literal/meta_model.py +11 -0
  307. dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_between_enumeration_and_literal/meta_model.py +30 -0
  308. dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_in_enumerations_between_subset_and_superset/meta_model.py +21 -0
  309. dev/test_data/intermediate/unexpected/constant_set/of_str/literals_in_subset_outside_of_superset/meta_model.py +18 -0
  310. dev/test_data/intermediate/unexpected/constant_set/of_str/mismatch_between_type_annotation_and_literals/meta_model.py +10 -0
  311. dev/test_data/intermediate/unexpected/constant_set/of_str/superset_and_subset_mismatch_in_type/meta_model.py +12 -0
  312. dev/test_data/intermediate/unexpected/constraints/dangling_constraintref/meta_model.py +18 -0
  313. dev/test_data/intermediate/unexpected/constraints/duplicate_constraints/meta_model.py +20 -0
  314. dev/test_data/intermediate/unexpected/documentation/unexpected_documentation_elements/meta_model.py +34 -0
  315. dev/test_data/intermediate/unexpected/invariant/class_invariant_uses_re/meta_model.py +10 -0
  316. dev/test_data/intermediate/unexpected/invariant/invariant_of_constrained_primitive_uses_re/meta_model.py +7 -0
  317. dev/test_data/intermediate/unexpected/invariant/unexpected_argument_count_to_len/meta_model.py +20 -0
  318. dev/test_data/intermediate/unexpected/invariant/unhandled_built_in_function/meta_model.py +16 -0
  319. dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/meta_model.py +7 -0
  320. dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/default_non_none/meta_model.py +16 -0
  321. dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/no_default/meta_model.py +16 -0
  322. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/after_inheritance/meta_model.py +58 -0
  323. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/type_missmatch/meta_model.py +9 -0
  324. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/within_class/meta_model.py +22 -0
  325. dev/test_data/jsonschema/test_main/regression_when_len_constraints_on_inherited_property/meta_model.py +28 -0
  326. dev/test_data/opcua/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
  327. dev/test_data/opcua/test_main/classes_with_invariants/meta_model.py +21 -0
  328. dev/test_data/opcua/test_main/concrete_class_with_descendant/meta_model.py +27 -0
  329. dev/test_data/opcua/test_main/concrete_class_with_enum/meta_model.py +21 -0
  330. dev/test_data/opcua/test_main/concrete_class_with_list_of_instances/meta_model.py +21 -0
  331. dev/test_data/opcua/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  332. dev/test_data/opcua/test_main/concrete_class_with_string/meta_model.py +13 -0
  333. dev/test_data/opcua/test_main/constrained_primitive/meta_model.py +20 -0
  334. dev/test_data/opcua/test_main/multiple_inheritance/meta_model.py +25 -0
  335. dev/test_data/parse/expected/constant/constant_set/of_enum/meta_model.py +12 -0
  336. dev/test_data/parse/expected/constant/constant_set/of_str/meta_model.py +4 -0
  337. dev/test_data/parse/expected/constant/constant_set/with_description/meta_model.py +6 -0
  338. dev/test_data/parse/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
  339. dev/test_data/parse/expected/constant/constant_str/only_value/meta_model.py +7 -0
  340. dev/test_data/parse/expected/constant/constant_str/with_description/meta_model.py +5 -0
  341. dev/test_data/parse/expected/enum/ok/meta_model.py +15 -0
  342. dev/test_data/parse/expected/implementation_specific_class/properties_and_methods_in_implementation_specific_class/meta_model.py +17 -0
  343. dev/test_data/parse/expected/inheritance/basic/meta_model.py +11 -0
  344. dev/test_data/parse/expected/inheritance/diamond/meta_model.py +26 -0
  345. dev/test_data/parse/expected/inheritance/inheritance_from_concrete_class/meta_model.py +10 -0
  346. dev/test_data/parse/expected/invariants/in_relation/meta_model.py +16 -0
  347. dev/test_data/parse/expected/method/arguments/meta_model.py +7 -0
  348. dev/test_data/parse/expected/method/basic/meta_model.py +7 -0
  349. dev/test_data/parse/expected/method/contracts/condition_as_keyword_argument/meta_model.py +8 -0
  350. dev/test_data/parse/expected/method/contracts/condition_as_positional_argument/meta_model.py +8 -0
  351. dev/test_data/parse/expected/method/contracts/description_as_keyword_argument/meta_model.py +8 -0
  352. dev/test_data/parse/expected/method/contracts/description_as_positional_argument/meta_model.py +8 -0
  353. dev/test_data/parse/expected/method/contracts/multiple_contracts_in_order/meta_model.py +17 -0
  354. dev/test_data/parse/expected/method/contracts/postcondition/basic/meta_model.py +10 -0
  355. dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_keyword_arguments/meta_model.py +9 -0
  356. dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_positional_arguments/meta_model.py +9 -0
  357. dev/test_data/parse/expected/method/default/meta_model.py +9 -0
  358. dev/test_data/parse/expected/method/description/meta_model.py +8 -0
  359. dev/test_data/parse/expected/method/is_implementation_specific/meta_model.py +8 -0
  360. dev/test_data/parse/expected/method/non_mutating/meta_model.py +11 -0
  361. dev/test_data/parse/expected/method/returns_none/meta_model.py +7 -0
  362. dev/test_data/parse/expected/method/returns_something/meta_model.py +7 -0
  363. dev/test_data/parse/expected/single_class/description/meta_model.py +12 -0
  364. dev/test_data/parse/expected/single_class/empty/meta_model.py +6 -0
  365. dev/test_data/parse/expected/single_class/property/description/meta_model.py +14 -0
  366. dev/test_data/parse/expected/single_class/property/mandatory/meta_model.py +6 -0
  367. dev/test_data/parse/expected/single_class/property/optional/meta_model.py +6 -0
  368. dev/test_data/parse/expected/single_class/property/recursion_to_entity/meta_model.py +6 -0
  369. dev/test_data/parse/unexpected/class_decorators/non_name_decorator/meta_model.py +7 -0
  370. dev/test_data/parse/unexpected/class_decorators/unknown_decorator/meta_model.py +7 -0
  371. dev/test_data/parse/unexpected/class_definitions/is_abstract_and_implementation_specific/meta_model.py +8 -0
  372. dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_before_a_method/meta_model.py +11 -0
  373. dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_for_a_pass/meta_model.py +9 -0
  374. dev/test_data/parse/unexpected/class_definitions/unexpected_double_description_for_a_property/meta_model.py +10 -0
  375. dev/test_data/parse/unexpected/class_inheritances/inheriting_from_implementation_specific_parent/meta_model.py +20 -0
  376. dev/test_data/parse/unexpected/class_inheritances/non_name_super_class/meta_model.py +6 -0
  377. dev/test_data/parse/unexpected/enum/expression_as_assignment_value/meta_model.py +6 -0
  378. dev/test_data/parse/unexpected/enum/non_assignment/meta_model.py +8 -0
  379. dev/test_data/parse/unexpected/enum/non_string_literal/meta_model.py +6 -0
  380. dev/test_data/parse/unexpected/enum/unexpected_inheritance/meta_model.py +6 -0
  381. dev/test_data/parse/unexpected/method_contracts/contract/non_lambda_condition/meta_model.py +8 -0
  382. dev/test_data/parse/unexpected/method_contracts/contract/non_string_literal_description/meta_model.py +8 -0
  383. dev/test_data/parse/unexpected/method_contracts/contract/without_any_arguments/meta_model.py +8 -0
  384. dev/test_data/parse/unexpected/method_contracts/contract/without_condition/meta_model.py +8 -0
  385. dev/test_data/parse/unexpected/method_contracts/postcondition/OLD_in_postcondition_without_snapshot/meta_model.py +8 -0
  386. dev/test_data/parse/unexpected/method_contracts/postcondition/argument_missing_in_function/meta_model.py +8 -0
  387. dev/test_data/parse/unexpected/method_contracts/precondition/argument_missing_in_function/meta_model.py +8 -0
  388. dev/test_data/parse/unexpected/method_contracts/snapshot/argument_missing_in_function/meta_model.py +8 -0
  389. dev/test_data/parse/unexpected/method_contracts/snapshot/capture_not_a_lambda/meta_model.py +8 -0
  390. dev/test_data/parse/unexpected/method_contracts/snapshot/invalid_name/meta_model.py +8 -0
  391. dev/test_data/parse/unexpected/method_contracts/snapshot/name_not_a_string_literal/meta_model.py +8 -0
  392. dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_capture/meta_model.py +8 -0
  393. dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_name/meta_model.py +8 -0
  394. dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_constructor/meta_model.py +8 -0
  395. dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_verification_function/meta_model.py +8 -0
  396. dev/test_data/parse/unexpected/method_decorators/non_name_decorator/meta_model.py +8 -0
  397. dev/test_data/parse/unexpected/method_decorators/unknown_call_decorator/meta_model.py +8 -0
  398. dev/test_data/parse/unexpected/method_decorators/unknown_name_decorator/meta_model.py +8 -0
  399. dev/test_data/parse/unexpected/method_definitions/argument_with_final/meta_model.py +7 -0
  400. dev/test_data/parse/unexpected/method_definitions/argument_without_a_type_annotation/meta_model.py +7 -0
  401. dev/test_data/parse/unexpected/method_definitions/default_for_self/meta_model.py +7 -0
  402. dev/test_data/parse/unexpected/method_definitions/dunder/meta_model.py +7 -0
  403. dev/test_data/parse/unexpected/method_definitions/init_with_return_type/meta_model.py +7 -0
  404. dev/test_data/parse/unexpected/method_definitions/with_keyword_only_arguments/meta_model.py +7 -0
  405. dev/test_data/parse/unexpected/method_definitions/with_positional_arguments/meta_model.py +7 -0
  406. dev/test_data/parse/unexpected/method_definitions/with_type_annotation_for_self/meta_model.py +7 -0
  407. dev/test_data/parse/unexpected/method_definitions/with_variable_arguments/meta_model.py +7 -0
  408. dev/test_data/parse/unexpected/method_definitions/with_variable_keyword_arguments/meta_model.py +7 -0
  409. dev/test_data/parse/unexpected/method_definitions/without_arguments/meta_model.py +7 -0
  410. dev/test_data/parse/unexpected/method_definitions/without_self/meta_model.py +7 -0
  411. dev/test_data/parse/unexpected/method_definitions/without_type_annotation_for_result/meta_model.py +7 -0
  412. dev/test_data/parse/unexpected/property_definitions/final_without_subscript/meta_model.py +6 -0
  413. dev/test_data/parse/unexpected/property_definitions/nested_final/meta_model.py +6 -0
  414. dev/test_data/parse/unexpected/property_definitions/non_simple/meta_model.py +6 -0
  415. dev/test_data/parse/unexpected/property_definitions/unexpected_assignment/meta_model.py +6 -0
  416. dev/test_data/parse/unexpected/property_definitions/unexpected_non_name_property/meta_model.py +6 -0
  417. dev/test_data/parse/unexpected/property_definitions/without_type_annotation/meta_model.py +6 -0
  418. dev/test_data/parse/unexpected/symbol_table/constant_set_with_a_non_set_subset/meta_model.py +6 -0
  419. dev/test_data/parse/unexpected/symbol_table/dangling_inheritance/meta_model.py +6 -0
  420. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_a_property/meta_model.py +6 -0
  421. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_an_argument/meta_model.py +7 -0
  422. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_constant_set/meta_model.py +6 -0
  423. dev/test_data/parse/unexpected/symbol_table/dangling_subset_in_constant_set/meta_model.py +4 -0
  424. dev/test_data/parse/unexpected/symbol_table/inheritance_from_non_class/meta_model.py +10 -0
  425. dev/test_data/parse_retree/expected/character_set/common_escaping/source.py +1 -0
  426. dev/test_data/parse_retree/expected/character_set/complementing/double_caret/source.py +1 -0
  427. dev/test_data/parse_retree/expected/character_set/complementing/multiple_ranges/source.py +1 -0
  428. dev/test_data/parse_retree/expected/character_set/complementing/suffix_dash/source.py +1 -0
  429. dev/test_data/parse_retree/expected/character_set/escape_first_caret/source.py +1 -0
  430. dev/test_data/parse_retree/expected/character_set/literals_which_need_no_escaping_in_characters_set_but_need_escaping_outside/source.py +1 -0
  431. dev/test_data/parse_retree/expected/character_set/multiple_ranges/source.py +1 -0
  432. dev/test_data/parse_retree/expected/character_set/single_literal/source.py +1 -0
  433. dev/test_data/parse_retree/expected/character_set/single_range/source.py +1 -0
  434. dev/test_data/parse_retree/expected/character_set/unescaped_dash/only_dash/source.py +1 -0
  435. dev/test_data/parse_retree/expected/character_set/unescaped_dash/prefix_dash/source.py +1 -0
  436. dev/test_data/parse_retree/expected/character_set/unescaped_dash/suffix_dash/source.py +1 -0
  437. dev/test_data/parse_retree/expected/dot/source.py +1 -0
  438. dev/test_data/parse_retree/expected/empty/group/source.py +1 -0
  439. dev/test_data/parse_retree/expected/empty/group_in_a_group/source.py +1 -0
  440. dev/test_data/parse_retree/expected/empty/group_of_union_of_empty_concatenations/source.py +1 -0
  441. dev/test_data/parse_retree/expected/empty/regex/source.py +1 -0
  442. dev/test_data/parse_retree/expected/empty/union_of_empty_concatenations/source.py +1 -0
  443. dev/test_data/parse_retree/expected/escaped_literals/source.py +1 -0
  444. dev/test_data/parse_retree/expected/formatted_value/at_the_beginning/source.py +1 -0
  445. dev/test_data/parse_retree/expected/formatted_value/at_the_end/source.py +1 -0
  446. dev/test_data/parse_retree/expected/formatted_value/in_the_middle/source.py +1 -0
  447. dev/test_data/parse_retree/expected/formatted_value/single_formatted_value/source.py +1 -0
  448. dev/test_data/parse_retree/expected/literal/source.py +1 -0
  449. dev/test_data/parse_retree/expected/quantifier/greedy/at_least_3/source.py +1 -0
  450. dev/test_data/parse_retree/expected/quantifier/greedy/at_least_one/source.py +1 -0
  451. dev/test_data/parse_retree/expected/quantifier/greedy/at_most_3/source.py +1 -0
  452. dev/test_data/parse_retree/expected/quantifier/greedy/exactly_3/source.py +1 -0
  453. dev/test_data/parse_retree/expected/quantifier/greedy/maybe/source.py +1 -0
  454. dev/test_data/parse_retree/expected/quantifier/greedy/zero_or_more/source.py +1 -0
  455. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_3/source.py +1 -0
  456. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_one/source.py +1 -0
  457. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_most_3/source.py +1 -0
  458. dev/test_data/parse_retree/expected/quantifier/non_greedy/exactly_3/source.py +1 -0
  459. dev/test_data/parse_retree/expected/quantifier/non_greedy/maybe/source.py +1 -0
  460. dev/test_data/parse_retree/expected/quantifier/non_greedy/zero_or_more/source.py +1 -0
  461. dev/test_data/parse_retree/expected/quantifier/on_a_character_set/source.py +1 -0
  462. dev/test_data/parse_retree/expected/quantifier/on_a_formatted_value/source.py +1 -0
  463. dev/test_data/parse_retree/expected/quantifier/on_a_group/source.py +1 -0
  464. dev/test_data/parse_retree/expected/quantifier/on_a_literal/source.py +1 -0
  465. dev/test_data/parse_retree/expected/start_and_stop_symbols/double_end_symbol/source.py +1 -0
  466. dev/test_data/parse_retree/expected/start_and_stop_symbols/double_start_symbol/source.py +1 -0
  467. dev/test_data/parse_retree/expected/start_and_stop_symbols/end_symbol_in_the_middle/source.py +1 -0
  468. dev/test_data/parse_retree/expected/start_and_stop_symbols/only_start_symbol/source.py +1 -0
  469. dev/test_data/parse_retree/expected/start_and_stop_symbols/only_stop_symbol/source.py +1 -0
  470. dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_at_the_beginning/source.py +1 -0
  471. dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_in_the_middle/source.py +1 -0
  472. dev/test_data/parse_retree/expected/start_and_stop_symbols/stop_symbol_at_the_end/source.py +1 -0
  473. dev/test_data/parse_retree/expected/union/of_character_sets/source.py +1 -0
  474. dev/test_data/parse_retree/expected/union/of_groups/source.py +1 -0
  475. dev/test_data/parse_retree/expected/union/of_string_literals/source.py +1 -0
  476. dev/test_data/parse_retree/expected/union/within_group/source.py +1 -0
  477. dev/test_data/parse_retree/expected/whitespace/source.py +1 -0
  478. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/Uxxxxxxxx_out_of_range/source.py +1 -0
  479. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/only_backslash/source.py +1 -0
  480. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_Uxxxxxxxx/source.py +1 -0
  481. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_uxxxx/source.py +1 -0
  482. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_x/source.py +1 -0
  483. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unexpected_escaping/source.py +1 -0
  484. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/digit/source.py +1 -0
  485. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_digit/source.py +1 -0
  486. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_whitespace/source.py +1 -0
  487. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_word/source.py +1 -0
  488. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/whitespace/source.py +1 -0
  489. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/word/source.py +1 -0
  490. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/Uxxxxxxxx_out_of_range/source.py +1 -0
  491. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/only_backslash/source.py +1 -0
  492. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_Uxxxxxxxx/source.py +1 -0
  493. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_uxxxx/source.py +1 -0
  494. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_x/source.py +1 -0
  495. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unexpected_escaping/source.py +1 -0
  496. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/digit/source.py +1 -0
  497. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_digit/source.py +1 -0
  498. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_whitespace/source.py +1 -0
  499. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_word/source.py +1 -0
  500. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/whitespace/source.py +1 -0
  501. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/word/source.py +1 -0
  502. dev/test_data/parse_retree/unexpected/invalid_character_range/source.py +1 -0
  503. dev/test_data/parse_retree/unexpected/invalid_quantifier/at_least_x/source.py +1 -0
  504. dev/test_data/parse_retree/unexpected/invalid_quantifier/between_3_and_x/source.py +1 -0
  505. dev/test_data/parse_retree/unexpected/invalid_quantifier/exactly_x/source.py +1 -0
  506. dev/test_data/parse_retree/unexpected/unhandled_group_directives/source.py +1 -0
  507. dev/test_data/parse_retree/unexpected/unterminated/character_set/source.py +1 -0
  508. dev/test_data/parse_retree/unexpected/unterminated/group/source.py +1 -0
  509. dev/test_data/parse_retree/unexpected/unterminated/group_of_union_of_empty_concatenations/source.py +1 -0
  510. dev/test_data/parse_retree/unexpected/unterminated/quantifier/source.py +1 -0
  511. dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_comma/source.py +1 -0
  512. dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_number_and_comma/source.py +1 -0
  513. dev/test_data/proto/test_main/expected/abstract_and_concrete_classes/meta_model.py +37 -0
  514. dev/test_data/proto/test_main/expected/concrete_class_with_descendants/meta_model.py +30 -0
  515. dev/test_data/proto/test_main/expected/concrete_class_with_enum/meta_model.py +21 -0
  516. dev/test_data/proto/test_main/expected/concrete_class_with_list_of_instances/meta_model.py +21 -0
  517. dev/test_data/proto/test_main/expected/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  518. dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/expected_output/pbization.py +532 -0
  519. dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
  520. dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/expected_output/pbization.py +527 -0
  521. dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/meta_model.py +27 -0
  522. dev/test_data/python_protobuf/test_main/concrete_class_with_enum/expected_output/pbization.py +290 -0
  523. dev/test_data/python_protobuf/test_main/concrete_class_with_enum/meta_model.py +21 -0
  524. dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/expected_output/pbization.py +328 -0
  525. dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/meta_model.py +23 -0
  526. dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/expected_output/pbization.py +274 -0
  527. dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  528. dev/test_data/rdf_shacl/test_main/expected/regression_when_lang_string_class_is_missing/meta_model.py +29 -0
  529. dev/test_data/rdf_shacl/test_main/expected/regression_when_len_constraints_on_inherited_property/meta_model.py +27 -0
  530. dev/test_data/rdf_shacl/test_main/unexpected/regression_len_constraint_on_class_property/meta_model.py +61 -0
  531. dev/test_data/real_meta_models/aas_core_meta.v3.py +5721 -0
  532. dev/test_data/smoke/test_main/unexpected/infer_for_schema_error/meta_model.py +12 -0
  533. dev/test_data/smoke/test_main/unexpected/intermediate_error/meta_model.py +18 -0
  534. dev/test_data/smoke/test_main/unexpected/parse_error/meta_model.py +5 -0
  535. dev/test_data/smoke/test_main/unexpected/pattern_verification_unparsable_regex/direct_match/meta_model.py +8 -0
  536. dev/test_data/smoke/test_main/unexpected/type_error/meta_model.py +18 -0
  537. dev/tests/__init__.py +1 -0
  538. dev/tests/common.py +197 -0
  539. dev/tests/cpp/__init__.py +0 -0
  540. dev/tests/cpp/test_common.py +32 -0
  541. dev/tests/cpp/test_main.py +144 -0
  542. dev/tests/cpp/test_pattern.py +188 -0
  543. dev/tests/cpp/test_verification.py +189 -0
  544. dev/tests/cpp/test_yielding.py +225 -0
  545. dev/tests/csharp/__init__.py +0 -0
  546. dev/tests/csharp/live_test_main.py +109 -0
  547. dev/tests/csharp/test_common.py +28 -0
  548. dev/tests/csharp/test_description.py +684 -0
  549. dev/tests/csharp/test_main.py +129 -0
  550. dev/tests/csharp/test_structure.py +93 -0
  551. dev/tests/csharp/test_verification.py +82 -0
  552. dev/tests/description.py +29 -0
  553. dev/tests/golang/__init__.py +0 -0
  554. dev/tests/golang/test_common.py +78 -0
  555. dev/tests/golang/test_main.py +128 -0
  556. dev/tests/infer_for_schema/__init__.py +0 -0
  557. dev/tests/infer_for_schema/common.py +47 -0
  558. dev/tests/infer_for_schema/test_len_on_properties.py +955 -0
  559. dev/tests/infer_for_schema/test_len_on_self.py +580 -0
  560. dev/tests/infer_for_schema/test_patterns_on_properties.py +686 -0
  561. dev/tests/infer_for_schema/test_patterns_on_self.py +258 -0
  562. dev/tests/infer_for_schema/test_property_in_set_of_enumeration_literals.py +600 -0
  563. dev/tests/infer_for_schema/test_property_in_set_of_primitives.py +549 -0
  564. dev/tests/intermediate/__init__.py +0 -0
  565. dev/tests/intermediate/test_constructor.py +719 -0
  566. dev/tests/intermediate/test_hierarchy.py +221 -0
  567. dev/tests/intermediate/test_revm.py +134 -0
  568. dev/tests/intermediate/test_translate.py +337 -0
  569. dev/tests/intermediate/test_type_inference.py +333 -0
  570. dev/tests/intermediate/test_types.py +169 -0
  571. dev/tests/java/__init__.py +0 -0
  572. dev/tests/java/test_common.py +20 -0
  573. dev/tests/java/test_description.py +128 -0
  574. dev/tests/java/test_main.py +234 -0
  575. dev/tests/jsonld_context/test_main.py +79 -0
  576. dev/tests/opcua/__init__.py +3 -0
  577. dev/tests/opcua/test_main.py +110 -0
  578. dev/tests/our_jsonschema/__init__.py +3 -0
  579. dev/tests/our_jsonschema/test_main.py +232 -0
  580. dev/tests/parse/__init__.py +0 -0
  581. dev/tests/parse/test_parse.py +503 -0
  582. dev/tests/parse/test_retree.py +272 -0
  583. dev/tests/proto/__init__.py +0 -0
  584. dev/tests/proto/test_main.py +112 -0
  585. dev/tests/python/__init__.py +0 -0
  586. dev/tests/python/test_common.py +124 -0
  587. dev/tests/python/test_main.py +126 -0
  588. dev/tests/python/test_xml_playground.py +254 -0
  589. dev/tests/python_protobuf/__init__.py +0 -0
  590. dev/tests/python_protobuf/test_main.py +111 -0
  591. dev/tests/rdf_shacl/__init__.py +0 -0
  592. dev/tests/rdf_shacl/test_common.py +32 -0
  593. dev/tests/rdf_shacl/test_description.py +223 -0
  594. dev/tests/rdf_shacl/test_main.py +194 -0
  595. dev/tests/smoke/__init__.py +0 -0
  596. dev/tests/smoke/test_main.py +83 -0
  597. dev/tests/test_common.py +94 -0
  598. dev/tests/typescript/__init__.py +0 -0
  599. dev/tests/typescript/test_common.py +108 -0
  600. dev/tests/typescript/test_main.py +125 -0
  601. dev/tests/xsd/__init__.py +0 -0
  602. dev/tests/xsd/test_main.py +227 -0
  603. dev/tests/yielding/__init__.py +0 -0
  604. dev/tests/yielding/test_linear.py +558 -0
@@ -0,0 +1,1103 @@
1
+ """Render descriptions to C# documentation comments."""
2
+ import abc
3
+ import collections
4
+ import io
5
+ import itertools
6
+ import textwrap
7
+ import xml.sax.saxutils
8
+ from typing import (
9
+ Tuple,
10
+ Optional,
11
+ List,
12
+ OrderedDict,
13
+ Union,
14
+ Sequence,
15
+ TypeVar,
16
+ Iterator,
17
+ Iterable,
18
+ )
19
+
20
+ import docutils.nodes
21
+ import docutils.parsers.rst.roles
22
+ import docutils.utils
23
+ from icontract import require, ensure, DBC
24
+
25
+ from aas_core_codegen import intermediate
26
+ from aas_core_codegen.common import (
27
+ Stripped,
28
+ Error,
29
+ assert_never,
30
+ Identifier,
31
+ assert_union_of_descendants_exhaustive,
32
+ assert_union_without_excluded,
33
+ )
34
+ from aas_core_codegen.csharp import (
35
+ naming as csharp_naming,
36
+ )
37
+ from aas_core_codegen.intermediate import (
38
+ doc as intermediate_doc,
39
+ _translate as intermediate_translate,
40
+ )
41
+
42
+
43
+ class _Node(DBC):
44
+ """Represent a node in an AST of a documentation comment."""
45
+
46
+ @abc.abstractmethod
47
+ def accept(self, visitor: "_NodeVisitor") -> None:
48
+ """Accept the ``visitor`` and dispatch."""
49
+ raise NotImplementedError()
50
+
51
+
52
+ class _Text(_Node):
53
+ """Represent a text node in a documentation comment."""
54
+
55
+ def __init__(self, content: str) -> None:
56
+ """Initialize with the given values."""
57
+ self.content = content
58
+
59
+ def accept(self, visitor: "_NodeVisitor") -> None:
60
+ """Accept the ``visitor`` and dispatch."""
61
+ visitor.visit_text(self)
62
+
63
+ def __repr__(self) -> str:
64
+ """Generate a string representation for easier debugging."""
65
+ return f"{self.__class__.__name__}({self.content!r})"
66
+
67
+
68
+ class _List(_Node):
69
+ """
70
+ Represent a sequence of nodes of a C# documentation comment.
71
+
72
+ This is necessary so that we can render a concatenation where there is no
73
+ enclosing element.
74
+ """
75
+
76
+ def __init__(self, items: List["_NodeUnion"]) -> None:
77
+ self.items = items
78
+
79
+ def accept(self, visitor: "_NodeVisitor") -> None:
80
+ """Accept the ``visitor`` and dispatch."""
81
+ visitor.visit_list(self)
82
+
83
+ def __repr__(self) -> str:
84
+ """Generate a string representation for easier debugging."""
85
+ if len(self.items) == 0:
86
+ return f"{self.__class__.__name__}([])"
87
+
88
+ writer = io.StringIO()
89
+ writer.write(f"{self.__class__.__name__}(\n")
90
+ writer.write(" [\n")
91
+
92
+ for i, item in enumerate(self.items):
93
+ if i > 0:
94
+ writer.write(",\n")
95
+ writer.write(textwrap.indent(repr(item), " "))
96
+
97
+ writer.write("\n ]\n)")
98
+ return writer.getvalue()
99
+
100
+
101
+ class _Element(_Node):
102
+ """Represent an element of a C# documentation comment."""
103
+
104
+ def __init__(
105
+ self,
106
+ name: str,
107
+ attrs: Optional[OrderedDict[str, str]] = None,
108
+ children: Optional[_List] = None,
109
+ ) -> None:
110
+ self.name = name
111
+ self.attrs = collections.OrderedDict() if attrs is None else attrs
112
+ self.children = _List(items=[]) if children is None else children
113
+
114
+ def accept(self, visitor: "_NodeVisitor") -> None:
115
+ """Accept the ``visitor`` and dispatch."""
116
+ visitor.visit_element(self)
117
+
118
+ def __repr__(self) -> str:
119
+ """Generate a string representation for easier debugging."""
120
+ indented_name = textwrap.indent(repr(self.name), " ")
121
+ indented_attrs = textwrap.indent(repr(self.attrs), " ")
122
+ indented_children = textwrap.indent(repr(self.children), " ")
123
+
124
+ return f"""\
125
+ {self.__class__.__name__}(
126
+ {indented_name},
127
+ {indented_attrs},
128
+ {indented_children}
129
+ )"""
130
+
131
+
132
+ _NodeUnion = Union[_Text, _Element, _List]
133
+ assert_union_of_descendants_exhaustive(base_class=_Node, union=_NodeUnion)
134
+
135
+
136
+ class _NodeVisitor:
137
+ def visit(self, node: _Node) -> None:
138
+ """Visit *via* double-dispatch."""
139
+ node.accept(self)
140
+
141
+ def visit_text(self, node: _Text) -> None:
142
+ """Visit the text node."""
143
+ pass
144
+
145
+ def visit_list(self, node: _List) -> None:
146
+ """Visit the node list and its items recursively."""
147
+ for item in node.items:
148
+ self.visit(item)
149
+
150
+ def visit_element(self, node: _Element) -> None:
151
+ """Visit the element node and its children."""
152
+ self.visit(node.children)
153
+
154
+
155
+ class _ElementRenderer(intermediate_doc.DocutilsElementTransformer[_NodeUnion]):
156
+ """Render descriptions as C# docstring XML."""
157
+
158
+ def transform_text(
159
+ self, element: docutils.nodes.Text
160
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
161
+ return _Text(element.astext()), None
162
+
163
+ def transform_reference_to_our_type_in_doc(
164
+ self, element: intermediate_doc.ReferenceToOurType
165
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
166
+ name: str
167
+
168
+ if isinstance(element.our_type, intermediate.Enumeration):
169
+ name = csharp_naming.enum_name(element.our_type.name)
170
+
171
+ elif isinstance(element.our_type, intermediate.ConstrainedPrimitive):
172
+ # NOTE (mristin, 2021-12-17):
173
+ # We do not generate a class for constrained primitives, but we
174
+ # leave it as class name, as that is what we used for ``Verify*`` function.
175
+ name = csharp_naming.class_name(element.our_type.name)
176
+
177
+ elif isinstance(element.our_type, intermediate.Class):
178
+ if isinstance(element.our_type, intermediate.AbstractClass):
179
+ # NOTE (mristin, 2021-12-25):
180
+ # We do not generate C# code for abstract classes, so we have to refer
181
+ # to the interface.
182
+ name = csharp_naming.interface_name(element.our_type.name)
183
+
184
+ elif isinstance(element.our_type, intermediate.ConcreteClass):
185
+ # NOTE (mristin, 2021-12-25):
186
+ # Though a concrete class can have multiple descendants and the writer
187
+ # might actually want to refer to the *interface* instead of
188
+ # the concrete class, we do the best effort here and resolve it to the
189
+ # name of the concrete class.
190
+ name = csharp_naming.class_name(element.our_type.name)
191
+
192
+ else:
193
+ assert_never(element.our_type)
194
+
195
+ else:
196
+ # NOTE (mristin, 2022-03-30):
197
+ # This is a very special case where we had problems with an interface.
198
+ # We leave this check here, just in case the bug resurfaces.
199
+ if isinstance(element.our_type, intermediate_translate._PlaceholderOurType):
200
+ return None, [
201
+ f"Unexpected placeholder for our type: {element.our_type}; "
202
+ f"this is a bug"
203
+ ]
204
+
205
+ assert_never(element.our_type)
206
+
207
+ # NOTE (mristin, 2022-06-19):
208
+ # We need to prefix the cref in case there are naming conflicts.
209
+ prefixed_name = f"Aas.{name}"
210
+
211
+ return (
212
+ _Element(
213
+ name="see", attrs=collections.OrderedDict([("cref", prefixed_name)])
214
+ ),
215
+ None,
216
+ )
217
+
218
+ def transform_reference_to_attribute_in_doc(
219
+ self, element: intermediate_doc.ReferenceToAttribute
220
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
221
+ cref: str
222
+
223
+ if isinstance(element.reference, intermediate_doc.ReferenceToProperty):
224
+ name_of_our_type: str
225
+
226
+ if isinstance(element.reference.cls, intermediate.AbstractClass):
227
+ # We do not generate C# code for abstract classes, so we have to refer
228
+ # to the interface.
229
+ name_of_our_type = csharp_naming.interface_name(
230
+ element.reference.cls.name
231
+ )
232
+ elif isinstance(element.reference.cls, intermediate.ConcreteClass):
233
+ # NOTE (mristin, 2021-12-25):
234
+ # Though a concrete class can have multiple descendants and the writer
235
+ # might actually want to refer to the *interface* instead of
236
+ # the concrete class, we do the best effort here and resolve it to the
237
+ # name of the concrete class.
238
+
239
+ name_of_our_type = csharp_naming.class_name(element.reference.cls.name)
240
+ else:
241
+ assert_never(element.reference.cls)
242
+
243
+ prop_name = csharp_naming.property_name(element.reference.prop.name)
244
+
245
+ cref = f"{name_of_our_type}.{prop_name}"
246
+ elif isinstance(
247
+ element.reference, intermediate_doc.ReferenceToEnumerationLiteral
248
+ ):
249
+ name_of_our_type = csharp_naming.enum_name(
250
+ element.reference.enumeration.name
251
+ )
252
+ literal_name = csharp_naming.enum_literal_name(
253
+ element.reference.literal.name
254
+ )
255
+
256
+ cref = f"{name_of_our_type}.{literal_name}"
257
+ else:
258
+ # NOTE (mristin, 2022-03-30):
259
+ # This is a very special case where we had problems with an interface.
260
+ # We leave this check here, just in case the bug resurfaces.
261
+ if isinstance(
262
+ element.reference,
263
+ intermediate_translate._PlaceholderReferenceToAttribute,
264
+ ):
265
+ return None, [
266
+ f"Unexpected placeholder "
267
+ f"for the attribute reference: {element.reference}; "
268
+ f"this is a bug"
269
+ ]
270
+
271
+ assert_never(element.reference)
272
+
273
+ # NOTE (mristin, 2022-06-19):
274
+ # We need to prefix the cref in case there are naming conflicts.
275
+ prefixed_cref = f"Aas.{cref}"
276
+
277
+ return (
278
+ _Element(
279
+ name="see", attrs=collections.OrderedDict([("cref", prefixed_cref)])
280
+ ),
281
+ None,
282
+ )
283
+
284
+ def transform_reference_to_argument_in_doc(
285
+ self, element: intermediate_doc.ReferenceToArgument
286
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
287
+ arg_name = csharp_naming.argument_name(Identifier(element.reference))
288
+
289
+ return (
290
+ _Element(
291
+ name="paramref", attrs=collections.OrderedDict([("name", arg_name)])
292
+ ),
293
+ None,
294
+ )
295
+
296
+ def transform_reference_to_constraint_in_doc(
297
+ self, element: intermediate_doc.ReferenceToConstraint
298
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
299
+ return _Text(content=f"Constraint {element.reference}"), None
300
+
301
+ def transform_reference_to_constant_in_doc(
302
+ self, element: intermediate_doc.ReferenceToConstant
303
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
304
+ constant_as_prop_name = csharp_naming.property_name(element.constant.name)
305
+ cref = f"Aas.Constants.{constant_as_prop_name}"
306
+
307
+ return (
308
+ _Element(name="see", attrs=collections.OrderedDict([("cref", cref)])),
309
+ None,
310
+ )
311
+
312
+ def transform_literal(
313
+ self, element: docutils.nodes.literal
314
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
315
+ return (
316
+ _Element(name="c", children=_List(items=[_Text(content=element.astext())])),
317
+ None,
318
+ )
319
+
320
+ def _transform_children_of(
321
+ self,
322
+ element: docutils.nodes.Element,
323
+ ) -> Tuple[Optional[_List], Optional[List[str]]]:
324
+ """Transform the children to a Python list."""
325
+ children = [] # type: List[_NodeUnion]
326
+
327
+ errors = [] # type: List[str]
328
+ for child in element.children:
329
+ rendered_child, child_errors = self.transform(child)
330
+ if child_errors is not None:
331
+ errors.extend(child_errors)
332
+ else:
333
+ assert rendered_child is not None
334
+ children.append(rendered_child)
335
+
336
+ if len(errors) > 0:
337
+ return None, errors
338
+
339
+ return _List(items=children), None
340
+
341
+ def transform_paragraph(
342
+ self, element: docutils.nodes.paragraph
343
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
344
+ children, errors = self._transform_children_of(element)
345
+ if errors is not None:
346
+ return None, errors
347
+
348
+ assert children is not None
349
+
350
+ return _Element(name="para", children=children), None
351
+
352
+ def transform_emphasis(
353
+ self, element: docutils.nodes.emphasis
354
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
355
+ children, errors = self._transform_children_of(element)
356
+ if errors is not None:
357
+ return None, errors
358
+
359
+ assert children is not None
360
+
361
+ return _Element(name="em", children=children), None
362
+
363
+ def transform_list_item(
364
+ self, element: docutils.nodes.list_item
365
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
366
+ children, errors = self._transform_children_of(element)
367
+ if errors is not None:
368
+ return None, errors
369
+
370
+ assert children is not None
371
+
372
+ return _Element(name="li", children=children), None
373
+
374
+ def transform_bullet_list(
375
+ self, element: docutils.nodes.bullet_list
376
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
377
+ children, errors = self._transform_children_of(element)
378
+ if errors is not None:
379
+ return None, errors
380
+
381
+ assert children is not None
382
+
383
+ return _Element(name="ul", children=children), None
384
+
385
+ def transform_note(
386
+ self, element: docutils.nodes.note
387
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
388
+ children, errors = self._transform_children_of(element)
389
+
390
+ if errors is not None:
391
+ return None, errors
392
+
393
+ assert children is not None
394
+
395
+ return _Element(name="para", children=children), None
396
+
397
+ def transform_reference(
398
+ self, element: docutils.nodes.reference
399
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
400
+ return self._transform_children_of(element)
401
+
402
+ def transform_field_body(
403
+ self, element: docutils.nodes.field_body
404
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
405
+ return self._transform_children_of(element)
406
+
407
+ def transform_document(
408
+ self, element: docutils.nodes.document
409
+ ) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
410
+ return self._transform_children_of(element)
411
+
412
+
413
+ class _FlattenListVisitor(_NodeVisitor):
414
+ """Flatten all the node lists recursively and in-place."""
415
+
416
+ def visit_list(self, node: _List) -> None:
417
+ """Visit the node list and its items recursively."""
418
+ new_items = [] # type: List[_NodeUnion]
419
+
420
+ for item in node.items:
421
+ self.visit(item)
422
+
423
+ if isinstance(item, _List):
424
+ new_items.extend(item.items)
425
+ else:
426
+ new_items.append(item)
427
+
428
+ node.items = new_items
429
+
430
+
431
+ class _ConcatenateTextVisitor(_NodeVisitor):
432
+ """Concatenate the consecutive text elements in lists recursively and in-place."""
433
+
434
+ def visit_list(self, node: _List) -> None:
435
+ """Visit the node list and its items recursively."""
436
+ new_items = [] # type: List[_NodeUnion]
437
+
438
+ accumulator = [] # type: List[_Text]
439
+ for item in node.items:
440
+ if isinstance(item, _Text):
441
+ accumulator.append(item)
442
+ else:
443
+ self.visit(item)
444
+
445
+ if len(accumulator) > 0:
446
+ new_items.append(
447
+ _Text(
448
+ content="".join(
449
+ text_element.content for text_element in accumulator
450
+ )
451
+ )
452
+ )
453
+ accumulator = []
454
+
455
+ new_items.append(item)
456
+
457
+ if len(accumulator) > 0:
458
+ new_items.append(
459
+ _Text(
460
+ content="".join(
461
+ text_element.content for text_element in accumulator
462
+ )
463
+ )
464
+ )
465
+
466
+ node.items = new_items
467
+
468
+
469
+ class _RemoveRedundantParaVisitor(_NodeVisitor):
470
+ """Remove the redundant ``<para>`` elements in-place."""
471
+
472
+ def visit_element(self, node: _Element) -> None:
473
+ self.visit(node.children)
474
+
475
+ # noinspection PyUnresolvedReferences
476
+ if (
477
+ node.name in ("summary", "remarks", "li", "param", "returns", "para")
478
+ and len(node.children.items) == 1
479
+ and isinstance(node.children.items[0], _Element)
480
+ and node.children.items[0].name == "para"
481
+ ):
482
+ # noinspection PyUnresolvedReferences
483
+ node.children = node.children.items[0].children
484
+
485
+
486
+ def _compress_node_in_place(node: _NodeUnion) -> None:
487
+ """Remove redundant nodes for more readability in the rendered text."""
488
+ flatten_list_visitor = _FlattenListVisitor()
489
+ flatten_list_visitor.visit(node)
490
+
491
+ concatenate_text_visitor = _ConcatenateTextVisitor()
492
+ concatenate_text_visitor.visit(node)
493
+
494
+ remove_redundant_para_visitor = _RemoveRedundantParaVisitor()
495
+ remove_redundant_para_visitor.visit(node)
496
+
497
+
498
+ def _render_summary_remarks(
499
+ description: intermediate.SummaryRemarksDescription,
500
+ ) -> Tuple[Optional[_List], Optional[List[Error]]]:
501
+ """Render a description to our description node."""
502
+ result_items = [] # type: List[_NodeUnion]
503
+ errors = [] # type: List[Error]
504
+
505
+ element_renderer = _ElementRenderer()
506
+
507
+ summary_node, summary_errors = element_renderer.transform(description.summary)
508
+ if summary_errors is not None:
509
+ errors.extend(
510
+ Error(description.parsed.node, message) for message in summary_errors
511
+ )
512
+ else:
513
+ assert summary_node is not None
514
+
515
+ result_items.append(
516
+ _Element(name="summary", children=_List(items=[summary_node]))
517
+ )
518
+
519
+ remark_nodes = [] # type: List[_NodeUnion]
520
+ for remark in description.remarks:
521
+ remark_node, remark_errors = element_renderer.transform(remark)
522
+ if remark_errors:
523
+ errors.extend(
524
+ Error(description.parsed.node, message) for message in remark_errors
525
+ )
526
+ else:
527
+ assert remark_node is not None
528
+ remark_nodes.append(remark_node)
529
+
530
+ if len(errors) > 0:
531
+ return None, errors
532
+
533
+ if len(remark_nodes) > 0:
534
+ result_items.append(
535
+ _Element(name="remarks", children=_List(items=remark_nodes))
536
+ )
537
+
538
+ return _List(items=result_items), None
539
+
540
+
541
+ def _render_summary_remarks_constraints(
542
+ description: intermediate.SummaryRemarksConstraintsDescription,
543
+ ) -> Tuple[Optional[_List], Optional[List[Error]]]:
544
+ """Render a description where constraints are put in remarks."""
545
+ result_items = [] # type: List[_NodeUnion]
546
+ errors = [] # type: List[Error]
547
+
548
+ element_renderer = _ElementRenderer()
549
+
550
+ summary_node, summary_errors = element_renderer.transform(description.summary)
551
+ if summary_errors is not None:
552
+ errors.extend(
553
+ Error(description.parsed.node, message) for message in summary_errors
554
+ )
555
+ else:
556
+ assert summary_node is not None
557
+ result_items.append(
558
+ _Element(name="summary", children=_List(items=[summary_node]))
559
+ )
560
+
561
+ remark_nodes = [] # type: List[_NodeUnion]
562
+ for remark in description.remarks:
563
+ remark_node, remark_errors = element_renderer.transform(remark)
564
+ if remark_errors:
565
+ errors.extend(
566
+ Error(description.parsed.node, message) for message in remark_errors
567
+ )
568
+ else:
569
+ assert remark_node is not None
570
+ remark_nodes.append(remark_node)
571
+
572
+ constraint_nodes = [] # type: List[_NodeUnion]
573
+ for identifier, docutils_element in description.constraints_by_identifier.items():
574
+ body, body_errors = element_renderer.transform(docutils_element)
575
+ if body_errors is not None:
576
+ errors.extend(
577
+ Error(description.parsed.node, message) for message in body_errors
578
+ )
579
+ else:
580
+ assert body is not None
581
+
582
+ # NOTE (mristin, 2022-07-21):
583
+ # We in-line the constraint prefix for better readability.
584
+
585
+ # noinspection PyUnresolvedReferences
586
+ if (
587
+ isinstance(body, _List)
588
+ and len(body.items) > 0
589
+ and isinstance(body.items[0], _Element)
590
+ and body.items[0].name == "para"
591
+ ):
592
+ # noinspection PyUnresolvedReferences
593
+ body.items[0].children.items.insert(
594
+ 0, _Text(content=f"Constraint {identifier}:\n")
595
+ )
596
+
597
+ constraint_node = _Element(name="li", children=body)
598
+ else:
599
+ constraint_node = _Element(
600
+ name="li",
601
+ children=_List(
602
+ items=[
603
+ _Element(
604
+ name="para",
605
+ children=_List(
606
+ items=[_Text(content=f"Constraint {identifier}:\n")]
607
+ ),
608
+ ),
609
+ body,
610
+ ]
611
+ ),
612
+ )
613
+
614
+ constraint_nodes.append(constraint_node)
615
+
616
+ if len(errors) > 0:
617
+ return None, errors
618
+
619
+ if len(constraint_nodes) > 0:
620
+ remark_nodes.append(
621
+ _Element(name="para", children=_List(items=[_Text(content="Constraints:")]))
622
+ )
623
+
624
+ ul_node = _Element(name="ul", children=_List(items=constraint_nodes))
625
+
626
+ remark_nodes.append(ul_node)
627
+
628
+ if len(remark_nodes) > 0:
629
+ result_items.append(
630
+ _Element(name="remarks", children=_List(items=remark_nodes))
631
+ )
632
+
633
+ return _List(items=result_items), None
634
+
635
+
636
+ @require(lambda line: "\n" not in line)
637
+ def _slash_slash_slash_line(line: str) -> str:
638
+ """Prepend ``///`` to the ``line``."""
639
+ if len(line) == 0:
640
+ return "///"
641
+
642
+ return f"/// {line}"
643
+
644
+
645
+ class _RelativeIndention:
646
+ """
647
+ Represent the relative indention.
648
+
649
+ Since the indention is *relative*, it can be either positive, neutral or negative.
650
+ """
651
+
652
+ @require(lambda direction: direction in (-1, 0, 1))
653
+ def __init__(self, direction: int) -> None:
654
+ self.direction = direction
655
+
656
+ def __repr__(self) -> str:
657
+ """Generate text representation for easier debugging."""
658
+ return f"{self.__class__.__name__}({self.direction!r})"
659
+
660
+
661
+ class _TextBlock(DBC):
662
+ """
663
+ Represent a block of text.
664
+
665
+ This data structure is expected to be append-only mutable, where you keep adding
666
+ new parts to the block. The parts are later expected to be joined by an empty
667
+ string.
668
+
669
+ All the text blocks are expected to be joined by empty strings.
670
+ """
671
+
672
+ def __init__(self, parts: List[str]) -> None:
673
+ """Initialize with the given values."""
674
+ self.parts = parts
675
+
676
+ def __repr__(self) -> str:
677
+ """Generate text representation for easier debugging."""
678
+ return f"{self.__class__.__name__}({self.parts!r})"
679
+
680
+
681
+ class _EnforceNewLine(DBC):
682
+ """
683
+ Enforce that the following text starts on a new line.
684
+
685
+ If there is already a new line output before, this text directive has no influence.
686
+ """
687
+
688
+ def __repr__(self) -> str:
689
+ """Generate text representation for easier debugging."""
690
+ return f"{self.__class__.__name__}()"
691
+
692
+
693
+ _TextDirective = Union[_RelativeIndention, _TextBlock, _EnforceNewLine]
694
+
695
+
696
+ class _ToTextDirectivesVisitor(_NodeVisitor):
697
+ """
698
+ Convert the nodes to a text as represented by text control directives.
699
+
700
+ The text is expected to be valid XML and properly escaped.
701
+ """
702
+
703
+ #: The resulting text control directives
704
+ directives: List[_TextDirective]
705
+
706
+ def __init__(self) -> None:
707
+ self.directives = []
708
+
709
+ def _last_or_new_block(self) -> _TextBlock:
710
+ """Retrieve the last block, or initialize a new block, if no last block."""
711
+ if len(self.directives) == 0 or not isinstance(self.directives[-1], _TextBlock):
712
+ self.directives.append(_TextBlock(parts=[]))
713
+
714
+ assert isinstance(self.directives[-1], _TextBlock)
715
+ return self.directives[-1]
716
+
717
+ def visit_text(self, node: _Text) -> None:
718
+ self._last_or_new_block().parts.append(xml.sax.saxutils.escape(node.content))
719
+
720
+ def visit_element(self, node: _Element) -> None:
721
+ """Visit the element node and its children."""
722
+ if node.name in ("summary", "remarks", "para", "param", "returns"):
723
+ # NOTE (mristin, 2022-07-18):
724
+ # We render these tags without indention for better readability.
725
+
726
+ start_element_writer = io.StringIO()
727
+ start_element_writer.write(f"<{node.name}")
728
+ if len(node.attrs) > 0:
729
+ for attr_name, attr_value in node.attrs.items():
730
+ start_element_writer.write(
731
+ f" {attr_name}={xml.sax.saxutils.quoteattr(attr_value)}"
732
+ )
733
+ start_element_writer.write(">")
734
+
735
+ self.directives.append(_EnforceNewLine())
736
+
737
+ self.directives.append(_TextBlock(parts=[start_element_writer.getvalue()]))
738
+
739
+ self.directives.append(_EnforceNewLine())
740
+
741
+ for item in node.children.items:
742
+ self.visit(item)
743
+
744
+ self.directives.append(_EnforceNewLine())
745
+
746
+ self.directives.append(_TextBlock(parts=[f"</{node.name}>"]))
747
+
748
+ elif node.name in ("ul", "li"):
749
+ # NOTE (mristin, 2022-07-18):
750
+ # We put the list elements on new lines and indent them.
751
+ assert (
752
+ len(node.attrs) == 0
753
+ ), f"Unexpected attributes in a node {node.name!r}"
754
+
755
+ self.directives.append(_EnforceNewLine())
756
+
757
+ self.directives.append(_TextBlock(parts=[f"<{node.name}>"]))
758
+
759
+ self.directives.append(_EnforceNewLine())
760
+
761
+ self.directives.append(_RelativeIndention(direction=1))
762
+
763
+ for item in node.children.items:
764
+ self.visit(item)
765
+
766
+ self.directives.append(_EnforceNewLine())
767
+
768
+ self.directives.append(_RelativeIndention(direction=-1))
769
+
770
+ self.directives.append(_TextBlock(parts=[f"</{node.name}>"]))
771
+
772
+ else:
773
+ # NOTE (mristin, 2022-07-18):
774
+ # We inline all the other elements.
775
+
776
+ start_element_writer = io.StringIO()
777
+ start_element_writer.write(f"<{node.name}")
778
+ if len(node.attrs) > 0:
779
+ for attr_name, attr_value in node.attrs.items():
780
+ start_element_writer.write(
781
+ f" {attr_name}={xml.sax.saxutils.quoteattr(attr_value)}"
782
+ )
783
+
784
+ if len(node.children.items) == 0:
785
+ start_element_writer.write(" />")
786
+ self._last_or_new_block().parts.append(start_element_writer.getvalue())
787
+
788
+ return
789
+
790
+ start_element_writer.write(">")
791
+ self._last_or_new_block().parts.append(start_element_writer.getvalue())
792
+
793
+ for item in node.children.items:
794
+ self.visit(item)
795
+
796
+ self._last_or_new_block().parts.append(f"</{node.name}>")
797
+
798
+
799
+ _TextDirectiveExceptEnforceNewLine = Union[_RelativeIndention, _TextBlock]
800
+ assert_union_without_excluded(
801
+ original_union=_TextDirective,
802
+ subset_union=_TextDirectiveExceptEnforceNewLine,
803
+ excluded=[_EnforceNewLine],
804
+ )
805
+
806
+ T = TypeVar("T")
807
+
808
+
809
+ def pairwise(iterable: Iterable[T]) -> Iterator[Tuple[T, T]]:
810
+ """Iterate pair-wise over the iterator."""
811
+ a, b = itertools.tee(iterable)
812
+ next(b, None)
813
+ return zip(a, b)
814
+
815
+
816
+ # fmt: off
817
+ @ensure(
818
+ lambda result:
819
+ all(
820
+ len(directive.parts) > 0
821
+ for directive in result
822
+ if isinstance(directive, _TextBlock)
823
+ ),
824
+ "No empty text blocks"
825
+ )
826
+ @ensure(
827
+ lambda result:
828
+ all(
829
+ not (
830
+ isinstance(prev, _TextBlock)
831
+ and isinstance(current, _TextBlock)
832
+ )
833
+ for prev, current in pairwise(result)
834
+ ),
835
+ "All text blocks are merged and there are no consecutive text blocks"
836
+ )
837
+ # fmt: on
838
+ def _compress_text_directives(
839
+ directives: Sequence[_TextDirective],
840
+ ) -> List[_TextDirectiveExceptEnforceNewLine]:
841
+ """Merge consecutive text blocks and enforce the new lines."""
842
+ # region Remove empty blocks
843
+
844
+ directives_wo_empty_blocks = [
845
+ directive
846
+ for directive in directives
847
+ if not (isinstance(directive, _TextBlock) and len(directive.parts) == 0)
848
+ ]
849
+
850
+ # endregion
851
+
852
+ # region Fulfill new-line enforcement
853
+
854
+ directives_wo_enforce_new_line = (
855
+ []
856
+ ) # type: List[_TextDirectiveExceptEnforceNewLine]
857
+
858
+ previous_text_block = None # type: Optional[_TextBlock]
859
+
860
+ for directive in directives_wo_empty_blocks:
861
+ if isinstance(directive, _EnforceNewLine):
862
+ if previous_text_block is not None:
863
+ assert len(previous_text_block.parts) > 0
864
+
865
+ if not previous_text_block.parts[-1].endswith("\n"):
866
+ previous_text_block.parts.append("\n")
867
+ elif isinstance(directive, _TextBlock):
868
+ assert len(directive.parts) > 0
869
+
870
+ previous_text_block = directive
871
+ directives_wo_enforce_new_line.append(directive)
872
+
873
+ elif isinstance(directive, _RelativeIndention):
874
+ directives_wo_enforce_new_line.append(directive)
875
+ else:
876
+ assert_never(directive)
877
+
878
+ # endregion
879
+
880
+ # region Merge consecutive text blocks
881
+
882
+ directives_w_merged_blocks = [] # type: List[_TextDirectiveExceptEnforceNewLine]
883
+
884
+ for directive in directives_wo_enforce_new_line:
885
+ if isinstance(directive, _TextBlock):
886
+ assert len(directive.parts) > 0
887
+
888
+ if len(directives_w_merged_blocks) > 0 and isinstance(
889
+ directives_w_merged_blocks[-1], _TextBlock
890
+ ):
891
+ directives_w_merged_blocks[-1].parts.extend(directive.parts)
892
+ else:
893
+ directives_w_merged_blocks.append(directive)
894
+ else:
895
+ directives_w_merged_blocks.append(directive)
896
+
897
+ # endregion
898
+
899
+ return directives_w_merged_blocks
900
+
901
+
902
+ def _to_text(node: _NodeUnion) -> str:
903
+ """
904
+ Convert the node to a text representation.
905
+
906
+ For readability and no phantom elements, the ``node`` is expected to be compressed
907
+ before.
908
+ """
909
+ to_text_directives_visitor = _ToTextDirectivesVisitor()
910
+ to_text_directives_visitor.visit(node)
911
+
912
+ # NOTE (mristin, 2022-07-18):
913
+ # We compress to do away with the new-line enforcement and consecutive and empty
914
+ # blocks, so that the operations below become much easier to write.
915
+ directives = _compress_text_directives(to_text_directives_visitor.directives)
916
+
917
+ writer = io.StringIO()
918
+ level = 0 # indention level
919
+
920
+ for directive in directives:
921
+ if isinstance(directive, _TextBlock):
922
+ writer.write(textwrap.indent("".join(directive.parts), level * " "))
923
+
924
+ elif isinstance(directive, _RelativeIndention):
925
+ assert level + directive.direction >= 0, (
926
+ f"Negative absolute indention not possible: "
927
+ f"{level=}, {directive.direction=}"
928
+ )
929
+ level += directive.direction
930
+
931
+ else:
932
+ assert_never(directive)
933
+
934
+ return writer.getvalue()
935
+
936
+
937
+ def _generate_summary_remarks(
938
+ description: intermediate.SummaryRemarksDescription,
939
+ ) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
940
+ """Generate the documentation comment for a summary-remarks description."""
941
+ node, errors = _render_summary_remarks(description=description)
942
+ if errors is not None:
943
+ return None, errors
944
+
945
+ assert node is not None
946
+
947
+ _compress_node_in_place(node=node)
948
+ text = _to_text(node)
949
+
950
+ commented_lines = [_slash_slash_slash_line(line) for line in text.splitlines()]
951
+
952
+ return Stripped("\n".join(commented_lines)), None
953
+
954
+
955
+ def _generate_summary_remarks_constraints(
956
+ description: intermediate.SummaryRemarksConstraintsDescription,
957
+ ) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
958
+ """Generate the documentation comment for a summary-remarks-constraints."""
959
+ node, errors = _render_summary_remarks_constraints(description=description)
960
+ if errors is not None:
961
+ return None, errors
962
+
963
+ assert node is not None
964
+
965
+ _compress_node_in_place(node=node)
966
+ text = _to_text(node)
967
+
968
+ commented_lines = [_slash_slash_slash_line(line) for line in text.splitlines()]
969
+
970
+ return Stripped("\n".join(commented_lines)), None
971
+
972
+
973
+ def generate_comment_for_meta_model(
974
+ description: intermediate.DescriptionOfMetaModel,
975
+ ) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
976
+ """Generate the documentation comment for the given meta-model."""
977
+ return _generate_summary_remarks_constraints(description)
978
+
979
+
980
+ def generate_comment_for_our_type(
981
+ description: intermediate.DescriptionOfOurType,
982
+ ) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
983
+ """Generate the documentation comment for our type."""
984
+ return _generate_summary_remarks_constraints(description)
985
+
986
+
987
+ def generate_comment_for_property(
988
+ description: intermediate.DescriptionOfProperty,
989
+ ) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
990
+ """Generate the documentation comment for the given property."""
991
+ return _generate_summary_remarks_constraints(description)
992
+
993
+
994
+ def generate_comment_for_enumeration_literal(
995
+ description: intermediate.DescriptionOfEnumerationLiteral,
996
+ ) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
997
+ """Generate the documentation comment for the given enumeration literal."""
998
+ return _generate_summary_remarks(description)
999
+
1000
+
1001
+ def _render_description_of_signature(
1002
+ description: intermediate.DescriptionOfSignature,
1003
+ ) -> Tuple[Optional[_List], Optional[List[Error]]]:
1004
+ """Render a description where constraints are put in remarks."""
1005
+ result_items = [] # type: List[_NodeUnion]
1006
+ errors = [] # type: List[Error]
1007
+
1008
+ renderer = _ElementRenderer()
1009
+
1010
+ summary_node, summary_errors = renderer.transform(description.summary)
1011
+ if summary_errors is not None:
1012
+ errors.extend(
1013
+ Error(description.parsed.node, message) for message in summary_errors
1014
+ )
1015
+ else:
1016
+ assert summary_node is not None
1017
+ result_items.append(
1018
+ _Element(name="summary", children=_List(items=[summary_node]))
1019
+ )
1020
+
1021
+ remark_nodes = [] # type: List[_NodeUnion]
1022
+ for remark in description.remarks:
1023
+ remark_node, remark_errors = renderer.transform(remark)
1024
+ if remark_errors:
1025
+ errors.extend(
1026
+ Error(description.parsed.node, message) for message in remark_errors
1027
+ )
1028
+ else:
1029
+ assert remark_node is not None
1030
+ remark_nodes.append(remark_node)
1031
+
1032
+ param_nodes = [] # type: List[_NodeUnion]
1033
+
1034
+ for name, docutils_element in description.arguments_by_name.items():
1035
+ returns, body_errors = renderer.transform(docutils_element)
1036
+ if body_errors is not None:
1037
+ errors.extend(
1038
+ Error(description.parsed.node, message) for message in body_errors
1039
+ )
1040
+ else:
1041
+ assert returns is not None
1042
+
1043
+ param_nodes.append(
1044
+ _Element(
1045
+ name="param",
1046
+ attrs=collections.OrderedDict([("name", name)]),
1047
+ children=_List(items=[returns]),
1048
+ )
1049
+ )
1050
+
1051
+ returns_node = None # type: Optional[_NodeUnion]
1052
+
1053
+ if description.returns is not None:
1054
+ # NOTE (mristin, 2022-07-18):
1055
+ # We need to help the type checker in PyCharm a bit.
1056
+ assert isinstance(description.returns, docutils.nodes.field_body)
1057
+
1058
+ returns, returns_errors = renderer.transform(description.returns)
1059
+ if returns_errors is not None:
1060
+ errors.extend(
1061
+ Error(description.parsed.node, message) for message in returns_errors
1062
+ )
1063
+ else:
1064
+ assert returns is not None
1065
+
1066
+ returns_node = _Element(name="returns", children=_List(items=[returns]))
1067
+
1068
+ if len(errors) > 0:
1069
+ return None, errors
1070
+
1071
+ if len(remark_nodes) > 0:
1072
+ result_items.append(
1073
+ _Element(name="remarks", children=_List(items=remark_nodes))
1074
+ )
1075
+
1076
+ result_items.extend(param_nodes)
1077
+
1078
+ if returns_node is not None:
1079
+ result_items.append(returns_node)
1080
+
1081
+ return _List(items=result_items), None
1082
+
1083
+
1084
+ def generate_comment_for_signature(
1085
+ description: intermediate.DescriptionOfSignature,
1086
+ ) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
1087
+ """
1088
+ Generate the documentation comment for the given signature.
1089
+
1090
+ A signature, in this context, means a function or a method signature.
1091
+ """
1092
+ node, errors = _render_description_of_signature(description=description)
1093
+ if errors is not None:
1094
+ return None, errors
1095
+
1096
+ assert node is not None
1097
+
1098
+ _compress_node_in_place(node=node)
1099
+ text = _to_text(node)
1100
+
1101
+ commented_lines = [_slash_slash_slash_line(line) for line in text.splitlines()]
1102
+
1103
+ return Stripped("\n".join(commented_lines)), None