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,1102 @@
|
|
|
1
|
+
"""Render descriptions to ProtoBuf documentation comments."""
|
|
2
|
+
|
|
3
|
+
import abc
|
|
4
|
+
import collections
|
|
5
|
+
import io
|
|
6
|
+
import itertools
|
|
7
|
+
import textwrap
|
|
8
|
+
import xml.sax.saxutils
|
|
9
|
+
from typing import (
|
|
10
|
+
Tuple,
|
|
11
|
+
Optional,
|
|
12
|
+
List,
|
|
13
|
+
OrderedDict,
|
|
14
|
+
Union,
|
|
15
|
+
Sequence,
|
|
16
|
+
TypeVar,
|
|
17
|
+
Iterator,
|
|
18
|
+
Iterable,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
import docutils.nodes
|
|
22
|
+
import docutils.parsers.rst.roles
|
|
23
|
+
import docutils.utils
|
|
24
|
+
from icontract import require, ensure, DBC
|
|
25
|
+
|
|
26
|
+
from aas_core_codegen import intermediate
|
|
27
|
+
from aas_core_codegen.common import (
|
|
28
|
+
Stripped,
|
|
29
|
+
Error,
|
|
30
|
+
assert_never,
|
|
31
|
+
Identifier,
|
|
32
|
+
assert_union_of_descendants_exhaustive,
|
|
33
|
+
assert_union_without_excluded,
|
|
34
|
+
)
|
|
35
|
+
from aas_core_codegen.protobuf import (
|
|
36
|
+
naming as proto_naming,
|
|
37
|
+
)
|
|
38
|
+
from aas_core_codegen.intermediate import (
|
|
39
|
+
doc as intermediate_doc,
|
|
40
|
+
_translate as intermediate_translate,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _Node(DBC):
|
|
45
|
+
"""Represent a node in an AST of a documentation comment."""
|
|
46
|
+
|
|
47
|
+
@abc.abstractmethod
|
|
48
|
+
def accept(self, visitor: "_NodeVisitor") -> None:
|
|
49
|
+
"""Accept the ``visitor`` and dispatch."""
|
|
50
|
+
raise NotImplementedError()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class _Text(_Node):
|
|
54
|
+
"""Represent a text node in a documentation comment."""
|
|
55
|
+
|
|
56
|
+
def __init__(self, content: str) -> None:
|
|
57
|
+
"""Initialize with the given values."""
|
|
58
|
+
self.content = content
|
|
59
|
+
|
|
60
|
+
def accept(self, visitor: "_NodeVisitor") -> None:
|
|
61
|
+
"""Accept the ``visitor`` and dispatch."""
|
|
62
|
+
visitor.visit_text(self)
|
|
63
|
+
|
|
64
|
+
def __repr__(self) -> str:
|
|
65
|
+
"""Generate a string representation for easier debugging."""
|
|
66
|
+
return f"{self.__class__.__name__}({self.content!r})"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class _List(_Node):
|
|
70
|
+
"""
|
|
71
|
+
Represent a sequence of nodes of a ProtoBuf documentation comment.
|
|
72
|
+
|
|
73
|
+
This is necessary so that we can render a concatenation where there is no
|
|
74
|
+
enclosing element.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
def __init__(self, items: List["_NodeUnion"]) -> None:
|
|
78
|
+
self.items = items
|
|
79
|
+
|
|
80
|
+
def accept(self, visitor: "_NodeVisitor") -> None:
|
|
81
|
+
"""Accept the ``visitor`` and dispatch."""
|
|
82
|
+
visitor.visit_list(self)
|
|
83
|
+
|
|
84
|
+
def __repr__(self) -> str:
|
|
85
|
+
"""Generate a string representation for easier debugging."""
|
|
86
|
+
if len(self.items) == 0:
|
|
87
|
+
return f"{self.__class__.__name__}([])"
|
|
88
|
+
|
|
89
|
+
writer = io.StringIO()
|
|
90
|
+
writer.write(f"{self.__class__.__name__}(\n")
|
|
91
|
+
writer.write(" [\n")
|
|
92
|
+
|
|
93
|
+
for i, item in enumerate(self.items):
|
|
94
|
+
if i > 0:
|
|
95
|
+
writer.write(",\n")
|
|
96
|
+
writer.write(textwrap.indent(repr(item), " "))
|
|
97
|
+
|
|
98
|
+
writer.write("\n ]\n)")
|
|
99
|
+
return writer.getvalue()
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class _Element(_Node):
|
|
103
|
+
"""Represent an element of a ProtoBuf documentation comment."""
|
|
104
|
+
|
|
105
|
+
def __init__(
|
|
106
|
+
self,
|
|
107
|
+
name: str,
|
|
108
|
+
attrs: Optional[OrderedDict[str, str]] = None,
|
|
109
|
+
children: Optional[_List] = None,
|
|
110
|
+
) -> None:
|
|
111
|
+
self.name = name
|
|
112
|
+
self.attrs = collections.OrderedDict() if attrs is None else attrs
|
|
113
|
+
self.children = _List(items=[]) if children is None else children
|
|
114
|
+
|
|
115
|
+
def accept(self, visitor: "_NodeVisitor") -> None:
|
|
116
|
+
"""Accept the ``visitor`` and dispatch."""
|
|
117
|
+
visitor.visit_element(self)
|
|
118
|
+
|
|
119
|
+
def __repr__(self) -> str:
|
|
120
|
+
"""Generate a string representation for easier debugging."""
|
|
121
|
+
indented_name = textwrap.indent(repr(self.name), " ")
|
|
122
|
+
indented_attrs = textwrap.indent(repr(self.attrs), " ")
|
|
123
|
+
indented_children = textwrap.indent(repr(self.children), " ")
|
|
124
|
+
|
|
125
|
+
return f"""\
|
|
126
|
+
{self.__class__.__name__}(
|
|
127
|
+
{indented_name},
|
|
128
|
+
{indented_attrs},
|
|
129
|
+
{indented_children}
|
|
130
|
+
)"""
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
_NodeUnion = Union[_Text, _Element, _List]
|
|
134
|
+
assert_union_of_descendants_exhaustive(base_class=_Node, union=_NodeUnion)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class _NodeVisitor:
|
|
138
|
+
def visit(self, node: _Node) -> None:
|
|
139
|
+
"""Visit *via* double-dispatch."""
|
|
140
|
+
node.accept(self)
|
|
141
|
+
|
|
142
|
+
def visit_text(self, node: _Text) -> None:
|
|
143
|
+
"""Visit the text node."""
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
def visit_list(self, node: _List) -> None:
|
|
147
|
+
"""Visit the node list and its items recursively."""
|
|
148
|
+
for item in node.items:
|
|
149
|
+
self.visit(item)
|
|
150
|
+
|
|
151
|
+
def visit_element(self, node: _Element) -> None:
|
|
152
|
+
"""Visit the element node and its children."""
|
|
153
|
+
self.visit(node.children)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class _ElementRenderer(intermediate_doc.DocutilsElementTransformer[_NodeUnion]):
|
|
157
|
+
"""Render descriptions as ProtoBuf docstring XML."""
|
|
158
|
+
|
|
159
|
+
def transform_text(
|
|
160
|
+
self, element: docutils.nodes.Text
|
|
161
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
162
|
+
return _Text(element.astext()), None
|
|
163
|
+
|
|
164
|
+
def transform_reference_to_our_type_in_doc(
|
|
165
|
+
self, element: intermediate_doc.ReferenceToOurType
|
|
166
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
167
|
+
name: str
|
|
168
|
+
|
|
169
|
+
if isinstance(element.our_type, intermediate.Enumeration):
|
|
170
|
+
name = proto_naming.enum_name(element.our_type.name)
|
|
171
|
+
|
|
172
|
+
elif isinstance(element.our_type, intermediate.ConstrainedPrimitive):
|
|
173
|
+
# NOTE (mristin, 2021-12-17):
|
|
174
|
+
# We do not generate a class for constrained primitives, but we
|
|
175
|
+
# leave it as class name, as that is what we used for ``Verify*`` function.
|
|
176
|
+
name = proto_naming.class_name(element.our_type.name)
|
|
177
|
+
|
|
178
|
+
elif isinstance(element.our_type, intermediate.Class):
|
|
179
|
+
if isinstance(element.our_type, intermediate.AbstractClass):
|
|
180
|
+
# NOTE (mristin, 2021-12-25):
|
|
181
|
+
# We do not generate ProtoBuf code for abstract classes, so we have to refer
|
|
182
|
+
# to the interface.
|
|
183
|
+
name = proto_naming.class_name(element.our_type.name)
|
|
184
|
+
|
|
185
|
+
elif isinstance(element.our_type, intermediate.ConcreteClass):
|
|
186
|
+
# NOTE (mristin, 2021-12-25):
|
|
187
|
+
# Though a concrete class can have multiple descendants and the writer
|
|
188
|
+
# might actually want to refer to the *interface* instead of
|
|
189
|
+
# the concrete class, we do the best effort here and resolve it to the
|
|
190
|
+
# name of the concrete class.
|
|
191
|
+
name = proto_naming.class_name(element.our_type.name)
|
|
192
|
+
|
|
193
|
+
else:
|
|
194
|
+
assert_never(element.our_type)
|
|
195
|
+
|
|
196
|
+
else:
|
|
197
|
+
# NOTE (mristin, 2022-03-30):
|
|
198
|
+
# This is a very special case where we had problems with an interface.
|
|
199
|
+
# We leave this check here, just in case the bug resurfaces.
|
|
200
|
+
if isinstance(element.our_type, intermediate_translate._PlaceholderOurType):
|
|
201
|
+
return None, [
|
|
202
|
+
f"Unexpected placeholder for our type: {element.our_type}; "
|
|
203
|
+
f"this is a bug"
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
assert_never(element.our_type)
|
|
207
|
+
|
|
208
|
+
# NOTE (mristin, 2022-06-19):
|
|
209
|
+
# We need to prefix the cref in case there are naming conflicts.
|
|
210
|
+
prefixed_name = f"Aas.{name}"
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
_Element(
|
|
214
|
+
name="see", attrs=collections.OrderedDict([("cref", prefixed_name)])
|
|
215
|
+
),
|
|
216
|
+
None,
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
def transform_reference_to_attribute_in_doc(
|
|
220
|
+
self, element: intermediate_doc.ReferenceToAttribute
|
|
221
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
222
|
+
cref: str
|
|
223
|
+
|
|
224
|
+
if isinstance(element.reference, intermediate_doc.ReferenceToProperty):
|
|
225
|
+
name_of_our_type: str
|
|
226
|
+
|
|
227
|
+
if isinstance(element.reference.cls, intermediate.AbstractClass):
|
|
228
|
+
# We do not generate ProtoBuf code for abstract classes, so we have to refer
|
|
229
|
+
# to the interface.
|
|
230
|
+
name_of_our_type = proto_naming.class_name(element.reference.cls.name)
|
|
231
|
+
elif isinstance(element.reference.cls, intermediate.ConcreteClass):
|
|
232
|
+
# NOTE (mristin, 2021-12-25):
|
|
233
|
+
# Though a concrete class can have multiple descendants and the writer
|
|
234
|
+
# might actually want to refer to the *interface* instead of
|
|
235
|
+
# the concrete class, we do the best effort here and resolve it to the
|
|
236
|
+
# name of the concrete class.
|
|
237
|
+
|
|
238
|
+
name_of_our_type = proto_naming.class_name(element.reference.cls.name)
|
|
239
|
+
else:
|
|
240
|
+
assert_never(element.reference.cls)
|
|
241
|
+
|
|
242
|
+
prop_name = proto_naming.property_name(element.reference.prop.name)
|
|
243
|
+
|
|
244
|
+
cref = f"{name_of_our_type}.{prop_name}"
|
|
245
|
+
elif isinstance(
|
|
246
|
+
element.reference, intermediate_doc.ReferenceToEnumerationLiteral
|
|
247
|
+
):
|
|
248
|
+
name_of_our_type = proto_naming.enum_name(
|
|
249
|
+
element.reference.enumeration.name
|
|
250
|
+
)
|
|
251
|
+
literal_name = proto_naming.enum_literal_name(
|
|
252
|
+
element.reference.literal.name
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
cref = f"{name_of_our_type}.{literal_name}"
|
|
256
|
+
else:
|
|
257
|
+
# NOTE (mristin, 2022-03-30):
|
|
258
|
+
# This is a very special case where we had problems with an interface.
|
|
259
|
+
# We leave this check here, just in case the bug resurfaces.
|
|
260
|
+
if isinstance(
|
|
261
|
+
element.reference,
|
|
262
|
+
intermediate_translate._PlaceholderReferenceToAttribute,
|
|
263
|
+
):
|
|
264
|
+
return None, [
|
|
265
|
+
f"Unexpected placeholder "
|
|
266
|
+
f"for the attribute reference: {element.reference}; "
|
|
267
|
+
f"this is a bug"
|
|
268
|
+
]
|
|
269
|
+
|
|
270
|
+
assert_never(element.reference)
|
|
271
|
+
|
|
272
|
+
# NOTE (mristin, 2022-06-19):
|
|
273
|
+
# We need to prefix the cref in case there are naming conflicts.
|
|
274
|
+
prefixed_cref = f"Aas.{cref}"
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
_Element(
|
|
278
|
+
name="see", attrs=collections.OrderedDict([("cref", prefixed_cref)])
|
|
279
|
+
),
|
|
280
|
+
None,
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
def transform_reference_to_argument_in_doc(
|
|
284
|
+
self, element: intermediate_doc.ReferenceToArgument
|
|
285
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
286
|
+
arg_name = proto_naming.argument_name(Identifier(element.reference))
|
|
287
|
+
|
|
288
|
+
return (
|
|
289
|
+
_Element(
|
|
290
|
+
name="paramref", attrs=collections.OrderedDict([("name", arg_name)])
|
|
291
|
+
),
|
|
292
|
+
None,
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
def transform_reference_to_constraint_in_doc(
|
|
296
|
+
self, element: intermediate_doc.ReferenceToConstraint
|
|
297
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
298
|
+
return _Text(content=f"Constraint {element.reference}"), None
|
|
299
|
+
|
|
300
|
+
def transform_reference_to_constant_in_doc(
|
|
301
|
+
self, element: intermediate_doc.ReferenceToConstant
|
|
302
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
303
|
+
constant_as_prop_name = proto_naming.property_name(element.constant.name)
|
|
304
|
+
cref = f"Aas.Constants.{constant_as_prop_name}"
|
|
305
|
+
|
|
306
|
+
return (
|
|
307
|
+
_Element(name="see", attrs=collections.OrderedDict([("cref", cref)])),
|
|
308
|
+
None,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
def transform_literal(
|
|
312
|
+
self, element: docutils.nodes.literal
|
|
313
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
314
|
+
return (
|
|
315
|
+
_Element(name="c", children=_List(items=[_Text(content=element.astext())])),
|
|
316
|
+
None,
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
def _transform_children_of(
|
|
320
|
+
self,
|
|
321
|
+
element: docutils.nodes.Element,
|
|
322
|
+
) -> Tuple[Optional[_List], Optional[List[str]]]:
|
|
323
|
+
"""Transform the children to a Python list."""
|
|
324
|
+
children = [] # type: List[_NodeUnion]
|
|
325
|
+
|
|
326
|
+
errors = [] # type: List[str]
|
|
327
|
+
for child in element.children:
|
|
328
|
+
rendered_child, child_errors = self.transform(child)
|
|
329
|
+
if child_errors is not None:
|
|
330
|
+
errors.extend(child_errors)
|
|
331
|
+
else:
|
|
332
|
+
assert rendered_child is not None
|
|
333
|
+
children.append(rendered_child)
|
|
334
|
+
|
|
335
|
+
if len(errors) > 0:
|
|
336
|
+
return None, errors
|
|
337
|
+
|
|
338
|
+
return _List(items=children), None
|
|
339
|
+
|
|
340
|
+
def transform_paragraph(
|
|
341
|
+
self, element: docutils.nodes.paragraph
|
|
342
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
343
|
+
children, errors = self._transform_children_of(element)
|
|
344
|
+
if errors is not None:
|
|
345
|
+
return None, errors
|
|
346
|
+
|
|
347
|
+
assert children is not None
|
|
348
|
+
|
|
349
|
+
return _Element(name="para", children=children), None
|
|
350
|
+
|
|
351
|
+
def transform_emphasis(
|
|
352
|
+
self, element: docutils.nodes.emphasis
|
|
353
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
354
|
+
children, errors = self._transform_children_of(element)
|
|
355
|
+
if errors is not None:
|
|
356
|
+
return None, errors
|
|
357
|
+
|
|
358
|
+
assert children is not None
|
|
359
|
+
|
|
360
|
+
return _Element(name="em", children=children), None
|
|
361
|
+
|
|
362
|
+
def transform_list_item(
|
|
363
|
+
self, element: docutils.nodes.list_item
|
|
364
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
365
|
+
children, errors = self._transform_children_of(element)
|
|
366
|
+
if errors is not None:
|
|
367
|
+
return None, errors
|
|
368
|
+
|
|
369
|
+
assert children is not None
|
|
370
|
+
|
|
371
|
+
return _Element(name="li", children=children), None
|
|
372
|
+
|
|
373
|
+
def transform_bullet_list(
|
|
374
|
+
self, element: docutils.nodes.bullet_list
|
|
375
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
376
|
+
children, errors = self._transform_children_of(element)
|
|
377
|
+
if errors is not None:
|
|
378
|
+
return None, errors
|
|
379
|
+
|
|
380
|
+
assert children is not None
|
|
381
|
+
|
|
382
|
+
return _Element(name="ul", children=children), None
|
|
383
|
+
|
|
384
|
+
def transform_note(
|
|
385
|
+
self, element: docutils.nodes.note
|
|
386
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
387
|
+
children, errors = self._transform_children_of(element)
|
|
388
|
+
|
|
389
|
+
if errors is not None:
|
|
390
|
+
return None, errors
|
|
391
|
+
|
|
392
|
+
assert children is not None
|
|
393
|
+
|
|
394
|
+
return _Element(name="para", children=children), None
|
|
395
|
+
|
|
396
|
+
def transform_reference(
|
|
397
|
+
self, element: docutils.nodes.reference
|
|
398
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
399
|
+
return self._transform_children_of(element)
|
|
400
|
+
|
|
401
|
+
def transform_field_body(
|
|
402
|
+
self, element: docutils.nodes.field_body
|
|
403
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
404
|
+
return self._transform_children_of(element)
|
|
405
|
+
|
|
406
|
+
def transform_document(
|
|
407
|
+
self, element: docutils.nodes.document
|
|
408
|
+
) -> Tuple[Optional[_NodeUnion], Optional[List[str]]]:
|
|
409
|
+
return self._transform_children_of(element)
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
class _FlattenListVisitor(_NodeVisitor):
|
|
413
|
+
"""Flatten all the node lists recursively and in-place."""
|
|
414
|
+
|
|
415
|
+
def visit_list(self, node: _List) -> None:
|
|
416
|
+
"""Visit the node list and its items recursively."""
|
|
417
|
+
new_items = [] # type: List[_NodeUnion]
|
|
418
|
+
|
|
419
|
+
for item in node.items:
|
|
420
|
+
self.visit(item)
|
|
421
|
+
|
|
422
|
+
if isinstance(item, _List):
|
|
423
|
+
new_items.extend(item.items)
|
|
424
|
+
else:
|
|
425
|
+
new_items.append(item)
|
|
426
|
+
|
|
427
|
+
node.items = new_items
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
class _ConcatenateTextVisitor(_NodeVisitor):
|
|
431
|
+
"""Concatenate the consecutive text elements in lists recursively and in-place."""
|
|
432
|
+
|
|
433
|
+
def visit_list(self, node: _List) -> None:
|
|
434
|
+
"""Visit the node list and its items recursively."""
|
|
435
|
+
new_items = [] # type: List[_NodeUnion]
|
|
436
|
+
|
|
437
|
+
accumulator = [] # type: List[_Text]
|
|
438
|
+
for item in node.items:
|
|
439
|
+
if isinstance(item, _Text):
|
|
440
|
+
accumulator.append(item)
|
|
441
|
+
else:
|
|
442
|
+
self.visit(item)
|
|
443
|
+
|
|
444
|
+
if len(accumulator) > 0:
|
|
445
|
+
new_items.append(
|
|
446
|
+
_Text(
|
|
447
|
+
content="".join(
|
|
448
|
+
text_element.content for text_element in accumulator
|
|
449
|
+
)
|
|
450
|
+
)
|
|
451
|
+
)
|
|
452
|
+
accumulator = []
|
|
453
|
+
|
|
454
|
+
new_items.append(item)
|
|
455
|
+
|
|
456
|
+
if len(accumulator) > 0:
|
|
457
|
+
new_items.append(
|
|
458
|
+
_Text(
|
|
459
|
+
content="".join(
|
|
460
|
+
text_element.content for text_element in accumulator
|
|
461
|
+
)
|
|
462
|
+
)
|
|
463
|
+
)
|
|
464
|
+
|
|
465
|
+
node.items = new_items
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
class _RemoveRedundantParaVisitor(_NodeVisitor):
|
|
469
|
+
"""Remove the redundant ``<para>`` elements in-place."""
|
|
470
|
+
|
|
471
|
+
def visit_element(self, node: _Element) -> None:
|
|
472
|
+
self.visit(node.children)
|
|
473
|
+
|
|
474
|
+
# noinspection PyUnresolvedReferences
|
|
475
|
+
if (
|
|
476
|
+
node.name in ("summary", "remarks", "li", "param", "returns", "para")
|
|
477
|
+
and len(node.children.items) == 1
|
|
478
|
+
and isinstance(node.children.items[0], _Element)
|
|
479
|
+
and node.children.items[0].name == "para"
|
|
480
|
+
):
|
|
481
|
+
# noinspection PyUnresolvedReferences
|
|
482
|
+
node.children = node.children.items[0].children
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def _compress_node_in_place(node: _NodeUnion) -> None:
|
|
486
|
+
"""Remove redundant nodes for more readability in the rendered text."""
|
|
487
|
+
flatten_list_visitor = _FlattenListVisitor()
|
|
488
|
+
flatten_list_visitor.visit(node)
|
|
489
|
+
|
|
490
|
+
concatenate_text_visitor = _ConcatenateTextVisitor()
|
|
491
|
+
concatenate_text_visitor.visit(node)
|
|
492
|
+
|
|
493
|
+
remove_redundant_para_visitor = _RemoveRedundantParaVisitor()
|
|
494
|
+
remove_redundant_para_visitor.visit(node)
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
def _render_summary_remarks(
|
|
498
|
+
description: intermediate.SummaryRemarksDescription,
|
|
499
|
+
) -> Tuple[Optional[_List], Optional[List[Error]]]:
|
|
500
|
+
"""Render a description to our description node."""
|
|
501
|
+
result_items = [] # type: List[_NodeUnion]
|
|
502
|
+
errors = [] # type: List[Error]
|
|
503
|
+
|
|
504
|
+
element_renderer = _ElementRenderer()
|
|
505
|
+
|
|
506
|
+
summary_node, summary_errors = element_renderer.transform(description.summary)
|
|
507
|
+
if summary_errors is not None:
|
|
508
|
+
errors.extend(
|
|
509
|
+
Error(description.parsed.node, message) for message in summary_errors
|
|
510
|
+
)
|
|
511
|
+
else:
|
|
512
|
+
assert summary_node is not None
|
|
513
|
+
|
|
514
|
+
result_items.append(
|
|
515
|
+
_Element(name="summary", children=_List(items=[summary_node]))
|
|
516
|
+
)
|
|
517
|
+
|
|
518
|
+
remark_nodes = [] # type: List[_NodeUnion]
|
|
519
|
+
for remark in description.remarks:
|
|
520
|
+
remark_node, remark_errors = element_renderer.transform(remark)
|
|
521
|
+
if remark_errors:
|
|
522
|
+
errors.extend(
|
|
523
|
+
Error(description.parsed.node, message) for message in remark_errors
|
|
524
|
+
)
|
|
525
|
+
else:
|
|
526
|
+
assert remark_node is not None
|
|
527
|
+
remark_nodes.append(remark_node)
|
|
528
|
+
|
|
529
|
+
if len(errors) > 0:
|
|
530
|
+
return None, errors
|
|
531
|
+
|
|
532
|
+
if len(remark_nodes) > 0:
|
|
533
|
+
result_items.append(
|
|
534
|
+
_Element(name="remarks", children=_List(items=remark_nodes))
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
return _List(items=result_items), None
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def _render_summary_remarks_constraints(
|
|
541
|
+
description: intermediate.SummaryRemarksConstraintsDescription,
|
|
542
|
+
) -> Tuple[Optional[_List], Optional[List[Error]]]:
|
|
543
|
+
"""Render a description where constraints are put in remarks."""
|
|
544
|
+
result_items = [] # type: List[_NodeUnion]
|
|
545
|
+
errors = [] # type: List[Error]
|
|
546
|
+
|
|
547
|
+
element_renderer = _ElementRenderer()
|
|
548
|
+
|
|
549
|
+
summary_node, summary_errors = element_renderer.transform(description.summary)
|
|
550
|
+
if summary_errors is not None:
|
|
551
|
+
errors.extend(
|
|
552
|
+
Error(description.parsed.node, message) for message in summary_errors
|
|
553
|
+
)
|
|
554
|
+
else:
|
|
555
|
+
assert summary_node is not None
|
|
556
|
+
result_items.append(
|
|
557
|
+
_Element(name="summary", children=_List(items=[summary_node]))
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
remark_nodes = [] # type: List[_NodeUnion]
|
|
561
|
+
for remark in description.remarks:
|
|
562
|
+
remark_node, remark_errors = element_renderer.transform(remark)
|
|
563
|
+
if remark_errors:
|
|
564
|
+
errors.extend(
|
|
565
|
+
Error(description.parsed.node, message) for message in remark_errors
|
|
566
|
+
)
|
|
567
|
+
else:
|
|
568
|
+
assert remark_node is not None
|
|
569
|
+
remark_nodes.append(remark_node)
|
|
570
|
+
|
|
571
|
+
constraint_nodes = [] # type: List[_NodeUnion]
|
|
572
|
+
for identifier, docutils_element in description.constraints_by_identifier.items():
|
|
573
|
+
body, body_errors = element_renderer.transform(docutils_element)
|
|
574
|
+
if body_errors is not None:
|
|
575
|
+
errors.extend(
|
|
576
|
+
Error(description.parsed.node, message) for message in body_errors
|
|
577
|
+
)
|
|
578
|
+
else:
|
|
579
|
+
assert body is not None
|
|
580
|
+
|
|
581
|
+
# NOTE (mristin, 2022-07-21):
|
|
582
|
+
# We in-line the constraint prefix for better readability.
|
|
583
|
+
|
|
584
|
+
# noinspection PyUnresolvedReferences
|
|
585
|
+
if (
|
|
586
|
+
isinstance(body, _List)
|
|
587
|
+
and len(body.items) > 0
|
|
588
|
+
and isinstance(body.items[0], _Element)
|
|
589
|
+
and body.items[0].name == "para"
|
|
590
|
+
):
|
|
591
|
+
# noinspection PyUnresolvedReferences
|
|
592
|
+
body.items[0].children.items.insert(
|
|
593
|
+
0, _Text(content=f"Constraint {identifier}:\n")
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
constraint_node = _Element(name="li", children=body)
|
|
597
|
+
else:
|
|
598
|
+
constraint_node = _Element(
|
|
599
|
+
name="li",
|
|
600
|
+
children=_List(
|
|
601
|
+
items=[
|
|
602
|
+
_Element(
|
|
603
|
+
name="para",
|
|
604
|
+
children=_List(
|
|
605
|
+
items=[_Text(content=f"Constraint {identifier}:\n")]
|
|
606
|
+
),
|
|
607
|
+
),
|
|
608
|
+
body,
|
|
609
|
+
]
|
|
610
|
+
),
|
|
611
|
+
)
|
|
612
|
+
|
|
613
|
+
constraint_nodes.append(constraint_node)
|
|
614
|
+
|
|
615
|
+
if len(errors) > 0:
|
|
616
|
+
return None, errors
|
|
617
|
+
|
|
618
|
+
if len(constraint_nodes) > 0:
|
|
619
|
+
remark_nodes.append(
|
|
620
|
+
_Element(name="para", children=_List(items=[_Text(content="Constraints:")]))
|
|
621
|
+
)
|
|
622
|
+
|
|
623
|
+
ul_node = _Element(name="ul", children=_List(items=constraint_nodes))
|
|
624
|
+
|
|
625
|
+
remark_nodes.append(ul_node)
|
|
626
|
+
|
|
627
|
+
if len(remark_nodes) > 0:
|
|
628
|
+
result_items.append(
|
|
629
|
+
_Element(name="remarks", children=_List(items=remark_nodes))
|
|
630
|
+
)
|
|
631
|
+
|
|
632
|
+
return _List(items=result_items), None
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
@require(lambda line: "\n" not in line)
|
|
636
|
+
def _slash_slash_slash_line(line: str) -> str:
|
|
637
|
+
"""Prepend ``///`` to the ``line``."""
|
|
638
|
+
if len(line) == 0:
|
|
639
|
+
return "///"
|
|
640
|
+
|
|
641
|
+
return f"/// {line}"
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
class _RelativeIndention:
|
|
645
|
+
"""
|
|
646
|
+
Represent the relative indention.
|
|
647
|
+
|
|
648
|
+
Since the indention is *relative*, it can be either positive, neutral or negative.
|
|
649
|
+
"""
|
|
650
|
+
|
|
651
|
+
@require(lambda direction: direction in (-1, 0, 1))
|
|
652
|
+
def __init__(self, direction: int) -> None:
|
|
653
|
+
self.direction = direction
|
|
654
|
+
|
|
655
|
+
def __repr__(self) -> str:
|
|
656
|
+
"""Generate text representation for easier debugging."""
|
|
657
|
+
return f"{self.__class__.__name__}({self.direction!r})"
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
class _TextBlock(DBC):
|
|
661
|
+
"""
|
|
662
|
+
Represent a block of text.
|
|
663
|
+
|
|
664
|
+
This data structure is expected to be append-only mutable, where you keep adding
|
|
665
|
+
new parts to the block. The parts are later expected to be joined by an empty
|
|
666
|
+
string.
|
|
667
|
+
|
|
668
|
+
All the text blocks are expected to be joined by empty strings.
|
|
669
|
+
"""
|
|
670
|
+
|
|
671
|
+
def __init__(self, parts: List[str]) -> None:
|
|
672
|
+
"""Initialize with the given values."""
|
|
673
|
+
self.parts = parts
|
|
674
|
+
|
|
675
|
+
def __repr__(self) -> str:
|
|
676
|
+
"""Generate text representation for easier debugging."""
|
|
677
|
+
return f"{self.__class__.__name__}({self.parts!r})"
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
class _EnforceNewLine(DBC):
|
|
681
|
+
"""
|
|
682
|
+
Enforce that the following text starts on a new line.
|
|
683
|
+
|
|
684
|
+
If there is already a new line output before, this text directive has no influence.
|
|
685
|
+
"""
|
|
686
|
+
|
|
687
|
+
def __repr__(self) -> str:
|
|
688
|
+
"""Generate text representation for easier debugging."""
|
|
689
|
+
return f"{self.__class__.__name__}()"
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
_TextDirective = Union[_RelativeIndention, _TextBlock, _EnforceNewLine]
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
class _ToTextDirectivesVisitor(_NodeVisitor):
|
|
696
|
+
"""
|
|
697
|
+
Convert the nodes to a text as represented by text control directives.
|
|
698
|
+
|
|
699
|
+
The text is expected to be valid XML and properly escaped.
|
|
700
|
+
"""
|
|
701
|
+
|
|
702
|
+
#: The resulting text control directives
|
|
703
|
+
directives: List[_TextDirective]
|
|
704
|
+
|
|
705
|
+
def __init__(self) -> None:
|
|
706
|
+
self.directives = []
|
|
707
|
+
|
|
708
|
+
def _last_or_new_block(self) -> _TextBlock:
|
|
709
|
+
"""Retrieve the last block, or initialize a new block, if no last block."""
|
|
710
|
+
if len(self.directives) == 0 or not isinstance(self.directives[-1], _TextBlock):
|
|
711
|
+
self.directives.append(_TextBlock(parts=[]))
|
|
712
|
+
|
|
713
|
+
assert isinstance(self.directives[-1], _TextBlock)
|
|
714
|
+
return self.directives[-1]
|
|
715
|
+
|
|
716
|
+
def visit_text(self, node: _Text) -> None:
|
|
717
|
+
self._last_or_new_block().parts.append(xml.sax.saxutils.escape(node.content))
|
|
718
|
+
|
|
719
|
+
def visit_element(self, node: _Element) -> None:
|
|
720
|
+
"""Visit the element node and its children."""
|
|
721
|
+
if node.name in ("summary", "remarks", "para", "param", "returns"):
|
|
722
|
+
# NOTE (mristin, 2022-07-18):
|
|
723
|
+
# We render these tags without indention for better readability.
|
|
724
|
+
|
|
725
|
+
start_element_writer = io.StringIO()
|
|
726
|
+
start_element_writer.write(f"<{node.name}")
|
|
727
|
+
if len(node.attrs) > 0:
|
|
728
|
+
for attr_name, attr_value in node.attrs.items():
|
|
729
|
+
start_element_writer.write(
|
|
730
|
+
f" {attr_name}={xml.sax.saxutils.quoteattr(attr_value)}"
|
|
731
|
+
)
|
|
732
|
+
start_element_writer.write(">")
|
|
733
|
+
|
|
734
|
+
self.directives.append(_EnforceNewLine())
|
|
735
|
+
|
|
736
|
+
self.directives.append(_TextBlock(parts=[start_element_writer.getvalue()]))
|
|
737
|
+
|
|
738
|
+
self.directives.append(_EnforceNewLine())
|
|
739
|
+
|
|
740
|
+
for item in node.children.items:
|
|
741
|
+
self.visit(item)
|
|
742
|
+
|
|
743
|
+
self.directives.append(_EnforceNewLine())
|
|
744
|
+
|
|
745
|
+
self.directives.append(_TextBlock(parts=[f"</{node.name}>"]))
|
|
746
|
+
|
|
747
|
+
elif node.name in ("ul", "li"):
|
|
748
|
+
# NOTE (mristin, 2022-07-18):
|
|
749
|
+
# We put the list elements on new lines and indent them.
|
|
750
|
+
assert (
|
|
751
|
+
len(node.attrs) == 0
|
|
752
|
+
), f"Unexpected attributes in a node {node.name!r}"
|
|
753
|
+
|
|
754
|
+
self.directives.append(_EnforceNewLine())
|
|
755
|
+
|
|
756
|
+
self.directives.append(_TextBlock(parts=[f"<{node.name}>"]))
|
|
757
|
+
|
|
758
|
+
self.directives.append(_EnforceNewLine())
|
|
759
|
+
|
|
760
|
+
self.directives.append(_RelativeIndention(direction=1))
|
|
761
|
+
|
|
762
|
+
for item in node.children.items:
|
|
763
|
+
self.visit(item)
|
|
764
|
+
|
|
765
|
+
self.directives.append(_EnforceNewLine())
|
|
766
|
+
|
|
767
|
+
self.directives.append(_RelativeIndention(direction=-1))
|
|
768
|
+
|
|
769
|
+
self.directives.append(_TextBlock(parts=[f"</{node.name}>"]))
|
|
770
|
+
|
|
771
|
+
else:
|
|
772
|
+
# NOTE (mristin, 2022-07-18):
|
|
773
|
+
# We inline all the other elements.
|
|
774
|
+
|
|
775
|
+
start_element_writer = io.StringIO()
|
|
776
|
+
start_element_writer.write(f"<{node.name}")
|
|
777
|
+
if len(node.attrs) > 0:
|
|
778
|
+
for attr_name, attr_value in node.attrs.items():
|
|
779
|
+
start_element_writer.write(
|
|
780
|
+
f" {attr_name}={xml.sax.saxutils.quoteattr(attr_value)}"
|
|
781
|
+
)
|
|
782
|
+
|
|
783
|
+
if len(node.children.items) == 0:
|
|
784
|
+
start_element_writer.write(" />")
|
|
785
|
+
self._last_or_new_block().parts.append(start_element_writer.getvalue())
|
|
786
|
+
|
|
787
|
+
return
|
|
788
|
+
|
|
789
|
+
start_element_writer.write(">")
|
|
790
|
+
self._last_or_new_block().parts.append(start_element_writer.getvalue())
|
|
791
|
+
|
|
792
|
+
for item in node.children.items:
|
|
793
|
+
self.visit(item)
|
|
794
|
+
|
|
795
|
+
self._last_or_new_block().parts.append(f"</{node.name}>")
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
_TextDirectiveExceptEnforceNewLine = Union[_RelativeIndention, _TextBlock]
|
|
799
|
+
assert_union_without_excluded(
|
|
800
|
+
original_union=_TextDirective,
|
|
801
|
+
subset_union=_TextDirectiveExceptEnforceNewLine,
|
|
802
|
+
excluded=[_EnforceNewLine],
|
|
803
|
+
)
|
|
804
|
+
|
|
805
|
+
T = TypeVar("T")
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
def pairwise(iterable: Iterable[T]) -> Iterator[Tuple[T, T]]:
|
|
809
|
+
"""Iterate pair-wise over the iterator."""
|
|
810
|
+
a, b = itertools.tee(iterable)
|
|
811
|
+
next(b, None)
|
|
812
|
+
return zip(a, b)
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
# fmt: off
|
|
816
|
+
@ensure(
|
|
817
|
+
lambda result:
|
|
818
|
+
all(
|
|
819
|
+
len(directive.parts) > 0
|
|
820
|
+
for directive in result
|
|
821
|
+
if isinstance(directive, _TextBlock)
|
|
822
|
+
),
|
|
823
|
+
"No empty text blocks"
|
|
824
|
+
)
|
|
825
|
+
@ensure(
|
|
826
|
+
lambda result:
|
|
827
|
+
all(
|
|
828
|
+
not (
|
|
829
|
+
isinstance(prev, _TextBlock)
|
|
830
|
+
and isinstance(current, _TextBlock)
|
|
831
|
+
)
|
|
832
|
+
for prev, current in pairwise(result)
|
|
833
|
+
),
|
|
834
|
+
"All text blocks are merged and there are no consecutive text blocks"
|
|
835
|
+
)
|
|
836
|
+
# fmt: on
|
|
837
|
+
def _compress_text_directives(
|
|
838
|
+
directives: Sequence[_TextDirective],
|
|
839
|
+
) -> List[_TextDirectiveExceptEnforceNewLine]:
|
|
840
|
+
"""Merge consecutive text blocks and enforce the new lines."""
|
|
841
|
+
# region Remove empty blocks
|
|
842
|
+
|
|
843
|
+
directives_wo_empty_blocks = [
|
|
844
|
+
directive
|
|
845
|
+
for directive in directives
|
|
846
|
+
if not (isinstance(directive, _TextBlock) and len(directive.parts) == 0)
|
|
847
|
+
]
|
|
848
|
+
|
|
849
|
+
# endregion
|
|
850
|
+
|
|
851
|
+
# region Fulfill new-line enforcement
|
|
852
|
+
|
|
853
|
+
directives_wo_enforce_new_line = (
|
|
854
|
+
[]
|
|
855
|
+
) # type: List[_TextDirectiveExceptEnforceNewLine]
|
|
856
|
+
|
|
857
|
+
previous_text_block = None # type: Optional[_TextBlock]
|
|
858
|
+
|
|
859
|
+
for directive in directives_wo_empty_blocks:
|
|
860
|
+
if isinstance(directive, _EnforceNewLine):
|
|
861
|
+
if previous_text_block is not None:
|
|
862
|
+
assert len(previous_text_block.parts) > 0
|
|
863
|
+
|
|
864
|
+
if not previous_text_block.parts[-1].endswith("\n"):
|
|
865
|
+
previous_text_block.parts.append("\n")
|
|
866
|
+
elif isinstance(directive, _TextBlock):
|
|
867
|
+
assert len(directive.parts) > 0
|
|
868
|
+
|
|
869
|
+
previous_text_block = directive
|
|
870
|
+
directives_wo_enforce_new_line.append(directive)
|
|
871
|
+
|
|
872
|
+
elif isinstance(directive, _RelativeIndention):
|
|
873
|
+
directives_wo_enforce_new_line.append(directive)
|
|
874
|
+
else:
|
|
875
|
+
assert_never(directive)
|
|
876
|
+
|
|
877
|
+
# endregion
|
|
878
|
+
|
|
879
|
+
# region Merge consecutive text blocks
|
|
880
|
+
|
|
881
|
+
directives_w_merged_blocks = [] # type: List[_TextDirectiveExceptEnforceNewLine]
|
|
882
|
+
|
|
883
|
+
for directive in directives_wo_enforce_new_line:
|
|
884
|
+
if isinstance(directive, _TextBlock):
|
|
885
|
+
assert len(directive.parts) > 0
|
|
886
|
+
|
|
887
|
+
if len(directives_w_merged_blocks) > 0 and isinstance(
|
|
888
|
+
directives_w_merged_blocks[-1], _TextBlock
|
|
889
|
+
):
|
|
890
|
+
directives_w_merged_blocks[-1].parts.extend(directive.parts)
|
|
891
|
+
else:
|
|
892
|
+
directives_w_merged_blocks.append(directive)
|
|
893
|
+
else:
|
|
894
|
+
directives_w_merged_blocks.append(directive)
|
|
895
|
+
|
|
896
|
+
# endregion
|
|
897
|
+
|
|
898
|
+
return directives_w_merged_blocks
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
def _to_text(node: _NodeUnion) -> str:
|
|
902
|
+
"""
|
|
903
|
+
Convert the node to a text representation.
|
|
904
|
+
|
|
905
|
+
For readability and no phantom elements, the ``node`` is expected to be compressed
|
|
906
|
+
before.
|
|
907
|
+
"""
|
|
908
|
+
to_text_directives_visitor = _ToTextDirectivesVisitor()
|
|
909
|
+
to_text_directives_visitor.visit(node)
|
|
910
|
+
|
|
911
|
+
# NOTE (mristin, 2022-07-18):
|
|
912
|
+
# We compress to do away with the new-line enforcement and consecutive and empty
|
|
913
|
+
# blocks, so that the operations below become much easier to write.
|
|
914
|
+
directives = _compress_text_directives(to_text_directives_visitor.directives)
|
|
915
|
+
|
|
916
|
+
writer = io.StringIO()
|
|
917
|
+
level = 0 # indention level
|
|
918
|
+
|
|
919
|
+
for directive in directives:
|
|
920
|
+
if isinstance(directive, _TextBlock):
|
|
921
|
+
writer.write(textwrap.indent("".join(directive.parts), level * " "))
|
|
922
|
+
|
|
923
|
+
elif isinstance(directive, _RelativeIndention):
|
|
924
|
+
assert level + directive.direction >= 0, (
|
|
925
|
+
f"Negative absolute indention not possible: "
|
|
926
|
+
f"{level=}, {directive.direction=}"
|
|
927
|
+
)
|
|
928
|
+
level += directive.direction
|
|
929
|
+
|
|
930
|
+
else:
|
|
931
|
+
assert_never(directive)
|
|
932
|
+
|
|
933
|
+
return writer.getvalue()
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
def _generate_summary_remarks(
|
|
937
|
+
description: intermediate.SummaryRemarksDescription,
|
|
938
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
939
|
+
"""Generate the documentation comment for a summary-remarks description."""
|
|
940
|
+
node, errors = _render_summary_remarks(description=description)
|
|
941
|
+
if errors is not None:
|
|
942
|
+
return None, errors
|
|
943
|
+
|
|
944
|
+
assert node is not None
|
|
945
|
+
|
|
946
|
+
_compress_node_in_place(node=node)
|
|
947
|
+
text = _to_text(node)
|
|
948
|
+
|
|
949
|
+
commented_lines = [_slash_slash_slash_line(line) for line in text.splitlines()]
|
|
950
|
+
|
|
951
|
+
return Stripped("\n".join(commented_lines)), None
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
def _generate_summary_remarks_constraints(
|
|
955
|
+
description: intermediate.SummaryRemarksConstraintsDescription,
|
|
956
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
957
|
+
"""Generate the documentation comment for a summary-remarks-constraints."""
|
|
958
|
+
node, errors = _render_summary_remarks_constraints(description=description)
|
|
959
|
+
if errors is not None:
|
|
960
|
+
return None, errors
|
|
961
|
+
|
|
962
|
+
assert node is not None
|
|
963
|
+
|
|
964
|
+
_compress_node_in_place(node=node)
|
|
965
|
+
text = _to_text(node)
|
|
966
|
+
|
|
967
|
+
commented_lines = [_slash_slash_slash_line(line) for line in text.splitlines()]
|
|
968
|
+
|
|
969
|
+
return Stripped("\n".join(commented_lines)), None
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
def generate_comment_for_meta_model(
|
|
973
|
+
description: intermediate.DescriptionOfMetaModel,
|
|
974
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
975
|
+
"""Generate the documentation comment for the given meta-model."""
|
|
976
|
+
return _generate_summary_remarks_constraints(description)
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
def generate_comment_for_our_type(
|
|
980
|
+
description: intermediate.DescriptionOfOurType,
|
|
981
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
982
|
+
"""Generate the documentation comment for our type."""
|
|
983
|
+
return _generate_summary_remarks_constraints(description)
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
def generate_comment_for_property(
|
|
987
|
+
description: intermediate.DescriptionOfProperty,
|
|
988
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
989
|
+
"""Generate the documentation comment for the given property."""
|
|
990
|
+
return _generate_summary_remarks_constraints(description)
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
def generate_comment_for_enumeration_literal(
|
|
994
|
+
description: intermediate.DescriptionOfEnumerationLiteral,
|
|
995
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
996
|
+
"""Generate the documentation comment for the given enumeration literal."""
|
|
997
|
+
return _generate_summary_remarks(description)
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
def _render_description_of_signature(
|
|
1001
|
+
description: intermediate.DescriptionOfSignature,
|
|
1002
|
+
) -> Tuple[Optional[_List], Optional[List[Error]]]:
|
|
1003
|
+
"""Render a description where constraints are put in remarks."""
|
|
1004
|
+
result_items = [] # type: List[_NodeUnion]
|
|
1005
|
+
errors = [] # type: List[Error]
|
|
1006
|
+
|
|
1007
|
+
renderer = _ElementRenderer()
|
|
1008
|
+
|
|
1009
|
+
summary_node, summary_errors = renderer.transform(description.summary)
|
|
1010
|
+
if summary_errors is not None:
|
|
1011
|
+
errors.extend(
|
|
1012
|
+
Error(description.parsed.node, message) for message in summary_errors
|
|
1013
|
+
)
|
|
1014
|
+
else:
|
|
1015
|
+
assert summary_node is not None
|
|
1016
|
+
result_items.append(
|
|
1017
|
+
_Element(name="summary", children=_List(items=[summary_node]))
|
|
1018
|
+
)
|
|
1019
|
+
|
|
1020
|
+
remark_nodes = [] # type: List[_NodeUnion]
|
|
1021
|
+
for remark in description.remarks:
|
|
1022
|
+
remark_node, remark_errors = renderer.transform(remark)
|
|
1023
|
+
if remark_errors:
|
|
1024
|
+
errors.extend(
|
|
1025
|
+
Error(description.parsed.node, message) for message in remark_errors
|
|
1026
|
+
)
|
|
1027
|
+
else:
|
|
1028
|
+
assert remark_node is not None
|
|
1029
|
+
remark_nodes.append(remark_node)
|
|
1030
|
+
|
|
1031
|
+
param_nodes = [] # type: List[_NodeUnion]
|
|
1032
|
+
|
|
1033
|
+
for name, docutils_element in description.arguments_by_name.items():
|
|
1034
|
+
returns, body_errors = renderer.transform(docutils_element)
|
|
1035
|
+
if body_errors is not None:
|
|
1036
|
+
errors.extend(
|
|
1037
|
+
Error(description.parsed.node, message) for message in body_errors
|
|
1038
|
+
)
|
|
1039
|
+
else:
|
|
1040
|
+
assert returns is not None
|
|
1041
|
+
|
|
1042
|
+
param_nodes.append(
|
|
1043
|
+
_Element(
|
|
1044
|
+
name="param",
|
|
1045
|
+
attrs=collections.OrderedDict([("name", name)]),
|
|
1046
|
+
children=_List(items=[returns]),
|
|
1047
|
+
)
|
|
1048
|
+
)
|
|
1049
|
+
|
|
1050
|
+
returns_node = None # type: Optional[_NodeUnion]
|
|
1051
|
+
|
|
1052
|
+
if description.returns is not None:
|
|
1053
|
+
# NOTE (mristin, 2022-07-18):
|
|
1054
|
+
# We need to help the type checker in PyCharm a bit.
|
|
1055
|
+
assert isinstance(description.returns, docutils.nodes.field_body)
|
|
1056
|
+
|
|
1057
|
+
returns, returns_errors = renderer.transform(description.returns)
|
|
1058
|
+
if returns_errors is not None:
|
|
1059
|
+
errors.extend(
|
|
1060
|
+
Error(description.parsed.node, message) for message in returns_errors
|
|
1061
|
+
)
|
|
1062
|
+
else:
|
|
1063
|
+
assert returns is not None
|
|
1064
|
+
|
|
1065
|
+
returns_node = _Element(name="returns", children=_List(items=[returns]))
|
|
1066
|
+
|
|
1067
|
+
if len(errors) > 0:
|
|
1068
|
+
return None, errors
|
|
1069
|
+
|
|
1070
|
+
if len(remark_nodes) > 0:
|
|
1071
|
+
result_items.append(
|
|
1072
|
+
_Element(name="remarks", children=_List(items=remark_nodes))
|
|
1073
|
+
)
|
|
1074
|
+
|
|
1075
|
+
result_items.extend(param_nodes)
|
|
1076
|
+
|
|
1077
|
+
if returns_node is not None:
|
|
1078
|
+
result_items.append(returns_node)
|
|
1079
|
+
|
|
1080
|
+
return _List(items=result_items), None
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
def generate_comment_for_signature(
|
|
1084
|
+
description: intermediate.DescriptionOfSignature,
|
|
1085
|
+
) -> Tuple[Optional[Stripped], Optional[List[Error]]]:
|
|
1086
|
+
"""
|
|
1087
|
+
Generate the documentation comment for the given signature.
|
|
1088
|
+
|
|
1089
|
+
A signature, in this context, means a function or a method signature.
|
|
1090
|
+
"""
|
|
1091
|
+
node, errors = _render_description_of_signature(description=description)
|
|
1092
|
+
if errors is not None:
|
|
1093
|
+
return None, errors
|
|
1094
|
+
|
|
1095
|
+
assert node is not None
|
|
1096
|
+
|
|
1097
|
+
_compress_node_in_place(node=node)
|
|
1098
|
+
text = _to_text(node)
|
|
1099
|
+
|
|
1100
|
+
commented_lines = [_slash_slash_slash_line(line) for line in text.splitlines()]
|
|
1101
|
+
|
|
1102
|
+
return Stripped("\n".join(commented_lines)), None
|