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.
- aas_core_codegen/__init__.py +6 -0
- aas_core_codegen/__main__.py +8 -0
- aas_core_codegen/common.py +500 -0
- aas_core_codegen/cpp/__init__.py +1 -0
- aas_core_codegen/cpp/aas_common/__init__.py +6 -0
- aas_core_codegen/cpp/aas_common/_generate.py +713 -0
- aas_core_codegen/cpp/common.py +681 -0
- aas_core_codegen/cpp/constants/__init__.py +6 -0
- aas_core_codegen/cpp/constants/_generate.py +568 -0
- aas_core_codegen/cpp/description.py +654 -0
- aas_core_codegen/cpp/enhancing/__init__.py +4 -0
- aas_core_codegen/cpp/enhancing/_generate.py +993 -0
- aas_core_codegen/cpp/iteration/__init__.py +6 -0
- aas_core_codegen/cpp/iteration/_generate.py +2332 -0
- aas_core_codegen/cpp/jsonization/__init__.py +6 -0
- aas_core_codegen/cpp/jsonization/_generate.py +2619 -0
- aas_core_codegen/cpp/main.py +694 -0
- aas_core_codegen/cpp/naming.py +170 -0
- aas_core_codegen/cpp/optionaling.py +557 -0
- aas_core_codegen/cpp/pattern/__init__.py +6 -0
- aas_core_codegen/cpp/pattern/_generate.py +508 -0
- aas_core_codegen/cpp/revm/__init__.py +6 -0
- aas_core_codegen/cpp/revm/_generate.py +1149 -0
- aas_core_codegen/cpp/stringification/__init__.py +5 -0
- aas_core_codegen/cpp/stringification/_generate.py +955 -0
- aas_core_codegen/cpp/structure/__init__.py +7 -0
- aas_core_codegen/cpp/structure/_generate.py +1503 -0
- aas_core_codegen/cpp/transpilation.py +1383 -0
- aas_core_codegen/cpp/unrolling.py +159 -0
- aas_core_codegen/cpp/verification/__init__.py +6 -0
- aas_core_codegen/cpp/verification/_generate.py +3073 -0
- aas_core_codegen/cpp/visitation/__init__.py +6 -0
- aas_core_codegen/cpp/visitation/_generate.py +521 -0
- aas_core_codegen/cpp/wstringification/__init__.py +5 -0
- aas_core_codegen/cpp/wstringification/_generate.py +586 -0
- aas_core_codegen/cpp/xmlization/__init__.py +6 -0
- aas_core_codegen/cpp/xmlization/_generate.py +5373 -0
- aas_core_codegen/cpp/yielding.py +201 -0
- aas_core_codegen/csharp/__init__.py +1 -0
- aas_core_codegen/csharp/common.py +224 -0
- aas_core_codegen/csharp/constants/__init__.py +5 -0
- aas_core_codegen/csharp/constants/_generate.py +409 -0
- aas_core_codegen/csharp/copying/__init__.py +4 -0
- aas_core_codegen/csharp/copying/_generate.py +498 -0
- aas_core_codegen/csharp/description.py +1103 -0
- aas_core_codegen/csharp/enhancing/__init__.py +4 -0
- aas_core_codegen/csharp/enhancing/_generate.py +667 -0
- aas_core_codegen/csharp/jsonization/__init__.py +4 -0
- aas_core_codegen/csharp/jsonization/_generate.py +1630 -0
- aas_core_codegen/csharp/main.py +421 -0
- aas_core_codegen/csharp/naming.py +157 -0
- aas_core_codegen/csharp/reporting/__init__.py +4 -0
- aas_core_codegen/csharp/reporting/_generate.py +266 -0
- aas_core_codegen/csharp/stringification/__init__.py +4 -0
- aas_core_codegen/csharp/stringification/_generate.py +243 -0
- aas_core_codegen/csharp/structure/__init__.py +6 -0
- aas_core_codegen/csharp/structure/_generate.py +1341 -0
- aas_core_codegen/csharp/transpilation.py +990 -0
- aas_core_codegen/csharp/unrolling.py +211 -0
- aas_core_codegen/csharp/verification/__init__.py +6 -0
- aas_core_codegen/csharp/verification/_generate.py +1457 -0
- aas_core_codegen/csharp/visitation/__init__.py +5 -0
- aas_core_codegen/csharp/visitation/_generate.py +579 -0
- aas_core_codegen/csharp/xmlization/__init__.py +4 -0
- aas_core_codegen/csharp/xmlization/_generate.py +1980 -0
- aas_core_codegen/golang/__init__.py +1 -0
- aas_core_codegen/golang/aas_common/__init__.py +4 -0
- aas_core_codegen/golang/aas_common/_generate.py +152 -0
- aas_core_codegen/golang/common.py +303 -0
- aas_core_codegen/golang/constants/__init__.py +5 -0
- aas_core_codegen/golang/constants/_generate.py +339 -0
- aas_core_codegen/golang/description.py +501 -0
- aas_core_codegen/golang/enhancing/__init__.py +4 -0
- aas_core_codegen/golang/enhancing/_generate.py +527 -0
- aas_core_codegen/golang/jsonization/__init__.py +4 -0
- aas_core_codegen/golang/jsonization/_generate.py +1740 -0
- aas_core_codegen/golang/main.py +368 -0
- aas_core_codegen/golang/naming.py +412 -0
- aas_core_codegen/golang/pointering.py +631 -0
- aas_core_codegen/golang/reporting/__init__.py +4 -0
- aas_core_codegen/golang/reporting/_generate.py +218 -0
- aas_core_codegen/golang/stringification/__init__.py +4 -0
- aas_core_codegen/golang/stringification/_generate.py +394 -0
- aas_core_codegen/golang/structure/__init__.py +6 -0
- aas_core_codegen/golang/structure/_generate.py +1493 -0
- aas_core_codegen/golang/transpilation.py +1191 -0
- aas_core_codegen/golang/unrolling.py +159 -0
- aas_core_codegen/golang/verification/__init__.py +6 -0
- aas_core_codegen/golang/verification/_generate.py +1513 -0
- aas_core_codegen/golang/xmlization/__init__.py +4 -0
- aas_core_codegen/golang/xmlization/_generate.py +2507 -0
- aas_core_codegen/infer_for_schema/__init__.py +21 -0
- aas_core_codegen/infer_for_schema/_inline.py +693 -0
- aas_core_codegen/infer_for_schema/_len.py +527 -0
- aas_core_codegen/infer_for_schema/_pattern.py +311 -0
- aas_core_codegen/infer_for_schema/_set.py +394 -0
- aas_core_codegen/infer_for_schema/_stringify.py +201 -0
- aas_core_codegen/infer_for_schema/_types.py +135 -0
- aas_core_codegen/infer_for_schema/match.py +122 -0
- aas_core_codegen/intermediate/__init__.py +78 -0
- aas_core_codegen/intermediate/_hierarchy.py +397 -0
- aas_core_codegen/intermediate/_stringify.py +989 -0
- aas_core_codegen/intermediate/_translate.py +5128 -0
- aas_core_codegen/intermediate/_types.py +2901 -0
- aas_core_codegen/intermediate/construction.py +750 -0
- aas_core_codegen/intermediate/doc.py +344 -0
- aas_core_codegen/intermediate/pattern_verification.py +428 -0
- aas_core_codegen/intermediate/revm.py +985 -0
- aas_core_codegen/intermediate/type_inference.py +2266 -0
- aas_core_codegen/java/__init__.py +1 -0
- aas_core_codegen/java/common.py +197 -0
- aas_core_codegen/java/constants/__init__.py +5 -0
- aas_core_codegen/java/constants/_generate.py +334 -0
- aas_core_codegen/java/copying/__init__.py +4 -0
- aas_core_codegen/java/copying/_generate.py +502 -0
- aas_core_codegen/java/description.py +774 -0
- aas_core_codegen/java/enhancing/__init__.py +4 -0
- aas_core_codegen/java/enhancing/_generate.py +820 -0
- aas_core_codegen/java/generation/__init__.py +5 -0
- aas_core_codegen/java/generation/_generate.py +285 -0
- aas_core_codegen/java/jsonization/__init__.py +4 -0
- aas_core_codegen/java/jsonization/_generate.py +1472 -0
- aas_core_codegen/java/main.py +438 -0
- aas_core_codegen/java/naming.py +187 -0
- aas_core_codegen/java/optional.py +514 -0
- aas_core_codegen/java/reporting/__init__.py +4 -0
- aas_core_codegen/java/reporting/_generate.py +248 -0
- aas_core_codegen/java/stringification/__init__.py +4 -0
- aas_core_codegen/java/stringification/_generate.py +212 -0
- aas_core_codegen/java/structure/__init__.py +6 -0
- aas_core_codegen/java/structure/_generate.py +1767 -0
- aas_core_codegen/java/transpilation.py +1111 -0
- aas_core_codegen/java/verification/__init__.py +6 -0
- aas_core_codegen/java/verification/_generate.py +1536 -0
- aas_core_codegen/java/visitation/__init__.py +5 -0
- aas_core_codegen/java/visitation/_generate.py +689 -0
- aas_core_codegen/java/xmlization/__init__.py +4 -0
- aas_core_codegen/java/xmlization/_generate.py +2274 -0
- aas_core_codegen/jsonld/__init__.py +1 -0
- aas_core_codegen/jsonld/main.py +455 -0
- aas_core_codegen/jsonschema/__init__.py +1 -0
- aas_core_codegen/jsonschema/main.py +982 -0
- aas_core_codegen/main.py +245 -0
- aas_core_codegen/naming.py +133 -0
- aas_core_codegen/opcua/__init__.py +1 -0
- aas_core_codegen/opcua/main.py +1525 -0
- aas_core_codegen/opcua/naming.py +126 -0
- aas_core_codegen/parse/__init__.py +46 -0
- aas_core_codegen/parse/_rules.py +796 -0
- aas_core_codegen/parse/_stringify.py +532 -0
- aas_core_codegen/parse/_translate.py +3940 -0
- aas_core_codegen/parse/_types.py +973 -0
- aas_core_codegen/parse/retree/__init__.py +46 -0
- aas_core_codegen/parse/retree/_fix.py +434 -0
- aas_core_codegen/parse/retree/_parse.py +1143 -0
- aas_core_codegen/parse/retree/_render.py +298 -0
- aas_core_codegen/parse/retree/_stringify.py +199 -0
- aas_core_codegen/parse/retree/_types.py +362 -0
- aas_core_codegen/parse/retree/_visitor.py +70 -0
- aas_core_codegen/parse/tree.py +1303 -0
- aas_core_codegen/protobuf/__init__.py +1 -0
- aas_core_codegen/protobuf/common.py +225 -0
- aas_core_codegen/protobuf/description.py +1102 -0
- aas_core_codegen/protobuf/main.py +115 -0
- aas_core_codegen/protobuf/naming.py +143 -0
- aas_core_codegen/protobuf/structure/__init__.py +6 -0
- aas_core_codegen/protobuf/structure/_generate.py +502 -0
- aas_core_codegen/py.typed +1 -0
- aas_core_codegen/python/__init__.py +1 -0
- aas_core_codegen/python/aas_common/__init__.py +4 -0
- aas_core_codegen/python/aas_common/_generate.py +63 -0
- aas_core_codegen/python/common.py +406 -0
- aas_core_codegen/python/constants/__init__.py +5 -0
- aas_core_codegen/python/constants/_generate.py +377 -0
- aas_core_codegen/python/description.py +508 -0
- aas_core_codegen/python/jsonization/__init__.py +4 -0
- aas_core_codegen/python/jsonization/_generate.py +1391 -0
- aas_core_codegen/python/main.py +323 -0
- aas_core_codegen/python/naming.py +255 -0
- aas_core_codegen/python/stringification/__init__.py +4 -0
- aas_core_codegen/python/stringification/_generate.py +129 -0
- aas_core_codegen/python/structure/__init__.py +6 -0
- aas_core_codegen/python/structure/_generate.py +1801 -0
- aas_core_codegen/python/transpilation.py +958 -0
- aas_core_codegen/python/unrolling.py +156 -0
- aas_core_codegen/python/verification/__init__.py +6 -0
- aas_core_codegen/python/verification/_generate.py +1471 -0
- aas_core_codegen/python/xmlization/__init__.py +4 -0
- aas_core_codegen/python/xmlization/_generate.py +3003 -0
- aas_core_codegen/python_protobuf/__init__.py +1 -0
- aas_core_codegen/python_protobuf/main.py +1424 -0
- aas_core_codegen/python_protobuf/naming.py +85 -0
- aas_core_codegen/rdf_shacl/__init__.py +1 -0
- aas_core_codegen/rdf_shacl/_description.py +351 -0
- aas_core_codegen/rdf_shacl/common.py +206 -0
- aas_core_codegen/rdf_shacl/main.py +114 -0
- aas_core_codegen/rdf_shacl/naming.py +145 -0
- aas_core_codegen/rdf_shacl/rdf.py +435 -0
- aas_core_codegen/rdf_shacl/shacl.py +453 -0
- aas_core_codegen/run.py +124 -0
- aas_core_codegen/smoke/__init__.py +1 -0
- aas_core_codegen/smoke/main.py +219 -0
- aas_core_codegen/specific_implementations.py +72 -0
- aas_core_codegen/stringify.py +333 -0
- aas_core_codegen/typescript/__init__.py +1 -0
- aas_core_codegen/typescript/aas_common/__init__.py +4 -0
- aas_core_codegen/typescript/aas_common/_generate.py +472 -0
- aas_core_codegen/typescript/common.py +340 -0
- aas_core_codegen/typescript/constants/__init__.py +5 -0
- aas_core_codegen/typescript/constants/_generate.py +347 -0
- aas_core_codegen/typescript/description.py +530 -0
- aas_core_codegen/typescript/jsonization/__init__.py +4 -0
- aas_core_codegen/typescript/jsonization/_generate.py +1510 -0
- aas_core_codegen/typescript/main.py +258 -0
- aas_core_codegen/typescript/naming.py +189 -0
- aas_core_codegen/typescript/stringification/__init__.py +4 -0
- aas_core_codegen/typescript/stringification/_generate.py +367 -0
- aas_core_codegen/typescript/structure/__init__.py +6 -0
- aas_core_codegen/typescript/structure/_generate.py +2500 -0
- aas_core_codegen/typescript/transpilation.py +1051 -0
- aas_core_codegen/typescript/unrolling.py +159 -0
- aas_core_codegen/typescript/verification/__init__.py +6 -0
- aas_core_codegen/typescript/verification/_generate.py +1578 -0
- aas_core_codegen/xsd/__init__.py +1 -0
- aas_core_codegen/xsd/main.py +1187 -0
- aas_core_codegen/xsd/naming.py +83 -0
- aas_core_codegen/yielding/__init__.py +1 -0
- aas_core_codegen/yielding/flow.py +139 -0
- aas_core_codegen/yielding/linear.py +754 -0
- aas_core_codegen-0.0.16.dist-info/METADATA +211 -0
- aas_core_codegen-0.0.16.dist-info/RECORD +604 -0
- aas_core_codegen-0.0.16.dist-info/WHEEL +5 -0
- aas_core_codegen-0.0.16.dist-info/entry_points.txt +3 -0
- aas_core_codegen-0.0.16.dist-info/licenses/AUTHORS +9 -0
- aas_core_codegen-0.0.16.dist-info/licenses/LICENSE +23 -0
- aas_core_codegen-0.0.16.dist-info/top_level.txt +2 -0
- dev/continuous_integration/__init__.py +1 -0
- dev/continuous_integration/check_help_in_readme.py +208 -0
- dev/continuous_integration/check_init_and_pyproject_consistent.py +154 -0
- dev/continuous_integration/precommit.py +400 -0
- dev/dev_scripts/__init__.py +1 -0
- dev/dev_scripts/compare_rendered_regexes_against_source_py.py +42 -0
- dev/dev_scripts/copy_to_aas_core3_cpp.py +100 -0
- dev/dev_scripts/copy_to_aas_core3_java.py +90 -0
- dev/dev_scripts/download_latest_aas_core_meta_v3.py +114 -0
- dev/dev_scripts/draw_bipartite_graph_based_on_lines.py +37 -0
- dev/dev_scripts/run_tests_with_rerecord.py +69 -0
- dev/dev_scripts/update_to_aas_core_meta.py +174 -0
- dev/integration_tests/input/jsonschema/boilerplate/main.py +55 -0
- dev/integration_tests/input/meta_model.py +38 -0
- dev/integration_tests/input/python/boilerplate/main.py +153 -0
- dev/integration_tests/main.py +258 -0
- dev/test_data/csharp/test_structure/concrete_class_with_descendants/meta_model.py +15 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/all_properties_optional/meta_model.py +9 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/no_properties/meta_model.py +6 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_list/meta_model.py +20 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_str/meta_model.py +16 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_prefix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_suffix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_group_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_union/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/single_utf32_literal/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_within_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_without_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_beginning/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_end/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/multiple/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/mixed_with_non_utf32/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/more_than_two_high_surrogates/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges/meta_model.py +8 -0
- 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
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/two_high_surrogates/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/empty/meta_model.py +6 -0
- dev/test_data/intermediate/expected/class/implementation_specific_method/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/inheritance/meta_model.py +41 -0
- dev/test_data/intermediate/expected/class/methods_with_contracts/meta_model.py +15 -0
- dev/test_data/intermediate/expected/class/only_method_no_property/meta_model.py +7 -0
- dev/test_data/intermediate/expected/class/only_property_no_method/meta_model.py +9 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/intermediate/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/intermediate/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_in_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_outside_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/empty/meta_model.py +2 -0
- dev/test_data/intermediate/expected/enumeration/meta_model.py +9 -0
- dev/test_data/intermediate/expected/interface/basic/meta_model.py +14 -0
- dev/test_data/intermediate/expected/interface/empty/meta_model.py +7 -0
- dev/test_data/intermediate/expected/interface/inheritance/meta_model.py +27 -0
- dev/test_data/intermediate/expected/interface/method_signature/meta_model.py +10 -0
- dev/test_data/intermediate/expected/interface/only_constructor/meta_model.py +11 -0
- dev/test_data/intermediate/expected/method/non_mutating/implementation_specific/meta_model.py +12 -0
- dev/test_data/intermediate/expected/method/non_mutating/understood/meta_model.py +11 -0
- dev/test_data/intermediate/expected/type_annotation/atomic/meta_model.py +9 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/class/meta_model.py +13 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/primitive/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/enumeration_literals_in_subset_outside_of_superset/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/invalid_literal/meta_model.py +11 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_between_enumeration_and_literal/meta_model.py +30 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_in_enumerations_between_subset_and_superset/meta_model.py +21 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/literals_in_subset_outside_of_superset/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/mismatch_between_type_annotation_and_literals/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/superset_and_subset_mismatch_in_type/meta_model.py +12 -0
- dev/test_data/intermediate/unexpected/constraints/dangling_constraintref/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constraints/duplicate_constraints/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/documentation/unexpected_documentation_elements/meta_model.py +34 -0
- dev/test_data/intermediate/unexpected/invariant/class_invariant_uses_re/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/invariant/invariant_of_constrained_primitive_uses_re/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/invariant/unexpected_argument_count_to_len/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/invariant/unhandled_built_in_function/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/default_non_none/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/no_default/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/after_inheritance/meta_model.py +58 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/type_missmatch/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/within_class/meta_model.py +22 -0
- dev/test_data/jsonschema/test_main/regression_when_len_constraints_on_inherited_property/meta_model.py +28 -0
- dev/test_data/opcua/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/opcua/test_main/classes_with_invariants/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/opcua/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/opcua/test_main/concrete_class_with_string/meta_model.py +13 -0
- dev/test_data/opcua/test_main/constrained_primitive/meta_model.py +20 -0
- dev/test_data/opcua/test_main/multiple_inheritance/meta_model.py +25 -0
- dev/test_data/parse/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/parse/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/parse/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/parse/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/parse/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/parse/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/parse/expected/enum/ok/meta_model.py +15 -0
- dev/test_data/parse/expected/implementation_specific_class/properties_and_methods_in_implementation_specific_class/meta_model.py +17 -0
- dev/test_data/parse/expected/inheritance/basic/meta_model.py +11 -0
- dev/test_data/parse/expected/inheritance/diamond/meta_model.py +26 -0
- dev/test_data/parse/expected/inheritance/inheritance_from_concrete_class/meta_model.py +10 -0
- dev/test_data/parse/expected/invariants/in_relation/meta_model.py +16 -0
- dev/test_data/parse/expected/method/arguments/meta_model.py +7 -0
- dev/test_data/parse/expected/method/basic/meta_model.py +7 -0
- dev/test_data/parse/expected/method/contracts/condition_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/condition_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/multiple_contracts_in_order/meta_model.py +17 -0
- dev/test_data/parse/expected/method/contracts/postcondition/basic/meta_model.py +10 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_keyword_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_positional_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/default/meta_model.py +9 -0
- dev/test_data/parse/expected/method/description/meta_model.py +8 -0
- dev/test_data/parse/expected/method/is_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/expected/method/non_mutating/meta_model.py +11 -0
- dev/test_data/parse/expected/method/returns_none/meta_model.py +7 -0
- dev/test_data/parse/expected/method/returns_something/meta_model.py +7 -0
- dev/test_data/parse/expected/single_class/description/meta_model.py +12 -0
- dev/test_data/parse/expected/single_class/empty/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/description/meta_model.py +14 -0
- dev/test_data/parse/expected/single_class/property/mandatory/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/optional/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/recursion_to_entity/meta_model.py +6 -0
- dev/test_data/parse/unexpected/class_decorators/non_name_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_decorators/unknown_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_definitions/is_abstract_and_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_before_a_method/meta_model.py +11 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_for_a_pass/meta_model.py +9 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_double_description_for_a_property/meta_model.py +10 -0
- dev/test_data/parse/unexpected/class_inheritances/inheriting_from_implementation_specific_parent/meta_model.py +20 -0
- dev/test_data/parse/unexpected/class_inheritances/non_name_super_class/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/expression_as_assignment_value/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/non_assignment/meta_model.py +8 -0
- dev/test_data/parse/unexpected/enum/non_string_literal/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/unexpected_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_lambda_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_string_literal_description/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_any_arguments/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/OLD_in_postcondition_without_snapshot/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/precondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/capture_not_a_lambda/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/invalid_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/name_not_a_string_literal/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_capture/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_constructor/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_verification_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_call_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_definitions/argument_with_final/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/argument_without_a_type_annotation/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/default_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/dunder/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/init_with_return_type/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_keyword_only_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_positional_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_type_annotation_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_keyword_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_type_annotation_for_result/meta_model.py +7 -0
- dev/test_data/parse/unexpected/property_definitions/final_without_subscript/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/nested_final/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/non_simple/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_assignment/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_non_name_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/without_type_annotation/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/constant_set_with_a_non_set_subset/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_a_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_an_argument/meta_model.py +7 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_constant_set/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_subset_in_constant_set/meta_model.py +4 -0
- dev/test_data/parse/unexpected/symbol_table/inheritance_from_non_class/meta_model.py +10 -0
- dev/test_data/parse_retree/expected/character_set/common_escaping/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/double_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/escape_first_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/literals_which_need_no_escaping_in_characters_set_but_need_escaping_outside/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_range/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/only_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/prefix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/dot/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_in_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/regex/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/escaped_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/single_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/literal/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_character_set/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_end_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/end_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_stop_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/stop_symbol_at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_character_sets/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_groups/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_string_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/union/within_group/source.py +1 -0
- dev/test_data/parse_retree/expected/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_character_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/at_least_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/between_3_and_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/exactly_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unhandled_group_directives/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/character_set/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_comma/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_number_and_comma/source.py +1 -0
- dev/test_data/proto/test_main/expected/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_descendants/meta_model.py +30 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/expected_output/pbization.py +532 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/expected_output/pbization.py +527 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/expected_output/pbization.py +290 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/expected_output/pbization.py +328 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/meta_model.py +23 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/expected_output/pbization.py +274 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_lang_string_class_is_missing/meta_model.py +29 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_len_constraints_on_inherited_property/meta_model.py +27 -0
- dev/test_data/rdf_shacl/test_main/unexpected/regression_len_constraint_on_class_property/meta_model.py +61 -0
- dev/test_data/real_meta_models/aas_core_meta.v3.py +5721 -0
- dev/test_data/smoke/test_main/unexpected/infer_for_schema_error/meta_model.py +12 -0
- dev/test_data/smoke/test_main/unexpected/intermediate_error/meta_model.py +18 -0
- dev/test_data/smoke/test_main/unexpected/parse_error/meta_model.py +5 -0
- dev/test_data/smoke/test_main/unexpected/pattern_verification_unparsable_regex/direct_match/meta_model.py +8 -0
- dev/test_data/smoke/test_main/unexpected/type_error/meta_model.py +18 -0
- dev/tests/__init__.py +1 -0
- dev/tests/common.py +197 -0
- dev/tests/cpp/__init__.py +0 -0
- dev/tests/cpp/test_common.py +32 -0
- dev/tests/cpp/test_main.py +144 -0
- dev/tests/cpp/test_pattern.py +188 -0
- dev/tests/cpp/test_verification.py +189 -0
- dev/tests/cpp/test_yielding.py +225 -0
- dev/tests/csharp/__init__.py +0 -0
- dev/tests/csharp/live_test_main.py +109 -0
- dev/tests/csharp/test_common.py +28 -0
- dev/tests/csharp/test_description.py +684 -0
- dev/tests/csharp/test_main.py +129 -0
- dev/tests/csharp/test_structure.py +93 -0
- dev/tests/csharp/test_verification.py +82 -0
- dev/tests/description.py +29 -0
- dev/tests/golang/__init__.py +0 -0
- dev/tests/golang/test_common.py +78 -0
- dev/tests/golang/test_main.py +128 -0
- dev/tests/infer_for_schema/__init__.py +0 -0
- dev/tests/infer_for_schema/common.py +47 -0
- dev/tests/infer_for_schema/test_len_on_properties.py +955 -0
- dev/tests/infer_for_schema/test_len_on_self.py +580 -0
- dev/tests/infer_for_schema/test_patterns_on_properties.py +686 -0
- dev/tests/infer_for_schema/test_patterns_on_self.py +258 -0
- dev/tests/infer_for_schema/test_property_in_set_of_enumeration_literals.py +600 -0
- dev/tests/infer_for_schema/test_property_in_set_of_primitives.py +549 -0
- dev/tests/intermediate/__init__.py +0 -0
- dev/tests/intermediate/test_constructor.py +719 -0
- dev/tests/intermediate/test_hierarchy.py +221 -0
- dev/tests/intermediate/test_revm.py +134 -0
- dev/tests/intermediate/test_translate.py +337 -0
- dev/tests/intermediate/test_type_inference.py +333 -0
- dev/tests/intermediate/test_types.py +169 -0
- dev/tests/java/__init__.py +0 -0
- dev/tests/java/test_common.py +20 -0
- dev/tests/java/test_description.py +128 -0
- dev/tests/java/test_main.py +234 -0
- dev/tests/jsonld_context/test_main.py +79 -0
- dev/tests/opcua/__init__.py +3 -0
- dev/tests/opcua/test_main.py +110 -0
- dev/tests/our_jsonschema/__init__.py +3 -0
- dev/tests/our_jsonschema/test_main.py +232 -0
- dev/tests/parse/__init__.py +0 -0
- dev/tests/parse/test_parse.py +503 -0
- dev/tests/parse/test_retree.py +272 -0
- dev/tests/proto/__init__.py +0 -0
- dev/tests/proto/test_main.py +112 -0
- dev/tests/python/__init__.py +0 -0
- dev/tests/python/test_common.py +124 -0
- dev/tests/python/test_main.py +126 -0
- dev/tests/python/test_xml_playground.py +254 -0
- dev/tests/python_protobuf/__init__.py +0 -0
- dev/tests/python_protobuf/test_main.py +111 -0
- dev/tests/rdf_shacl/__init__.py +0 -0
- dev/tests/rdf_shacl/test_common.py +32 -0
- dev/tests/rdf_shacl/test_description.py +223 -0
- dev/tests/rdf_shacl/test_main.py +194 -0
- dev/tests/smoke/__init__.py +0 -0
- dev/tests/smoke/test_main.py +83 -0
- dev/tests/test_common.py +94 -0
- dev/tests/typescript/__init__.py +0 -0
- dev/tests/typescript/test_common.py +108 -0
- dev/tests/typescript/test_main.py +125 -0
- dev/tests/xsd/__init__.py +0 -0
- dev/tests/xsd/test_main.py +227 -0
- dev/tests/yielding/__init__.py +0 -0
- dev/tests/yielding/test_linear.py +558 -0
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
"""Render descriptions to Java documentation comments."""
|
|
2
|
+
import dataclasses
|
|
3
|
+
import html
|
|
4
|
+
import io
|
|
5
|
+
import textwrap
|
|
6
|
+
import urllib.parse
|
|
7
|
+
from typing import (
|
|
8
|
+
Tuple,
|
|
9
|
+
Optional,
|
|
10
|
+
List,
|
|
11
|
+
Sequence,
|
|
12
|
+
Final,
|
|
13
|
+
Union,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
import docutils.nodes
|
|
17
|
+
import docutils.utils
|
|
18
|
+
from icontract import require
|
|
19
|
+
|
|
20
|
+
from aas_core_codegen import intermediate
|
|
21
|
+
from aas_core_codegen.common import (
|
|
22
|
+
Stripped,
|
|
23
|
+
Error,
|
|
24
|
+
assert_never,
|
|
25
|
+
Identifier,
|
|
26
|
+
)
|
|
27
|
+
from aas_core_codegen.intermediate import (
|
|
28
|
+
doc as intermediate_doc,
|
|
29
|
+
)
|
|
30
|
+
from aas_core_codegen.java import (
|
|
31
|
+
common as java_common,
|
|
32
|
+
naming as java_naming,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Context:
|
|
37
|
+
"""Structure the context of the rendering of a description."""
|
|
38
|
+
|
|
39
|
+
#: Fully qualified dot-path to the base package
|
|
40
|
+
root_package: Final[java_common.PackageIdentifier]
|
|
41
|
+
|
|
42
|
+
#: Scope in which the description resides.
|
|
43
|
+
#:
|
|
44
|
+
#: This narrows down the outer scope of the description, while the description
|
|
45
|
+
#: does not necessarily describe a class, but can also describe a method,
|
|
46
|
+
#: a property, an enumeration literal *etc.*
|
|
47
|
+
cls_or_enum: Final[
|
|
48
|
+
Optional[Union[intermediate.ClassUnion, intermediate.Enumeration]]
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
package: java_common.PackageIdentifier,
|
|
54
|
+
cls_or_enum: Optional[Union[intermediate.ClassUnion, intermediate.Enumeration]],
|
|
55
|
+
) -> None:
|
|
56
|
+
"""Initialize with the given values."""
|
|
57
|
+
self.root_package = package
|
|
58
|
+
self.cls_or_enum = cls_or_enum
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# NOTE (mristin, 2024-03-28):
|
|
62
|
+
# The Javadoc markup is a bit peculiar. In many cases, it requires only the opening
|
|
63
|
+
# tag, and tolerates (or even encourages) omission of the closing tag. Consequently,
|
|
64
|
+
# this allows us to model the text flow operations as a list of tokens (instead, say,
|
|
65
|
+
# a more complex document tree).
|
|
66
|
+
#
|
|
67
|
+
# At this point, we only care about the text flow (*i.e.*, line breaks, bullets,
|
|
68
|
+
# and beginnings of the paragraphs). To keep it all simple, we ignore all the other
|
|
69
|
+
# Javadoc tags which do not affect the text flow, and capture them in plain text.
|
|
70
|
+
|
|
71
|
+
# NOTE (mristin, 2024-03-28):
|
|
72
|
+
# We make all token classes as data classes so that the comparisons and
|
|
73
|
+
# string representations are automatically generated.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclasses.dataclass
|
|
77
|
+
class _TokenText:
|
|
78
|
+
"""Model rendered description text, except any text flow operation."""
|
|
79
|
+
|
|
80
|
+
content: str
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclasses.dataclass
|
|
84
|
+
class _TokenULOpen:
|
|
85
|
+
"""Capture a beginning of an unordered list."""
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclasses.dataclass
|
|
89
|
+
class _TokenULClose:
|
|
90
|
+
"""Capture the end an unordered list."""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclasses.dataclass
|
|
94
|
+
class _TokenLI:
|
|
95
|
+
"""Capture a beginning of a list item."""
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@dataclasses.dataclass
|
|
99
|
+
class _TokenP:
|
|
100
|
+
"""Capture a beginning of a paragraph."""
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
_Token = Union[_TokenText, _TokenULOpen, _TokenULClose, _TokenLI, _TokenP]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class _ElementRenderer(intermediate_doc.DocutilsElementTransformer[List[_Token]]):
|
|
107
|
+
"""Render descriptions as a content of a docstring."""
|
|
108
|
+
|
|
109
|
+
def __init__(self, context: Context) -> None:
|
|
110
|
+
"""Initialize with the given values."""
|
|
111
|
+
self.context = context
|
|
112
|
+
|
|
113
|
+
def transform_text(
|
|
114
|
+
self, element: docutils.nodes.Text
|
|
115
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
116
|
+
return [
|
|
117
|
+
_TokenText(
|
|
118
|
+
element.astext()
|
|
119
|
+
.replace("&", "&")
|
|
120
|
+
.replace("<", "<")
|
|
121
|
+
.replace(">", ">")
|
|
122
|
+
)
|
|
123
|
+
], None
|
|
124
|
+
|
|
125
|
+
def transform_reference_to_our_type_in_doc(
|
|
126
|
+
self, element: intermediate_doc.ReferenceToOurType
|
|
127
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
128
|
+
reference: Stripped
|
|
129
|
+
|
|
130
|
+
if isinstance(element.our_type, intermediate.Enumeration):
|
|
131
|
+
name = java_naming.enum_name(element.our_type.name)
|
|
132
|
+
reference = Stripped(
|
|
133
|
+
f"{{@link {self.context.root_package}.types.enums.{name}}}"
|
|
134
|
+
)
|
|
135
|
+
elif isinstance(element.our_type, intermediate.ConstrainedPrimitive):
|
|
136
|
+
# NOTE (mristin, 2024-03-27):
|
|
137
|
+
# We do not generate a class for constrained primitives, but we
|
|
138
|
+
# leave it as class name, as that is what we used for ``verify*`` functions.
|
|
139
|
+
name = java_naming.class_name(element.our_type.name)
|
|
140
|
+
reference = Stripped(f"@{{code {name}}}")
|
|
141
|
+
elif isinstance(element.our_type, intermediate.AbstractClass):
|
|
142
|
+
# NOTE (empwilli, 2023-12-14):
|
|
143
|
+
# We do not generate Java code for abstract classes, so we have to refer
|
|
144
|
+
# to the interface.
|
|
145
|
+
name = java_naming.interface_name(element.our_type.name)
|
|
146
|
+
reference = Stripped(
|
|
147
|
+
f"{{@link {self.context.root_package}.types.model.{name}}}"
|
|
148
|
+
)
|
|
149
|
+
elif isinstance(element.our_type, intermediate.ConcreteClass):
|
|
150
|
+
# NOTE (empwilli, 2023-12-14):
|
|
151
|
+
# Though a concrete class can have multiple descendants and the writer
|
|
152
|
+
# might actually want to refer to the *interface* instead of
|
|
153
|
+
# the concrete class, we do the best effort here and resolve it to the
|
|
154
|
+
# name of the concrete class.
|
|
155
|
+
name = java_naming.class_name(element.our_type.name)
|
|
156
|
+
reference = Stripped(
|
|
157
|
+
f"{{@link {self.context.root_package}.types.impl.{name}}}"
|
|
158
|
+
)
|
|
159
|
+
else:
|
|
160
|
+
assert_never(element.our_type)
|
|
161
|
+
|
|
162
|
+
return [_TokenText(reference)], None
|
|
163
|
+
|
|
164
|
+
def transform_reference_to_attribute_in_doc(
|
|
165
|
+
self, element: intermediate_doc.ReferenceToAttribute
|
|
166
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
167
|
+
if isinstance(element.reference, intermediate_doc.ReferenceToProperty):
|
|
168
|
+
getter_name = java_naming.getter_name(element.reference.prop.name)
|
|
169
|
+
|
|
170
|
+
if element.reference.cls is self.context.cls_or_enum:
|
|
171
|
+
return [_TokenText(f"{{@link #{getter_name}()}}")], None
|
|
172
|
+
|
|
173
|
+
base: Stripped
|
|
174
|
+
if isinstance(element.reference.cls, intermediate.AbstractClass):
|
|
175
|
+
# NOTE (empwilli, 2023-12-14):
|
|
176
|
+
# We do not generate Java code for abstract classes, so we have to refer
|
|
177
|
+
# to the interface.
|
|
178
|
+
interface_name = java_naming.interface_name(element.reference.cls.name)
|
|
179
|
+
base = Stripped(f"types.model.{interface_name}")
|
|
180
|
+
elif isinstance(element.reference.cls, intermediate.ConcreteClass):
|
|
181
|
+
# NOTE (empwilli, 2023-12-14):
|
|
182
|
+
# Though a concrete class can have multiple descendants and the writer
|
|
183
|
+
# might actually want to refer to the *interface* instead of
|
|
184
|
+
# the concrete class, we do the best effort here and resolve it to the
|
|
185
|
+
# name of the concrete class.
|
|
186
|
+
cls_name = java_naming.class_name(element.reference.cls.name)
|
|
187
|
+
base = Stripped(f"types.impl.{cls_name}")
|
|
188
|
+
else:
|
|
189
|
+
assert_never(element.reference.cls)
|
|
190
|
+
|
|
191
|
+
return [
|
|
192
|
+
_TokenText(
|
|
193
|
+
f"{{@link {self.context.root_package}.{base}#{getter_name}()}}"
|
|
194
|
+
)
|
|
195
|
+
], None
|
|
196
|
+
|
|
197
|
+
elif isinstance(
|
|
198
|
+
element.reference, intermediate_doc.ReferenceToEnumerationLiteral
|
|
199
|
+
):
|
|
200
|
+
literal_name = java_naming.enum_literal_name(element.reference.literal.name)
|
|
201
|
+
|
|
202
|
+
if element.reference.enumeration is self.context.cls_or_enum:
|
|
203
|
+
return [_TokenText(f"{{@link #{literal_name}}}")], None
|
|
204
|
+
|
|
205
|
+
enum_name = java_naming.enum_name(element.reference.enumeration.name)
|
|
206
|
+
|
|
207
|
+
return [
|
|
208
|
+
_TokenText(
|
|
209
|
+
f"{{@link {self.context.root_package}.types.enums"
|
|
210
|
+
f".{enum_name}#{literal_name}}}"
|
|
211
|
+
)
|
|
212
|
+
], None
|
|
213
|
+
else:
|
|
214
|
+
assert_never(element.reference)
|
|
215
|
+
|
|
216
|
+
def transform_reference_to_argument_in_doc(
|
|
217
|
+
self, element: intermediate_doc.ReferenceToArgument
|
|
218
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
219
|
+
arg_name = java_naming.argument_name(Identifier(element.reference))
|
|
220
|
+
return [_TokenText(f"{{@code {arg_name}}}")], None
|
|
221
|
+
|
|
222
|
+
def transform_reference_to_constraint_in_doc(
|
|
223
|
+
self, element: intermediate_doc.ReferenceToConstraint
|
|
224
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
225
|
+
assert isinstance(element.reference, str)
|
|
226
|
+
|
|
227
|
+
return [_TokenText(f"Constraint {element.reference}")], None
|
|
228
|
+
|
|
229
|
+
def transform_reference_to_constant_in_doc(
|
|
230
|
+
self, element: intermediate_doc.ReferenceToConstant
|
|
231
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
232
|
+
name = java_naming.property_name(element.constant.name)
|
|
233
|
+
|
|
234
|
+
return [
|
|
235
|
+
_TokenText(
|
|
236
|
+
f"{{@link {self.context.root_package}.constants.Constants#{name}}}"
|
|
237
|
+
)
|
|
238
|
+
], None
|
|
239
|
+
|
|
240
|
+
def transform_literal(
|
|
241
|
+
self, element: docutils.nodes.literal
|
|
242
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
243
|
+
# NOTE (mristin, 2024-03-27):
|
|
244
|
+
# Theoretically, we could escape the backticks properly here, see
|
|
245
|
+
# https://meta.stackexchange.com/questions/82718/how-do-i-escape-a-backtick-within-in-line-code-in-markdown.
|
|
246
|
+
# However, this is not necessary since our meta-model is written in
|
|
247
|
+
# Python, and escaping backticks in ReST is not well-defined. For now, we simply
|
|
248
|
+
# assume no backticks.
|
|
249
|
+
#
|
|
250
|
+
# See: https://stackoverflow.com/questions/66435475/how-to-escape-the-backtick-character-in-a-rst-file
|
|
251
|
+
text = element.astext()
|
|
252
|
+
assert "`" not in text, (
|
|
253
|
+
"(mristin, 2024-03-27): Theoretically, we could escape the backticks "
|
|
254
|
+
"properly here, see [how to escape backticks in markdown].\n\n"
|
|
255
|
+
"However, this is not necessary as our meta-model is written in Python, "
|
|
256
|
+
"and escaping backticks in ReST is not well-defined, see [how to escape "
|
|
257
|
+
"backticks in ReST]. At this moment, we simply assume no backticks in the "
|
|
258
|
+
"code literals.\n\n"
|
|
259
|
+
"[how to escape backticks in markdown]: https://meta.stackexchange.com/"
|
|
260
|
+
"questions/82718/how-do-i-escape-a-backtick-within-in-line-"
|
|
261
|
+
"code-in-markdown\n"
|
|
262
|
+
"[how to escape backticks in ReST]: https://stackoverflow.com/questions/"
|
|
263
|
+
"66435475/how-to-escape-the-backtick-character-in-a-rst-file"
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
escaped = (
|
|
267
|
+
text
|
|
268
|
+
# NOTE (mristin, 2024-03-27):
|
|
269
|
+
# See: https://stackoverflow.com/questions/2290757/how-can-you-escape-the-character-in-javadoc
|
|
270
|
+
.replace("@", "@")
|
|
271
|
+
)
|
|
272
|
+
return [_TokenText(f"{{@code {escaped}}}")], None
|
|
273
|
+
|
|
274
|
+
def _render_children(
|
|
275
|
+
self,
|
|
276
|
+
children: Sequence[docutils.nodes.Element],
|
|
277
|
+
prefix: Optional[_Token] = None,
|
|
278
|
+
suffix: Optional[_Token] = None,
|
|
279
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
280
|
+
"""
|
|
281
|
+
Render the children and concatenate the resulting tokens.
|
|
282
|
+
|
|
283
|
+
If ``prefix`` token is defined, it will be prepended to the result.
|
|
284
|
+
|
|
285
|
+
If ``suffix`` token is defined, it will be appended to the result
|
|
286
|
+
"""
|
|
287
|
+
result = [] # type: List[_Token]
|
|
288
|
+
|
|
289
|
+
if prefix is not None:
|
|
290
|
+
result.append(prefix)
|
|
291
|
+
|
|
292
|
+
errors = [] # type: List[str]
|
|
293
|
+
|
|
294
|
+
for child in children:
|
|
295
|
+
tokens, child_errors = self.transform(child)
|
|
296
|
+
if child_errors is not None:
|
|
297
|
+
errors.extend(child_errors)
|
|
298
|
+
continue
|
|
299
|
+
|
|
300
|
+
assert tokens is not None
|
|
301
|
+
result.extend(tokens)
|
|
302
|
+
|
|
303
|
+
if len(errors) > 0:
|
|
304
|
+
return None, errors
|
|
305
|
+
|
|
306
|
+
if suffix is not None:
|
|
307
|
+
result.append(suffix)
|
|
308
|
+
|
|
309
|
+
return result, None
|
|
310
|
+
|
|
311
|
+
def transform_paragraph(
|
|
312
|
+
self, element: docutils.nodes.paragraph
|
|
313
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
314
|
+
return self._render_children(children=element.children, prefix=_TokenP())
|
|
315
|
+
|
|
316
|
+
def transform_emphasis(
|
|
317
|
+
self, element: docutils.nodes.emphasis
|
|
318
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
319
|
+
return self._render_children(
|
|
320
|
+
children=element.children,
|
|
321
|
+
prefix=_TokenText("<em>"),
|
|
322
|
+
suffix=_TokenText("</em>"),
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
def transform_list_item(
|
|
326
|
+
self, element: docutils.nodes.list_item
|
|
327
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
328
|
+
return self._render_children(element.children)
|
|
329
|
+
|
|
330
|
+
def transform_bullet_list(
|
|
331
|
+
self, element: docutils.nodes.bullet_list
|
|
332
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
333
|
+
result = [_TokenULOpen()] # type: List[_Token]
|
|
334
|
+
|
|
335
|
+
errors = [] # type: List[str]
|
|
336
|
+
|
|
337
|
+
for child in element.children:
|
|
338
|
+
assert isinstance(child, docutils.nodes.list_item), (
|
|
339
|
+
f"Expected a list item in the bullet list, "
|
|
340
|
+
f"but got an instance of {type(child)}: {child}"
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
child_tokens, child_errors = self.transform(child)
|
|
344
|
+
if child_errors is not None:
|
|
345
|
+
errors.extend(child_errors)
|
|
346
|
+
continue
|
|
347
|
+
|
|
348
|
+
assert child_tokens is not None
|
|
349
|
+
result.append(_TokenLI())
|
|
350
|
+
result.extend(child_tokens)
|
|
351
|
+
|
|
352
|
+
result.append(_TokenULClose())
|
|
353
|
+
|
|
354
|
+
if len(errors) > 0:
|
|
355
|
+
return None, errors
|
|
356
|
+
|
|
357
|
+
return result, None
|
|
358
|
+
|
|
359
|
+
def transform_note(
|
|
360
|
+
self, element: docutils.nodes.note
|
|
361
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
362
|
+
return self._render_children(children=element.children, prefix=_TokenP())
|
|
363
|
+
|
|
364
|
+
def transform_reference(
|
|
365
|
+
self, element: docutils.nodes.reference
|
|
366
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
367
|
+
text = element.astext()
|
|
368
|
+
escaped_for_href = urllib.parse.quote(element.astext())
|
|
369
|
+
escaped_for_html = html.escape(text)
|
|
370
|
+
return [
|
|
371
|
+
_TokenText(f"<a href='{escaped_for_href}'>{escaped_for_html}</a>")
|
|
372
|
+
], None
|
|
373
|
+
|
|
374
|
+
def transform_field_body(
|
|
375
|
+
self, element: docutils.nodes.field_body
|
|
376
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
377
|
+
return self._render_children(element.children)
|
|
378
|
+
|
|
379
|
+
def transform_document(
|
|
380
|
+
self, element: docutils.nodes.document
|
|
381
|
+
) -> Tuple[Optional[List[_Token]], Optional[List[str]]]:
|
|
382
|
+
return self._render_children(element.children)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
def _remove_redundant_p(tokens: List[_Token]) -> List[_Token]:
|
|
386
|
+
"""Remove redundant chains of ``<p>`` tokens."""
|
|
387
|
+
result = [] # type: List[_Token]
|
|
388
|
+
|
|
389
|
+
# region Remove consecutive ``<p>``
|
|
390
|
+
last_token = None # type: Optional[_Token]
|
|
391
|
+
for token in tokens:
|
|
392
|
+
if (
|
|
393
|
+
last_token is not None
|
|
394
|
+
and isinstance(last_token, _TokenP)
|
|
395
|
+
and isinstance(token, _TokenP)
|
|
396
|
+
):
|
|
397
|
+
continue
|
|
398
|
+
|
|
399
|
+
result.append(token)
|
|
400
|
+
last_token = token
|
|
401
|
+
# endregion
|
|
402
|
+
|
|
403
|
+
# region Remove trailing ``<p>``
|
|
404
|
+
cutoff = 0
|
|
405
|
+
for token in reversed(result):
|
|
406
|
+
if not isinstance(token, _TokenP):
|
|
407
|
+
break
|
|
408
|
+
|
|
409
|
+
cutoff += 1
|
|
410
|
+
|
|
411
|
+
result = result[: len(result) - cutoff]
|
|
412
|
+
# endregion
|
|
413
|
+
|
|
414
|
+
return result
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def _strip_prefix_p(tokens: List[_Token]) -> List[_Token]:
|
|
418
|
+
"""Strip the ``<p>`` from ``tokens`` if they start with such a token."""
|
|
419
|
+
if len(tokens) == 0:
|
|
420
|
+
return tokens
|
|
421
|
+
|
|
422
|
+
if isinstance(tokens[0], _TokenP):
|
|
423
|
+
return tokens[1:]
|
|
424
|
+
|
|
425
|
+
return tokens
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def _add_prefix_p_if_necessary(tokens: List[_Token]) -> List[_Token]:
|
|
429
|
+
"""Add a ``<p>`` at the beginning if the ``tokens`` do not start with a re-flow."""
|
|
430
|
+
if len(tokens) == 0:
|
|
431
|
+
return tokens
|
|
432
|
+
|
|
433
|
+
if isinstance(tokens[0], (_TokenP, _TokenULOpen)):
|
|
434
|
+
return tokens
|
|
435
|
+
|
|
436
|
+
return [_TokenP()] + tokens
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
@dataclasses.dataclass
|
|
440
|
+
class _TextBlock:
|
|
441
|
+
"""Model a text block in the indented output, to be joined with empty strings."""
|
|
442
|
+
|
|
443
|
+
text: str
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
class _RelativeIndention:
|
|
447
|
+
"""
|
|
448
|
+
Represent the relative indention.
|
|
449
|
+
|
|
450
|
+
Since the indention is *relative*, it can be either positive or negative.
|
|
451
|
+
"""
|
|
452
|
+
|
|
453
|
+
@require(lambda direction: direction in (-1, 1))
|
|
454
|
+
def __init__(self, direction: int) -> None:
|
|
455
|
+
self.direction = direction
|
|
456
|
+
|
|
457
|
+
def __repr__(self) -> str:
|
|
458
|
+
"""Generate text representation for easier debugging."""
|
|
459
|
+
return f"{self.__class__.__name__}({self.direction!r})"
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
_TextDirective = Union[_TextBlock, _RelativeIndention]
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
class _IndentionMachine:
|
|
466
|
+
"""Write the text to a buffer, considering the indention."""
|
|
467
|
+
|
|
468
|
+
def __init__(self, indention: str = " ") -> None:
|
|
469
|
+
self._indention_level = 0
|
|
470
|
+
self._buffer: List[_TextDirective] = []
|
|
471
|
+
self.indention = indention
|
|
472
|
+
|
|
473
|
+
def write(self, text: str) -> None:
|
|
474
|
+
"""Direct a write of text onto the buffer."""
|
|
475
|
+
self._buffer.append(_TextBlock(text))
|
|
476
|
+
|
|
477
|
+
def indent(self) -> None:
|
|
478
|
+
"""Direct an indention onto the buffer."""
|
|
479
|
+
self._indention_level += 1
|
|
480
|
+
self._buffer.append(_RelativeIndention(direction=1))
|
|
481
|
+
|
|
482
|
+
def dedent(self) -> None:
|
|
483
|
+
"""Direct a dedention onto the buffer."""
|
|
484
|
+
self._indention_level -= 1
|
|
485
|
+
if self._indention_level < 0:
|
|
486
|
+
raise ValueError("Unexpected negative indention")
|
|
487
|
+
|
|
488
|
+
self._buffer.append(_RelativeIndention(direction=-1))
|
|
489
|
+
|
|
490
|
+
def render(self) -> str:
|
|
491
|
+
"""Render the buffer as indented text."""
|
|
492
|
+
level = 0
|
|
493
|
+
pending_text_blocks = [] # type: List[_TextBlock]
|
|
494
|
+
|
|
495
|
+
writer = io.StringIO()
|
|
496
|
+
|
|
497
|
+
for directive in self._buffer:
|
|
498
|
+
if isinstance(directive, _TextBlock):
|
|
499
|
+
pending_text_blocks.append(directive)
|
|
500
|
+
|
|
501
|
+
elif isinstance(directive, _RelativeIndention):
|
|
502
|
+
writer.write(
|
|
503
|
+
textwrap.indent(
|
|
504
|
+
"".join(block.text for block in pending_text_blocks),
|
|
505
|
+
self.indention * level,
|
|
506
|
+
)
|
|
507
|
+
)
|
|
508
|
+
level += directive.direction
|
|
509
|
+
if level < 0:
|
|
510
|
+
raise AssertionError(
|
|
511
|
+
"Unexpected indention level below zero; "
|
|
512
|
+
"expected to catch this in ``dedent()``"
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
pending_text_blocks = []
|
|
516
|
+
else:
|
|
517
|
+
assert_never(directive)
|
|
518
|
+
|
|
519
|
+
if len(pending_text_blocks) > 0:
|
|
520
|
+
writer.write(
|
|
521
|
+
textwrap.indent(
|
|
522
|
+
"".join(block.text for block in pending_text_blocks),
|
|
523
|
+
self.indention * level,
|
|
524
|
+
)
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
return writer.getvalue()
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
def _render_tokens(tokens: Sequence[_Token]) -> str:
|
|
531
|
+
"""Render the output tokens as text."""
|
|
532
|
+
if len(tokens) == 0:
|
|
533
|
+
return ""
|
|
534
|
+
|
|
535
|
+
indention_machine = _IndentionMachine()
|
|
536
|
+
|
|
537
|
+
for i, token in enumerate(tokens):
|
|
538
|
+
if isinstance(token, _TokenText):
|
|
539
|
+
indention_machine.write(token.content)
|
|
540
|
+
|
|
541
|
+
elif isinstance(token, _TokenP):
|
|
542
|
+
if i > 0:
|
|
543
|
+
indention_machine.write("\n\n")
|
|
544
|
+
|
|
545
|
+
indention_machine.write("<p>")
|
|
546
|
+
|
|
547
|
+
elif isinstance(token, _TokenULOpen):
|
|
548
|
+
if i > 0:
|
|
549
|
+
indention_machine.write("\n\n")
|
|
550
|
+
|
|
551
|
+
indention_machine.write("<ul>")
|
|
552
|
+
indention_machine.indent()
|
|
553
|
+
elif isinstance(token, _TokenULClose):
|
|
554
|
+
indention_machine.dedent()
|
|
555
|
+
indention_machine.write("\n</ul>")
|
|
556
|
+
elif isinstance(token, _TokenLI):
|
|
557
|
+
# NOTE (mristin, 2024-03-28):
|
|
558
|
+
# We add a space after ``<li>`` for better readability of the code in, say,
|
|
559
|
+
# a text editor.
|
|
560
|
+
indention_machine.write("\n<li> ")
|
|
561
|
+
else:
|
|
562
|
+
assert_never(token)
|
|
563
|
+
|
|
564
|
+
return indention_machine.render()
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
def documentation_comment(text: Stripped) -> Stripped:
|
|
568
|
+
"""Generate a documentation comment out of the text."""
|
|
569
|
+
lines = text.splitlines()
|
|
570
|
+
writer = io.StringIO()
|
|
571
|
+
writer.write("/**\n")
|
|
572
|
+
for line in lines:
|
|
573
|
+
if len(line.strip()) > 0:
|
|
574
|
+
writer.write(f" * {line}\n")
|
|
575
|
+
else:
|
|
576
|
+
writer.write(" *\n")
|
|
577
|
+
|
|
578
|
+
writer.write(" */")
|
|
579
|
+
|
|
580
|
+
return Stripped(writer.getvalue())
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def _post_process_summary(tokens: List[_Token]) -> List[_Token]:
|
|
584
|
+
"""Perform the post-processing steps for the summary tokens."""
|
|
585
|
+
return _remove_redundant_p(_strip_prefix_p(tokens))
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def _post_process_remark(tokens: List[_Token]) -> List[_Token]:
|
|
589
|
+
"""Perform the post-processing steps for the remark tokens."""
|
|
590
|
+
return _remove_redundant_p(_add_prefix_p_if_necessary(tokens))
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
def _generate_summary_remarks(
|
|
594
|
+
description: intermediate.SummaryRemarksDescription, context: Context
|
|
595
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
596
|
+
"""Generate the documentation comment for a summary-remarks."""
|
|
597
|
+
errors = [] # type: List[str]
|
|
598
|
+
|
|
599
|
+
renderer = _ElementRenderer(context=context)
|
|
600
|
+
|
|
601
|
+
tokens = [] # type: List[_Token]
|
|
602
|
+
|
|
603
|
+
summary_tokens, summary_errors = renderer.transform(description.summary)
|
|
604
|
+
if summary_errors is not None:
|
|
605
|
+
errors.extend(summary_errors)
|
|
606
|
+
else:
|
|
607
|
+
assert summary_tokens is not None
|
|
608
|
+
tokens.extend(_post_process_summary(summary_tokens))
|
|
609
|
+
|
|
610
|
+
for remark in description.remarks:
|
|
611
|
+
remark_tokens, remark_errors = renderer.transform(remark)
|
|
612
|
+
if remark_errors:
|
|
613
|
+
errors.extend(remark_errors)
|
|
614
|
+
else:
|
|
615
|
+
assert remark_tokens is not None
|
|
616
|
+
tokens.extend(_post_process_remark(remark_tokens))
|
|
617
|
+
|
|
618
|
+
if len(errors) > 0:
|
|
619
|
+
return None, [
|
|
620
|
+
Error(description.parsed.node, error_message) for error_message in errors
|
|
621
|
+
]
|
|
622
|
+
|
|
623
|
+
return documentation_comment(Stripped(_render_tokens(tokens))), None
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
def _generate_summary_remarks_constraints(
|
|
627
|
+
description: intermediate.SummaryRemarksConstraintsDescription, context: Context
|
|
628
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
629
|
+
"""Generate the documentation comment for a summary-remarks-constraints."""
|
|
630
|
+
errors = [] # type: List[str]
|
|
631
|
+
|
|
632
|
+
renderer = _ElementRenderer(context=context)
|
|
633
|
+
|
|
634
|
+
tokens = [] # type: List[_Token]
|
|
635
|
+
|
|
636
|
+
summary_tokens, summary_errors = renderer.transform(description.summary)
|
|
637
|
+
if summary_errors is not None:
|
|
638
|
+
errors.extend(summary_errors)
|
|
639
|
+
else:
|
|
640
|
+
assert summary_tokens is not None
|
|
641
|
+
tokens.extend(_post_process_summary(summary_tokens))
|
|
642
|
+
|
|
643
|
+
for remark in description.remarks:
|
|
644
|
+
remark_tokens, remark_errors = renderer.transform(remark)
|
|
645
|
+
if remark_errors:
|
|
646
|
+
errors.extend(remark_errors)
|
|
647
|
+
else:
|
|
648
|
+
assert remark_tokens is not None
|
|
649
|
+
tokens.extend(_post_process_remark(remark_tokens))
|
|
650
|
+
|
|
651
|
+
if len(description.constraints_by_identifier) > 0:
|
|
652
|
+
tokens.append(_TokenP())
|
|
653
|
+
tokens.append(_TokenText("Constraints:"))
|
|
654
|
+
|
|
655
|
+
tokens.append(_TokenULOpen())
|
|
656
|
+
|
|
657
|
+
for constraint_id, constraint in description.constraints_by_identifier.items():
|
|
658
|
+
constraint_tokens, constraint_errors = renderer.transform(constraint)
|
|
659
|
+
if constraint_errors is not None:
|
|
660
|
+
errors.extend(constraint_errors)
|
|
661
|
+
else:
|
|
662
|
+
assert constraint_tokens is not None
|
|
663
|
+
tokens.append(_TokenLI())
|
|
664
|
+
tokens.append(_TokenText(f"Constraint {constraint_id}:\n"))
|
|
665
|
+
tokens.extend(_strip_prefix_p(_remove_redundant_p(constraint_tokens)))
|
|
666
|
+
|
|
667
|
+
tokens.append(_TokenULClose())
|
|
668
|
+
|
|
669
|
+
if len(errors) > 0:
|
|
670
|
+
return None, [
|
|
671
|
+
Error(description.parsed.node, error_message) for error_message in errors
|
|
672
|
+
]
|
|
673
|
+
|
|
674
|
+
return documentation_comment(Stripped(_render_tokens(tokens))), None
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
def generate_comment_for_enumeration_literal(
|
|
678
|
+
description: intermediate.DescriptionOfEnumerationLiteral, context: Context
|
|
679
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
680
|
+
"""Generate the documentation comment for the given enumeration literal."""
|
|
681
|
+
return _generate_summary_remarks(description=description, context=context)
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
def generate_comment_for_our_type(
|
|
685
|
+
description: intermediate.DescriptionOfOurType, context: Context
|
|
686
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
687
|
+
"""Generate the documentation comment for our type."""
|
|
688
|
+
return _generate_summary_remarks_constraints(
|
|
689
|
+
description=description, context=context
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
def generate_comment_for_property(
|
|
694
|
+
description: intermediate.DescriptionOfProperty, context: Context
|
|
695
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
696
|
+
"""Generate the documentation comment for the given property."""
|
|
697
|
+
return _generate_summary_remarks_constraints(
|
|
698
|
+
description=description, context=context
|
|
699
|
+
)
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
def generate_comment_for_signature(
|
|
703
|
+
description: intermediate.DescriptionOfSignature, context: Context
|
|
704
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
705
|
+
"""
|
|
706
|
+
Generate the docstring for the given signature.
|
|
707
|
+
|
|
708
|
+
A signature, in this context, means a function or a method signature.
|
|
709
|
+
"""
|
|
710
|
+
errors = [] # type: List[str]
|
|
711
|
+
|
|
712
|
+
renderer = _ElementRenderer(context=context)
|
|
713
|
+
|
|
714
|
+
tokens = [] # type: List[_Token]
|
|
715
|
+
|
|
716
|
+
summary_tokens, summary_errors = renderer.transform(description.summary)
|
|
717
|
+
if summary_errors is not None:
|
|
718
|
+
errors.extend(summary_errors)
|
|
719
|
+
else:
|
|
720
|
+
assert summary_tokens is not None
|
|
721
|
+
tokens.extend(_post_process_summary(summary_tokens))
|
|
722
|
+
|
|
723
|
+
for remark in description.remarks:
|
|
724
|
+
remark_tokens, remark_errors = renderer.transform(remark)
|
|
725
|
+
if remark_errors:
|
|
726
|
+
errors.extend(remark_errors)
|
|
727
|
+
else:
|
|
728
|
+
assert remark_tokens is not None
|
|
729
|
+
tokens.extend(_post_process_remark(remark_tokens))
|
|
730
|
+
|
|
731
|
+
blocks = [] # type: List[Stripped]
|
|
732
|
+
|
|
733
|
+
summary_remarks = _render_tokens(tokens)
|
|
734
|
+
|
|
735
|
+
if len(summary_remarks) > 0:
|
|
736
|
+
blocks.append(Stripped(summary_remarks))
|
|
737
|
+
|
|
738
|
+
param_and_return_blocks = [] # type: List[str]
|
|
739
|
+
for arg_name, arg_description in description.arguments_by_name.items():
|
|
740
|
+
arg_tokens, arg_errors = renderer.transform(arg_description)
|
|
741
|
+
if arg_errors is not None:
|
|
742
|
+
errors.extend(arg_errors)
|
|
743
|
+
continue
|
|
744
|
+
|
|
745
|
+
assert arg_tokens is not None
|
|
746
|
+
|
|
747
|
+
arg_description = _render_tokens(
|
|
748
|
+
_strip_prefix_p(_remove_redundant_p(arg_tokens))
|
|
749
|
+
)
|
|
750
|
+
|
|
751
|
+
param_and_return_blocks.append(Stripped(f"@param {arg_name} {arg_description}"))
|
|
752
|
+
|
|
753
|
+
if description.returns is not None:
|
|
754
|
+
returns_tokens, returns_errors = renderer.transform(description.returns)
|
|
755
|
+
if returns_errors is not None:
|
|
756
|
+
errors.extend(returns_errors)
|
|
757
|
+
else:
|
|
758
|
+
assert returns_tokens is not None
|
|
759
|
+
|
|
760
|
+
returns_description = _render_tokens(
|
|
761
|
+
_strip_prefix_p(_remove_redundant_p(returns_tokens))
|
|
762
|
+
)
|
|
763
|
+
|
|
764
|
+
param_and_return_blocks.append(Stripped(f"@return {returns_description}"))
|
|
765
|
+
|
|
766
|
+
if len(errors) > 0:
|
|
767
|
+
return None, [
|
|
768
|
+
Error(description.parsed.node, error_message) for error_message in errors
|
|
769
|
+
]
|
|
770
|
+
|
|
771
|
+
if len(param_and_return_blocks) > 0:
|
|
772
|
+
blocks.append(Stripped("\n".join(param_and_return_blocks)))
|
|
773
|
+
|
|
774
|
+
return documentation_comment(Stripped("\n\n".join(blocks))), None
|