From f0cc6cdd7ab665b7d2612872339ec35cd560e278 Mon Sep 17 00:00:00 2001 From: Scott Dixon Date: Thu, 18 May 2023 13:25:58 -0700 Subject: [PATCH] Fix for #298 and workaround for Sybil 4 bug (#303) #298 will be fixed but this will also get another refactor when we switch to CETL. --- .devcontainer/devcontainer.json | 4 +- .github/workflows/release.yml | 4 +- .github/workflows/test.yml | 73 ++- .vscode/cmake-variants.json | 3 +- .vscode/extensions.json | 10 +- CONTRIBUTING.rst | 6 +- docs/static/templates/footer.html | 2 +- docs/templates.rst | 4 - requirements.txt | 2 - src/nunavut/_version.py | 4 +- src/nunavut/cli/__init__.py | 10 +- src/nunavut/jinja/jinja2/loaders.py | 520 ++++++++++++------ .../lang/cpp/templates/deserialization.j2 | 8 +- src/nunavut/lang/html/support/__init__.py | 19 + src/nunavut/lang/js/support/__init__.py | 19 + src/nunavut/lang/py/support/__init__.py | 19 + ...510.GetSynchronizationMasterInfo.0.1.dsdl} | 0 ...0.uavcan => 7168.Synchronization.1.0.dsdl} | 0 ...> SynchronizedAmbiguousTimestamp.1.0.dsdl} | 0 ....uavcan => SynchronizedTimestamp.1.0.dsdl} | 0 ...eSystem.0.1.uavcan => TimeSystem.0.1.dsdl} | 0 .../{Phased.0.1.uavcan => Phased.0.1.dsdl} | 0 .../{hotness.1.0.uavcan => hotness.1.0.dsdl} | 0 .../{malloc.1.0.uavcan => malloc.1.0.dsdl} | 0 .../dsdl/one/{foo.1.0.uavcan => foo.1.0.dsdl} | 0 ...{7168.bar.1.0.uavcan => 7168.bar.1.0.dsdl} | 0 .../{bar_svc.1.0.uavcan => bar_svc.1.0.dsdl} | 0 ....uavcan => SynchronizedTimestamp.1.0.dsdl} | 0 ...{uses_vla.0.1.uavcan => uses_vla.0.1.dsdl} | 0 ...Type.0.1.uavcan => 7168.TestType.0.1.dsdl} | 0 ...Type.0.1.uavcan => 7168.TestType.0.1.dsdl} | 0 ...Type.0.1.uavcan => 7169.TestType.0.1.dsdl} | 0 ...Type.0.1.uavcan => 7170.TestType.0.1.dsdl} | 0 ...0.uavcan => 7168.Synchronization.1.0.dsdl} | 0 ...> SynchronizedAmbiguousTimestamp.1.0.dsdl} | 0 ....uavcan => SynchronizedTimestamp.1.0.dsdl} | 0 ...eSystem.0.1.uavcan => TimeSystem.0.1.dsdl} | 0 ...rType.0.1.uavcan => DaughterType.0.1.dsdl} | 0 .../{SonType.0.1.uavcan => SonType.0.1.dsdl} | 0 ...herType.0.1.uavcan => FatherType.0.1.dsdl} | 0 .../mcu/{Timer.0.1.uavcan => Timer.0.1.dsdl} | 0 ...C_TYPE.0.1.uavcan => ATOMIC_TYPE.0.1.dsdl} | 0 ....uavcan => SynchronizedTimestamp.1.0.dsdl} | 0 ...00.Timer.1.0.uavcan => 100.Timer.1.0.dsdl} | 0 .../{TImer.2.1.uavcan => TImer.2.1.dsdl} | 0 .../{Timer.1.0.uavcan => Timer.1.0.dsdl} | 0 ...{TestType.0.8.uavcan => TestType.0.8.dsdl} | 0 test/gentest_nnvg/test_nnvg.py | 12 +- ...{TestType.0.2.uavcan => TestType.0.2.dsdl} | 0 ...0.uavcan => 1.HelloSerialization.1.0.dsdl} | 0 .../{Basic.1.0.uavcan => Basic.1.0.dsdl} | 0 ...Sink.1.0.uavcan => 2.KitchenSink.1.0.dsdl} | 0 .../{Nested.1.0.uavcan => Nested.1.0.dsdl} | 0 ...ested.1.0.uavcan => NestedNested.1.0.dsdl} | 0 ...dUnion.1.0.uavcan => NestedUnion.1.0.dsdl} | 0 ...vcan => NestedUnionWComplexArray.1.0.dsdl} | 0 ...bles.0.1.uavcan => serializables.0.1.dsdl} | 0 ...bles.0.1.uavcan => serializables.0.1.dsdl} | 0 ...{1.covid.1.10.uavcan => 1.covid.1.10.dsdl} | 0 .../{1.covid.1.9.uavcan => 1.covid.1.9.dsdl} | 0 .../{hasvla.1.0.uavcan => hasvla.1.0.dsdl} | 0 tox.ini | 10 +- verification/.devcontainer/devcontainer.json | 9 +- ...uavcan => CombinatorialExplosion.0.1.dsdl} | 0 ...ervice.0.1.uavcan => 300.Service.0.1.dsdl} | 0 ...ruct_.0.1.uavcan => 7000.Struct_.0.1.dsdl} | 0 ...0.1.uavcan => DelimitedFixedSize.0.1.dsdl} | 0 ....uavcan => DelimitedVariableSize.0.1.dsdl} | 0 ...rimitive.0.1.uavcan => Primitive.0.1.dsdl} | 0 ....1.uavcan => PrimitiveArrayFixed.0.1.dsdl} | 0 ...uavcan => PrimitiveArrayVariable.0.1.dsdl} | 0 .../{Union.0.1.uavcan => Union.0.1.dsdl} | 0 ...0.1.uavcan => UnionWithSameTypes.0.1.dsdl} | 0 .../delimited/{A.1.0.uavcan => A.1.0.dsdl} | 0 .../delimited/{A.1.1.uavcan => A.1.1.dsdl} | 0 ...limited.1.0.uavcan => BDelimited.1.0.dsdl} | 0 ...limited.1.1.uavcan => BDelimited.1.1.dsdl} | 0 .../{BSealed.1.0.uavcan => BSealed.1.0.dsdl} | 0 .../{CFixed.1.0.uavcan => CFixed.1.0.dsdl} | 0 .../{CFixed.1.1.uavcan => CFixed.1.1.dsdl} | 0 ...Variable.1.0.uavcan => CVariable.1.0.dsdl} | 0 ...Variable.1.1.uavcan => CVariable.1.1.dsdl} | 0 .../{BMSInfo.1.0.uavcan => BMSInfo.1.0.dsdl} | 0 ...MSStatus.1.0.uavcan => BMSStatus.1.0.dsdl} | 0 ...lue.1.0.uavcan => BMSStatusValue.1.0.dsdl} | 0 ...y.1.0.uavcan => BatteryChemistry.1.0.dsdl} | 0 ...int.0.1.uavcan => AngVelSetpoint.0.1.dsdl} | 0 ....1.uavcan => RatiometricSetpoint.0.1.dsdl} | 0 .../{Status.0.1.uavcan => Status.0.1.dsdl} | 0 ....0.1.uavcan => BatteryPackParams.0.1.dsdl} | 0 ....0.1.uavcan => BatteryPackStatus.0.1.dsdl} | 0 ...hnology.0.1.uavcan => Technology.0.1.dsdl} | 0 ...{DCSample.0.1.uavcan => DCSample.0.1.dsdl} | 0 93 files changed, 482 insertions(+), 256 deletions(-) create mode 100644 src/nunavut/lang/html/support/__init__.py create mode 100644 src/nunavut/lang/js/support/__init__.py create mode 100644 src/nunavut/lang/py/support/__init__.py rename test/gentest_any/dsdl/uavcan/time/{510.GetSynchronizationMasterInfo.0.1.uavcan => 510.GetSynchronizationMasterInfo.0.1.dsdl} (100%) rename test/gentest_any/dsdl/uavcan/time/{7168.Synchronization.1.0.uavcan => 7168.Synchronization.1.0.dsdl} (100%) rename test/gentest_any/dsdl/uavcan/time/{SynchronizedAmbiguousTimestamp.1.0.uavcan => SynchronizedAmbiguousTimestamp.1.0.dsdl} (100%) rename test/gentest_any/dsdl/uavcan/time/{SynchronizedTimestamp.1.0.uavcan => SynchronizedTimestamp.1.0.dsdl} (100%) rename test/gentest_any/dsdl/uavcan/time/{TimeSystem.0.1.uavcan => TimeSystem.0.1.dsdl} (100%) rename test/gentest_arrays/dsdl/radar/{Phased.0.1.uavcan => Phased.0.1.dsdl} (100%) rename test/gentest_filters/dsdl/new/{hotness.1.0.uavcan => hotness.1.0.dsdl} (100%) rename test/gentest_filters/dsdl/new/{malloc.1.0.uavcan => malloc.1.0.dsdl} (100%) rename test/gentest_filters/dsdl/one/{foo.1.0.uavcan => foo.1.0.dsdl} (100%) rename test/gentest_filters/dsdl/uavcan/str/{7168.bar.1.0.uavcan => 7168.bar.1.0.dsdl} (100%) rename test/gentest_filters/dsdl/uavcan/str/{bar_svc.1.0.uavcan => bar_svc.1.0.dsdl} (100%) rename test/gentest_filters/dsdl/uavcan/time/{SynchronizedTimestamp.1.0.uavcan => SynchronizedTimestamp.1.0.dsdl} (100%) rename test/gentest_filters/dsdl/vla/{uses_vla.0.1.uavcan => uses_vla.0.1.dsdl} (100%) rename test/gentest_json/dsdl/uavcan/test/{7168.TestType.0.1.uavcan => 7168.TestType.0.1.dsdl} (100%) rename test/gentest_lang/dsdl/langtest/c/{7168.TestType.0.1.uavcan => 7168.TestType.0.1.dsdl} (100%) rename test/gentest_lang/dsdl/langtest/cpp/ns/{7169.TestType.0.1.uavcan => 7169.TestType.0.1.dsdl} (100%) rename test/gentest_lang/dsdl/langtest/py/{7170.TestType.0.1.uavcan => 7170.TestType.0.1.dsdl} (100%) rename test/gentest_lookup/dsdl/uavcan/time/{7168.Synchronization.1.0.uavcan => 7168.Synchronization.1.0.dsdl} (100%) rename test/gentest_lookup/dsdl/uavcan/time/{SynchronizedAmbiguousTimestamp.1.0.uavcan => SynchronizedAmbiguousTimestamp.1.0.dsdl} (100%) rename test/gentest_lookup/dsdl/uavcan/time/{SynchronizedTimestamp.1.0.uavcan => SynchronizedTimestamp.1.0.dsdl} (100%) rename test/gentest_lookup/dsdl/uavcan/time/{TimeSystem.0.1.uavcan => TimeSystem.0.1.dsdl} (100%) rename test/gentest_multiple/dsdl/esmeinc/{DaughterType.0.1.uavcan => DaughterType.0.1.dsdl} (100%) rename test/gentest_multiple/dsdl/huckco/{SonType.0.1.uavcan => SonType.0.1.dsdl} (100%) rename test/gentest_multiple/dsdl/scotec/{FatherType.0.1.uavcan => FatherType.0.1.dsdl} (100%) rename test/gentest_namespaces/dsdl/scotec/mcu/{Timer.0.1.uavcan => Timer.0.1.dsdl} (100%) rename test/gentest_namespaces/dsdl/scotec/typedef/str/{ATOMIC_TYPE.0.1.uavcan => ATOMIC_TYPE.0.1.dsdl} (100%) rename test/gentest_namespaces/dsdl/uavcan/time/{SynchronizedTimestamp.1.0.uavcan => SynchronizedTimestamp.1.0.dsdl} (100%) rename test/gentest_nnvg/dsdl/fixedid/{100.Timer.1.0.uavcan => 100.Timer.1.0.dsdl} (100%) rename test/gentest_nnvg/dsdl/herringtec/{TImer.2.1.uavcan => TImer.2.1.dsdl} (100%) rename test/gentest_nnvg/dsdl/scotec/{Timer.1.0.uavcan => Timer.1.0.dsdl} (100%) rename test/gentest_nnvg/dsdl/uavcan/test/{TestType.0.8.uavcan => TestType.0.8.dsdl} (100%) rename test/gentest_postprocessors/dsdl/uavcan/test/{TestType.0.2.uavcan => TestType.0.2.dsdl} (100%) rename test/gentest_serialization/dsdl/basic/{1.HelloSerialization.1.0.uavcan => 1.HelloSerialization.1.0.dsdl} (100%) rename test/gentest_serialization/dsdl/basic/{Basic.1.0.uavcan => Basic.1.0.dsdl} (100%) rename test/gentest_serialization/dsdl/complex/{2.KitchenSink.1.0.uavcan => 2.KitchenSink.1.0.dsdl} (100%) rename test/gentest_serialization/dsdl/complex/{Nested.1.0.uavcan => Nested.1.0.dsdl} (100%) rename test/gentest_serialization/dsdl/complex/{NestedNested.1.0.uavcan => NestedNested.1.0.dsdl} (100%) rename test/gentest_serialization/dsdl/complex/{NestedUnion.1.0.uavcan => NestedUnion.1.0.dsdl} (100%) rename test/gentest_serialization/dsdl/complex/{NestedUnionWComplexArray.1.0.uavcan => NestedUnionWComplexArray.1.0.dsdl} (100%) rename test/gentest_tests/dsdl/buncho/{serializables.0.1.uavcan => serializables.0.1.dsdl} (100%) rename test/gentest_uses/dsdl/denada/{serializables.0.1.uavcan => serializables.0.1.dsdl} (100%) rename test/gentest_versions/dsdl/viruses/{1.covid.1.10.uavcan => 1.covid.1.10.dsdl} (100%) rename test/gentest_versions/dsdl/viruses/{1.covid.1.9.uavcan => 1.covid.1.9.dsdl} (100%) rename test/gettest_properties/dsdl/proptest/{hasvla.1.0.uavcan => hasvla.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/{CombinatorialExplosion.0.1.uavcan => CombinatorialExplosion.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{300.Service.0.1.uavcan => 300.Service.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{7000.Struct_.0.1.uavcan => 7000.Struct_.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{DelimitedFixedSize.0.1.uavcan => DelimitedFixedSize.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{DelimitedVariableSize.0.1.uavcan => DelimitedVariableSize.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{Primitive.0.1.uavcan => Primitive.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{PrimitiveArrayFixed.0.1.uavcan => PrimitiveArrayFixed.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{PrimitiveArrayVariable.0.1.uavcan => PrimitiveArrayVariable.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{Union.0.1.uavcan => Union.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/basics/{UnionWithSameTypes.0.1.uavcan => UnionWithSameTypes.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{A.1.0.uavcan => A.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{A.1.1.uavcan => A.1.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{BDelimited.1.0.uavcan => BDelimited.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{BDelimited.1.1.uavcan => BDelimited.1.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{BSealed.1.0.uavcan => BSealed.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{CFixed.1.0.uavcan => CFixed.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{CFixed.1.1.uavcan => CFixed.1.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{CVariable.1.0.uavcan => CVariable.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/delimited/{CVariable.1.1.uavcan => CVariable.1.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/drone/sensor/{BMSInfo.1.0.uavcan => BMSInfo.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/drone/sensor/{BMSStatus.1.0.uavcan => BMSStatus.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/drone/sensor/{BMSStatusValue.1.0.uavcan => BMSStatusValue.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/drone/sensor/{BatteryChemistry.1.0.uavcan => BatteryChemistry.1.0.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/{AngVelSetpoint.0.1.uavcan => AngVelSetpoint.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/{RatiometricSetpoint.0.1.uavcan => RatiometricSetpoint.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/{Status.0.1.uavcan => Status.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/{BatteryPackParams.0.1.uavcan => BatteryPackParams.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/{BatteryPackStatus.0.1.uavcan => BatteryPackStatus.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/{Technology.0.1.uavcan => Technology.0.1.dsdl} (100%) rename verification/nunavut_test_types/test0/regulated/zubax/sensor/wattmeter/{DCSample.0.1.uavcan => DCSample.0.1.dsdl} (100%) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f1b209a2..d12476a3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Python dev environment", - "image": "ghcr.io/opencyphal/toxic:tx20.4.1", + "image": "ghcr.io/opencyphal/toxic:tx22.4.1", "workspaceFolder": "/workspace", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=delegated", "mounts": [ @@ -12,7 +12,7 @@ "extensions": [ "uavcan.dsdl", "wholroyd.jinja", - "ban.spellright", + "streetsidesoftware.code-spell-checker", "ms-python.python" ] } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f0f4d73..63a44fcc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ jobs: release: if: ${{ github.event_name == 'release' && !github.event.release.prerelease }} runs-on: ubuntu-latest - container: ghcr.io/opencyphal/toxic:ts20.4.1 + container: ghcr.io/opencyphal/toxic:tx22.4.1 steps: - uses: actions/checkout@v3 with: @@ -20,8 +20,6 @@ jobs: # Fails the release if the release-tag doesn't match the Nunavut version at that tag. run: | $(./.github/verify.py -vv --version-check-only "${{ steps.process_event.outputs.tag }}") - - name: install-tox - run: pip3 install tox - name: lint run: tox -e lint - name: test-nnvg diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dff6a47f..b5f54c96 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,15 +9,11 @@ on: jobs: test: runs-on: ubuntu-latest + container: ghcr.io/opencyphal/toxic:tx22.4.1 steps: - uses: actions/checkout@v3 with: submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: install-tox - run: pip3 install tox - name: lint run: tox -e lint - name: test-nnvg @@ -52,11 +48,9 @@ jobs: container: sonarsource/sonar-scanner-cli steps: - uses: actions/checkout@v3 - - name: sonar-cache - uses: actions/cache@v3 with: - path: /opt/sonar-scanner/.sonar/cache - key: sonar-scanner-cli-4.8.0.2856-${{ runner.os }} + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 - name: download-converage-reports uses: actions/download-artifact@v3 with: @@ -75,43 +69,34 @@ jobs: working-directory: .tox - name: report-release if: ${{ github.event_name != 'pull_request' }} + uses: sonarsource/sonarcloud-github-action@master env: - SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - sonar-scanner -X \ - -Dsonar.login=${{ env.SONARQUBE_TOKEN }} \ - -Dsonar.buildString=${{ env.GITHUB_RUN_ID }} \ - -Dsonar.projectVersion=${{ env.NUNAVUT_MAJOR_MINOR_VERSION }} \ - -Dsonar.python.version=python3.9 + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + with: + args: > + -Dsonar.login=${{ env.SONAR_TOKEN }} + -Dsonar.buildString=${{ env.GITHUB_RUN_ID }} + -Dsonar.projectVersion=${{ env.NUNAVUT_MAJOR_MINOR_VERSION }} + -Dsonar.python.version=python3.10 - name: report-pr if: ${{ github.event_name == 'pull_request' }} + uses: sonarsource/sonarcloud-github-action@master env: - SONARQUBE_TOKEN: 6526e88c286672a7852fea52056c4b6ea583aaf7 + SONAR_TOKEN: "6526e88c286672a7852fea52056c4b6ea583aaf7" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - sonar-scanner -X \ - -Dsonar.login=${{ env.SONARQUBE_TOKEN }} \ - -Dsonar.buildString=${{ env.GITHUB_RUN_ID }} \ - -Dsonar.projectVersion=${{ env.NUNAVUT_MAJOR_MINOR_VERSION }} \ - -Dsonar.python.version=python3.9 + with: + args: > + -Dsonar.login=${{ env.SONAR_TOKEN }} + -Dsonar.buildString=${{ env.GITHUB_RUN_ID }} + -Dsonar.projectVersion=${{ env.NUNAVUT_MAJOR_MINOR_VERSION }} + -Dsonar.python.version=python3.10 - compat-test-python3: + compat-test-python3-windows-and-mac: strategy: matrix: - python3-version: ['11'] - python3-platform: ['ubuntu-latest', 'windows-latest', 'macos-latest'] - include: - - python3-version: 6 - python3-platform: ubuntu-18.04 - - python3-version: 7 - python3-platform: ubuntu-20.04 - - python3-version: 8 - python3-platform: ubuntu-20.04 - - python3-version: 9 - python3-platform: ubuntu-20.04 - - python3-version: 10 - python3-platform: ubuntu-20.04 + python3-version: ['10','11'] + python3-platform: ['windows-latest', 'macos-latest'] runs-on: ${{ matrix.python3-platform }} needs: test steps: @@ -127,6 +112,20 @@ jobs: - name: python3.${{ matrix.python3-version }} test run: tox -e py3${{ matrix.python3-version }}-nnvg,py3${{ matrix.python3-version }}-test + compat-test-python3-ubuntu: + strategy: + matrix: + python3-version: ['7', '8', '9', '10', '11'] + runs-on: ubuntu-latest + container: ghcr.io/opencyphal/toxic:tx22.4.1 + needs: test + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: python3.${{ matrix.python3-version }} test + run: tox -e py3${{ matrix.python3-version }}-nnvg,py3${{ matrix.python3-version }}-test + language-verification-c: runs-on: ubuntu-latest needs: test diff --git a/.vscode/cmake-variants.json b/.vscode/cmake-variants.json index cafd912a..57add1d9 100644 --- a/.vscode/cmake-variants.json +++ b/.vscode/cmake-variants.json @@ -45,7 +45,8 @@ "short": "--std=c11", "long": "Compile and link using the C11 standard.", "settings": { - "NUNAVUT_VERIFICATION_LANG": "c" + "NUNAVUT_VERIFICATION_LANG": "c", + "NUNAVUT_VERIFICATION_LANG_STANDARD": "c11" } }, "C++14": { diff --git a/.vscode/extensions.json b/.vscode/extensions.json index da49b63d..9a828aa1 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,15 +2,9 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ - "ms-azuretools.vscode-docker", "uavcan.dsdl", "wholroyd.jinja", - "ban.spellright", - "ms-python.python", - "ms-vscode.cpptools", - "ms-vscode.cpptools-extension-pack", - "xaver.clang-format", - "hbenl.vscode-test-explorer", - "matepek.vscode-catch2-test-adapter" + "streetsidesoftware.code-spell-checker", + "ms-python.python" ] } diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index b0fb77d6..13a4390b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -72,8 +72,8 @@ To run the full suite of `tox`_ tests locally you'll need docker. Once you have and running do:: git submodule update --init --recursive - docker pull ghcr.io/opencyphal/toxic:tx20.4.1 - docker run --rm -v $PWD:/repo ghcr.io/opencyphal/toxic:tx20.4.1 tox + docker pull ghcr.io/opencyphal/toxic:tx22.4.1 + docker run --rm -v $PWD:/repo ghcr.io/opencyphal/toxic:tx22.4.1 tox To run a limited suite using only locally available interpreters directly on your host machine, skip the docker invocations and use ``tox -s``. @@ -187,7 +187,7 @@ Building The Docs We rely on `read the docs`_ to build our documentation from github but we also verify this build as part of our tox build. This means you can view a local copy after completing a full, successful test run (See `Running The Tests`_) or do -:code:`docker run --rm -t -v $PWD:/repo uavcan/toxic:py35-py39-sq /bin/sh -c "tox -e docs"` to build +:code:`docker run --rm -t -v $PWD:/repo ghcr.io/opencyphal/toxic:tx22.4.1 /bin/sh -c "tox -e docs"` to build the docs target. You can open the index.html under .tox/docs/tmp/index.html or run a local web-server:: diff --git a/docs/static/templates/footer.html b/docs/static/templates/footer.html index 2f9fcaaf..ff53452d 100644 --- a/docs/static/templates/footer.html +++ b/docs/static/templates/footer.html @@ -1,7 +1,7 @@ {% extends "!footer.html" %} {% block extrafooter %}
- +
  • OpenCyphal Website »
  • diff --git a/docs/templates.rst b/docs/templates.rst index fe5037bc..1f538ae2 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -306,10 +306,6 @@ C++ Filters :noindex: .. autofunction:: nunavut.lang.cpp.filter_declaration :noindex: -.. autofunction:: nunavut.lang.cpp.filter_definition_begin - :noindex: -.. autofunction:: nunavut.lang.cpp.filter_definition_end - :noindex: .. autofunction:: nunavut.lang.cpp.filter_to_namespace_qualifier :noindex: .. autofunction:: nunavut.lang.cpp.filter_type_from_primitive diff --git a/requirements.txt b/requirements.txt index 444307ea..f5b0d184 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,4 @@ # This file provided for readthedocs.io only. Use tox.ini for all dependencies. -sphinx >= 1.8.5 sphinx-argparse -sphinx_rtd_theme sphinxemoji diff --git a/src/nunavut/_version.py b/src/nunavut/_version.py index 11f5bf6c..8eb74fac 100644 --- a/src/nunavut/_version.py +++ b/src/nunavut/_version.py @@ -8,8 +8,8 @@ .. autodata:: __version__ """ -__version__ = "2.0.10" +__version__ = "2.1.0" __license__ = "MIT" __author__ = "OpenCyphal" -__copyright__ = "Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. Copyright (c) 2023 OpenCyphal." +__copyright__ = "Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Copyright (c) 2023 OpenCyphal." __email__ = "maintainers@opencyphal.org" diff --git a/src/nunavut/cli/__init__.py b/src/nunavut/cli/__init__.py index ed1c38a3..e3acfc46 100644 --- a/src/nunavut/cli/__init__.py +++ b/src/nunavut/cli/__init__.py @@ -108,9 +108,9 @@ def _make_parser() -> argparse.ArgumentParser: the vendor-specific namespace won't be able to use data types from the standard namespace. - Additional directories can also be specified through the environment variable - DSDL_INCLUDE_PATH, where the path entries are separated by colons ":" on posix - systems and ";" on Windows. + Additional directories can also be specified through an environment variable + DSDL_INCLUDE_PATH where the path entries are separated by colons ":" on + posix systems and ";" on Windows. """ ).lstrip(), @@ -562,9 +562,7 @@ def main() -> int: # extra_includes = args.lookup_dir - # legacy variable. We'll support this for a time. - extra_includes_from_env = _extra_includes_from_env("UAVCAN_DSDL_INCLUDE_PATH") - extra_includes_from_env += _extra_includes_from_env("DSDL_INCLUDE_PATH") + extra_includes_from_env = _extra_includes_from_env("DSDL_INCLUDE_PATH") extra_includes += sorted(extra_includes_from_env) from nunavut.cli.runners import ArgparseRunner diff --git a/src/nunavut/jinja/jinja2/loaders.py b/src/nunavut/jinja/jinja2/loaders.py index 1e17eeb2..e6e1a5f1 100644 --- a/src/nunavut/jinja/jinja2/loaders.py +++ b/src/nunavut/jinja/jinja2/loaders.py @@ -1,40 +1,44 @@ -# -*- coding: utf-8 -*- -""" - jinja2.loaders - ~~~~~~~~~~~~~~ - - Jinja loader classes. - - :copyright: (c) 2017 by the Jinja Team. - :license: BSD, see LICENSE for more details. +"""API and implementations for loading templates from different data +sources. """ +import importlib.util import os +import posixpath import sys +import typing as t import weakref -from types import ModuleType -from os import path +import zipimport +from collections import abc from hashlib import sha1 +from importlib import import_module +from types import ModuleType + from nunavut.jinja.jinja2.exceptions import TemplateNotFound -from nunavut.jinja.jinja2.utils import open_if_exists, internalcode -from nunavut.jinja.jinja2._compat import string_types, iteritems +from nunavut.jinja.jinja2.utils import internalcode + +if t.TYPE_CHECKING: + from .environment import Environment + from .environment import Template -def split_template_path(template): +def split_template_path(template: str) -> t.List[str]: """Split a path into segments and perform a sanity check. If it detects '..' in the path it will raise a `TemplateNotFound` error. """ pieces = [] - for piece in template.split('/'): - if path.sep in piece \ - or (path.altsep and path.altsep in piece) or \ - piece == path.pardir: + for piece in template.split("/"): + if ( + os.sep in piece + or (os.path.altsep and os.path.altsep in piece) + or piece == os.path.pardir + ): raise TemplateNotFound(template) - elif piece and piece != '.': + elif piece and piece != ".": pieces.append(piece) return pieces -class BaseLoader(object): +class BaseLoader: """Baseclass for all loaders. Subclass this and override `get_source` to implement a custom loading mechanism. The environment provides a `get_template` method that calls the loader's `load` method to get the @@ -43,7 +47,7 @@ class BaseLoader(object): A very basic example for a loader that looks up templates on the file system could look like this:: - from nunavut.jinja.jinja2 import BaseLoader, TemplateNotFound + from jinja2 import BaseLoader, TemplateNotFound from os.path import join, exists, getmtime class MyLoader(BaseLoader): @@ -56,8 +60,8 @@ def get_source(self, environment, template): if not exists(path): raise TemplateNotFound(template) mtime = getmtime(path) - with file(path) as f: - source = f.read().decode('utf-8') + with open(path) as f: + source = f.read() return source, path, lambda: mtime == getmtime(path) """ @@ -67,16 +71,18 @@ def get_source(self, environment, template): #: .. versionadded:: 2.4 has_source_access = True - def get_source(self, environment, template): + def get_source( + self, environment: "Environment", template: str + ) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]]: """Get the template source, filename and reload helper for a template. It's passed the environment and template name and has to return a tuple in the form ``(source, filename, uptodate)`` or raise a `TemplateNotFound` error if it can't locate the template. The source part of the returned tuple must be the source of the - template as unicode string or a ASCII bytestring. The filename should - be the name of the file on the filesystem if it was loaded from there, - otherwise `None`. The filename is used by python for the tracebacks + template as a string. The filename should be the name of the + file on the filesystem if it was loaded from there, otherwise + ``None``. The filename is used by Python for the tracebacks if no loader extension is used. The last item in the tuple is the `uptodate` function. If auto @@ -86,18 +92,24 @@ def get_source(self, environment, template): the template will be reloaded. """ if not self.has_source_access: - raise RuntimeError('%s cannot provide access to the source' % - self.__class__.__name__) + raise RuntimeError( + f"{type(self).__name__} cannot provide access to the source" + ) raise TemplateNotFound(template) - def list_templates(self): + def list_templates(self) -> t.List[str]: """Iterates over all templates. If the loader does not support that it should raise a :exc:`TypeError` which is the default behavior. """ - raise TypeError('this loader cannot iterate over all templates') + raise TypeError("this loader cannot iterate over all templates") @internalcode - def load(self, environment, name, globals=None): + def load( + self, + environment: "Environment", + name: str, + globals: t.Optional[t.MutableMapping[str, t.Any]] = None, + ) -> "Template": """Loads a template. This method looks up the template in the cache or loads one by calling :meth:`get_source`. Subclasses should not override this method as loaders working on collections of other @@ -131,71 +143,94 @@ def load(self, environment, name, globals=None): bucket.code = code bcc.set_bucket(bucket) - return environment.template_class.from_code(environment, code, - globals, uptodate) + return environment.template_class.from_code( + environment, code, globals, uptodate + ) class FileSystemLoader(BaseLoader): - """Loads templates from the file system. This loader can find templates - in folders on the file system and is the preferred way to load them. + """Load templates from a directory in the file system. - The loader takes the path to the templates as string, or if multiple - locations are wanted a list of them which is then looked up in the - given order:: + The path can be relative or absolute. Relative paths are relative to + the current working directory. - >>> loader = FileSystemLoader('/path/to/templates') - >>> loader = FileSystemLoader(['/path/to/templates', '/other/path']) + .. code-block:: python - Per default the template encoding is ``'utf-8'`` which can be changed - by setting the `encoding` parameter to something else. + loader = FileSystemLoader("templates") - To follow symbolic links, set the *followlinks* parameter to ``True``:: + A list of paths can be given. The directories will be searched in + order, stopping at the first matching template. - >>> loader = FileSystemLoader('/path/to/templates', followlinks=True) + .. code-block:: python - .. versionchanged:: 2.8+ - The *followlinks* parameter was added. + loader = FileSystemLoader(["/override/templates", "/default/templates"]) + + :param searchpath: A path, or list of paths, to the directory that + contains the templates. + :param encoding: Use this encoding to read the text from template + files. + :param followlinks: Follow symbolic links in the path. + + .. versionchanged:: 2.8 + Added the ``followlinks`` parameter. """ - def __init__(self, searchpath, encoding='utf-8', followlinks=False): - if isinstance(searchpath, string_types): + def __init__( + self, + searchpath: t.Union[ + str, "os.PathLike[str]", t.Sequence[t.Union[str, "os.PathLike[str]"]] + ], + encoding: str = "utf-8", + followlinks: bool = False, + ) -> None: + if not isinstance(searchpath, abc.Iterable) or isinstance(searchpath, str): searchpath = [searchpath] - self.searchpath = list(searchpath) + + self.searchpath = [os.fspath(p) for p in searchpath] self.encoding = encoding self.followlinks = followlinks - def get_source(self, environment, template): + def get_source( + self, environment: "Environment", template: str + ) -> t.Tuple[str, str, t.Callable[[], bool]]: pieces = split_template_path(template) + for searchpath in self.searchpath: - filename = path.join(searchpath, *pieces) - f = open_if_exists(filename) - if f is None: - continue + # Use posixpath even on Windows to avoid "drive:" or UNC + # segments breaking out of the search directory. + filename = posixpath.join(searchpath, *pieces) + + if os.path.isfile(filename): + break + else: + raise TemplateNotFound(template) + + with open(filename, encoding=self.encoding) as f: + contents = f.read() + + mtime = os.path.getmtime(filename) + + def uptodate() -> bool: try: - contents = f.read().decode(self.encoding) - finally: - f.close() - - mtime = path.getmtime(filename) - - def uptodate(): - try: - return path.getmtime(filename) == mtime - except OSError: - return False - return contents, filename, uptodate - raise TemplateNotFound(template) + return os.path.getmtime(filename) == mtime + except OSError: + return False + + # Use normpath to convert Windows altsep to sep. + return contents, os.path.normpath(filename), uptodate - def list_templates(self): + def list_templates(self) -> t.List[str]: found = set() for searchpath in self.searchpath: walk_dir = os.walk(searchpath, followlinks=self.followlinks) - for dirpath, dirnames, filenames in walk_dir: + for dirpath, _, filenames in walk_dir: for filename in filenames: - template = os.path.join(dirpath, filename) \ - [len(searchpath):].strip(os.path.sep) \ - .replace(os.path.sep, '/') - if template[:2] == './': + template = ( + os.path.join(dirpath, filename)[len(searchpath) :] + .strip(os.sep) + .replace(os.sep, "/") + ) + if template[:2] == "./": template = template[2:] if template not in found: found.add(template) @@ -203,96 +238,196 @@ def list_templates(self): class PackageLoader(BaseLoader): - """Load templates from python eggs or packages. It is constructed with - the name of the python package and the path to the templates in that - package:: + """Load templates from a directory in a Python package. - loader = PackageLoader('mypackage', 'views') + :param package_name: Import name of the package that contains the + template directory. + :param package_path: Directory within the imported package that + contains the templates. + :param encoding: Encoding of template files. - If the package path is not given, ``'templates'`` is assumed. + The following example looks up templates in the ``pages`` directory + within the ``project.ui`` package. - Per default the template encoding is ``'utf-8'`` which can be changed - by setting the `encoding` parameter to something else. Due to the nature - of eggs it's only possible to reload templates if the package was loaded - from the file system and not a zip file. + .. code-block:: python + + loader = PackageLoader("project.ui", "pages") + + Only packages installed as directories (standard pip behavior) or + zip/egg files (less common) are supported. The Python API for + introspecting data in packages is too limited to support other + installation methods the way this loader requires. + + There is limited support for :pep:`420` namespace packages. The + template directory is assumed to only be in one namespace + contributor. Zip files contributing to a namespace are not + supported. + + .. versionchanged:: 3.0 + No longer uses ``setuptools`` as a dependency. + + .. versionchanged:: 3.0 + Limited PEP 420 namespace package support. """ - def __init__(self, package_name, package_path='templates', - encoding='utf-8'): - from pkg_resources import DefaultProvider, ResourceManager, \ - get_provider - provider = get_provider(package_name) - self.encoding = encoding - self.manager = ResourceManager() - self.filesystem_bound = isinstance(provider, DefaultProvider) - self.provider = provider + def __init__( + self, + package_name: str, + package_path: "str" = "templates", + encoding: str = "utf-8", + ) -> None: + package_path = os.path.normpath(package_path).rstrip(os.sep) + + # normpath preserves ".", which isn't valid in zip paths. + if package_path == os.path.curdir: + package_path = "" + elif package_path[:2] == os.path.curdir + os.sep: + package_path = package_path[2:] + self.package_path = package_path + self.package_name = package_name + self.encoding = encoding - def get_source(self, environment, template): - pieces = split_template_path(template) - p = '/'.join((self.package_path,) + tuple(pieces)) - if not self.provider.has_resource(p): - raise TemplateNotFound(template) + # Make sure the package exists. This also makes namespace + # packages work, otherwise get_loader returns None. + import_module(package_name) + spec = importlib.util.find_spec(package_name) + assert spec is not None, "An import spec was not found for the package." + loader = spec.loader + assert loader is not None, "A loader was not found for the package." + self._loader = loader + self._archive = None + template_root = None + + if isinstance(loader, zipimport.zipimporter): + self._archive = loader.archive + pkgdir = next(iter(spec.submodule_search_locations)) # type: ignore + template_root = os.path.join(pkgdir, package_path).rstrip(os.sep) + else: + roots: t.List[str] = [] + + # One element for regular packages, multiple for namespace + # packages, or None for single module file. + if spec.submodule_search_locations: + roots.extend(spec.submodule_search_locations) + # A single module file, use the parent directory instead. + elif spec.origin is not None: + roots.append(os.path.dirname(spec.origin)) + + for root in roots: + root = os.path.join(root, package_path) + + if os.path.isdir(root): + template_root = root + break + + if template_root is None: + raise ValueError( + f"The {package_name!r} package was not installed in a" + " way that PackageLoader understands." + ) + + self._template_root = template_root + + def get_source( + self, environment: "Environment", template: str + ) -> t.Tuple[str, str, t.Optional[t.Callable[[], bool]]]: + # Use posixpath even on Windows to avoid "drive:" or UNC + # segments breaking out of the search directory. Use normpath to + # convert Windows altsep to sep. + p = os.path.normpath( + posixpath.join(self._template_root, *split_template_path(template)) + ) + up_to_date: t.Optional[t.Callable[[], bool]] + + if self._archive is None: + # Package is a directory. + if not os.path.isfile(p): + raise TemplateNotFound(template) + + with open(p, "rb") as f: + source = f.read() + + mtime = os.path.getmtime(p) + + def up_to_date() -> bool: + return os.path.isfile(p) and os.path.getmtime(p) == mtime + + else: + # Package is a zip file. + try: + source = self._loader.get_data(p) # type: ignore + except OSError as e: + raise TemplateNotFound(template) from e + + # Could use the zip's mtime for all template mtimes, but + # would need to safely reload the module if it's out of + # date, so just report it as always current. + up_to_date = None + + return source.decode(self.encoding), p, up_to_date + + def list_templates(self) -> t.List[str]: + results: t.List[str] = [] + + if self._archive is None: + # Package is a directory. + offset = len(self._template_root) + + for dirpath, _, filenames in os.walk(self._template_root): + dirpath = dirpath[offset:].lstrip(os.sep) + results.extend( + os.path.join(dirpath, name).replace(os.sep, "/") + for name in filenames + ) + else: + if not hasattr(self._loader, "_files"): + raise TypeError( + "This zip import does not have the required" + " metadata to list templates." + ) + + # Package is a zip file. + prefix = self._template_root[len(self._archive) :].lstrip(os.sep) + os.sep + offset = len(prefix) + + for name in self._loader._files.keys(): + # Find names under the templates directory that aren't directories. + if name.startswith(prefix) and name[-1] != os.sep: + results.append(name[offset:].replace(os.sep, "/")) - filename = uptodate = None - if self.filesystem_bound: - filename = self.provider.get_resource_filename(self.manager, p) - mtime = path.getmtime(filename) - def uptodate(): - try: - return path.getmtime(filename) == mtime - except OSError: - return False - - source = self.provider.get_resource_string(self.manager, p) - return source.decode(self.encoding), filename, uptodate - - def list_templates(self): - path = self.package_path - if path[:2] == './': - path = path[2:] - elif path == '.': - path = '' - offset = len(path) - results = [] - def _walk(path): - for filename in self.provider.resource_listdir(path): - fullname = path + '/' + filename - if self.provider.resource_isdir(fullname): - _walk(fullname) - else: - results.append(fullname[offset:].lstrip('/')) - _walk(path) results.sort() return results class DictLoader(BaseLoader): - """Loads a template from a python dict. It's passed a dict of unicode - strings bound to template names. This loader is useful for unittesting: + """Loads a template from a Python dict mapping template names to + template source. This loader is useful for unittesting: >>> loader = DictLoader({'index.html': 'source here'}) Because auto reloading is rarely useful this is disabled per default. """ - def __init__(self, mapping): + def __init__(self, mapping: t.Mapping[str, str]) -> None: self.mapping = mapping - def get_source(self, environment, template): + def get_source( + self, environment: "Environment", template: str + ) -> t.Tuple[str, None, t.Callable[[], bool]]: if template in self.mapping: source = self.mapping[template] return source, None, lambda: source == self.mapping.get(template) raise TemplateNotFound(template) - def list_templates(self): + def list_templates(self) -> t.List[str]: return sorted(self.mapping) class FunctionLoader(BaseLoader): """A loader that is passed a function which does the loading. The function receives the name of the template and has to return either - an unicode string with the template source, a tuple in the form ``(source, + a string with the template source, a tuple in the form ``(source, filename, uptodatefunc)`` or `None` if the template does not exist. >>> def load_template(name): @@ -307,15 +442,30 @@ class FunctionLoader(BaseLoader): return value. """ - def __init__(self, load_func): + def __init__( + self, + load_func: t.Callable[ + [str], + t.Optional[ + t.Union[ + str, t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]] + ] + ], + ], + ) -> None: self.load_func = load_func - def get_source(self, environment, template): + def get_source( + self, environment: "Environment", template: str + ) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]]: rv = self.load_func(template) + if rv is None: raise TemplateNotFound(template) - elif isinstance(rv, string_types): + + if isinstance(rv, str): return rv, None, None + return rv @@ -334,40 +484,49 @@ class PrefixLoader(BaseLoader): by loading ``'app2/index.html'`` the file from the second. """ - def __init__(self, mapping, delimiter='/'): + def __init__( + self, mapping: t.Mapping[str, BaseLoader], delimiter: str = "/" + ) -> None: self.mapping = mapping self.delimiter = delimiter - def get_loader(self, template): + def get_loader(self, template: str) -> t.Tuple[BaseLoader, str]: try: prefix, name = template.split(self.delimiter, 1) loader = self.mapping[prefix] - except (ValueError, KeyError): - raise TemplateNotFound(template) + except (ValueError, KeyError) as e: + raise TemplateNotFound(template) from e return loader, name - def get_source(self, environment, template): + def get_source( + self, environment: "Environment", template: str + ) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]]: loader, name = self.get_loader(template) try: return loader.get_source(environment, name) - except TemplateNotFound: + except TemplateNotFound as e: # re-raise the exception with the correct filename here. # (the one that includes the prefix) - raise TemplateNotFound(template) + raise TemplateNotFound(template) from e @internalcode - def load(self, environment, name, globals=None): + def load( + self, + environment: "Environment", + name: str, + globals: t.Optional[t.MutableMapping[str, t.Any]] = None, + ) -> "Template": loader, local_name = self.get_loader(name) try: return loader.load(environment, local_name, globals) - except TemplateNotFound: + except TemplateNotFound as e: # re-raise the exception with the correct filename here. # (the one that includes the prefix) - raise TemplateNotFound(name) + raise TemplateNotFound(name) from e - def list_templates(self): + def list_templates(self) -> t.List[str]: result = [] - for prefix, loader in iteritems(self.mapping): + for prefix, loader in self.mapping.items(): for template in loader.list_templates(): result.append(prefix + self.delimiter + template) return result @@ -387,10 +546,12 @@ class ChoiceLoader(BaseLoader): from a different location. """ - def __init__(self, loaders): + def __init__(self, loaders: t.Sequence[BaseLoader]) -> None: self.loaders = loaders - def get_source(self, environment, template): + def get_source( + self, environment: "Environment", template: str + ) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]]: for loader in self.loaders: try: return loader.get_source(environment, template) @@ -399,7 +560,12 @@ def get_source(self, environment, template): raise TemplateNotFound(template) @internalcode - def load(self, environment, name, globals=None): + def load( + self, + environment: "Environment", + name: str, + globals: t.Optional[t.MutableMapping[str, t.Any]] = None, + ) -> "Template": for loader in self.loaders: try: return loader.load(environment, name, globals) @@ -407,7 +573,7 @@ def load(self, environment, name, globals=None): pass raise TemplateNotFound(name) - def list_templates(self): + def list_templates(self) -> t.List[str]: found = set() for loader in self.loaders: found.update(loader.list_templates()) @@ -433,20 +599,26 @@ class ModuleLoader(BaseLoader): has_source_access = False - def __init__(self, path): - package_name = '_jinja2_module_templates_%x' % id(self) + def __init__( + self, + path: t.Union[ + str, "os.PathLike[str]", t.Sequence[t.Union[str, "os.PathLike[str]"]] + ], + ) -> None: + package_name = f"_jinja2_module_templates_{id(self):x}" # create a fake module that looks for the templates in the # path given. mod = _TemplateModule(package_name) - if isinstance(path, string_types): + + if not isinstance(path, abc.Iterable) or isinstance(path, str): path = [path] - else: - path = list(path) - mod.__path__ = path - sys.modules[package_name] = weakref.proxy(mod, - lambda x: sys.modules.pop(package_name, None)) + mod.__path__ = [os.fspath(p) for p in path] + + sys.modules[package_name] = weakref.proxy( + mod, lambda x: sys.modules.pop(package_name, None) + ) # the only strong reference, the sys.modules entry is weak # so that the garbage collector can remove it once the @@ -455,27 +627,37 @@ def __init__(self, path): self.package_name = package_name @staticmethod - def get_template_key(name): - return 'tmpl_' + sha1(name.encode('utf-8')).hexdigest() + def get_template_key(name: str) -> str: + return "tmpl_" + sha1(name.encode("utf-8")).hexdigest() @staticmethod - def get_module_filename(name): - return ModuleLoader.get_template_key(name) + '.py' + def get_module_filename(name: str) -> str: + return ModuleLoader.get_template_key(name) + ".py" @internalcode - def load(self, environment, name, globals=None): + def load( + self, + environment: "Environment", + name: str, + globals: t.Optional[t.MutableMapping[str, t.Any]] = None, + ) -> "Template": key = self.get_template_key(name) - module = '%s.%s' % (self.package_name, key) + module = f"{self.package_name}.{key}" mod = getattr(self.module, module, None) + if mod is None: try: - mod = __import__(module, None, None, ['root']) - except ImportError: - raise TemplateNotFound(name) + mod = __import__(module, None, None, ["root"]) + except ImportError as e: + raise TemplateNotFound(name) from e # remove the entry from sys.modules, we only want the attribute # on the module object we have stored on the loader. sys.modules.pop(module, None) + if globals is None: + globals = {} + return environment.template_class.from_module_dict( - environment, mod.__dict__, globals) + environment, mod.__dict__, globals + ) diff --git a/src/nunavut/lang/cpp/templates/deserialization.j2 b/src/nunavut/lang/cpp/templates/deserialization.j2 index 8151e1dd..397a8332 100644 --- a/src/nunavut/lang/cpp/templates/deserialization.j2 +++ b/src/nunavut/lang/cpp/templates/deserialization.j2 @@ -201,15 +201,15 @@ {% endif %} {# GENERAL CASE #} {% set ref_index = 'index'|to_template_unique_name %} + {% set tmp_element = 'tmp'|to_template_unique_name %} for ({{ typename_unsigned_length }} {{ ref_index }} = 0U; {{ ref_index }} < {{ ref_size }}; ++{{ ref_index }}) { - // TODO This is terribly inefficient. We need to completely refactor this template to use C++ emplace and - // move semantics instead of assuming C-style containers - {{ reference }}.push_back(); + {{ t.element_type | declaration }} {{ tmp_element }} = {{ t.element_type | declaration }}(); {{ - _deserialize_any(t.element_type, reference + ('[%s]'|format(ref_index)), element_offset) + _deserialize_any(t.element_type, tmp_element, element_offset) |trim|indent }} + {{ reference }}.push_back(std::move({{ tmp_element }})); } } diff --git a/src/nunavut/lang/html/support/__init__.py b/src/nunavut/lang/html/support/__init__.py new file mode 100644 index 00000000..f5c35ff9 --- /dev/null +++ b/src/nunavut/lang/html/support/__init__.py @@ -0,0 +1,19 @@ +# +# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright (C) 2018-2020 OpenCyphal Development Team +# This software is distributed under the terms of the MIT License. +# +""" +Empty python package to ensure the support generator doesn't explode. +""" +import pathlib +import typing + +from nunavut._utilities import ResourceType, empty_list_support_files + +__version__ = "1.0.0" +"""Version of the html support headers.""" + + +def list_support_files(resource_type: ResourceType = ResourceType.ANY) -> typing.Generator[pathlib.Path, None, None]: + return empty_list_support_files() diff --git a/src/nunavut/lang/js/support/__init__.py b/src/nunavut/lang/js/support/__init__.py new file mode 100644 index 00000000..9f0dfc3c --- /dev/null +++ b/src/nunavut/lang/js/support/__init__.py @@ -0,0 +1,19 @@ +# +# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright (C) 2018-2020 OpenCyphal Development Team +# This software is distributed under the terms of the MIT License. +# +""" +Empty python package to ensure the support generator doesn't explode. +""" +import pathlib +import typing + +from nunavut._utilities import ResourceType, empty_list_support_files + +__version__ = "1.0.0" +"""Version of the js support headers.""" + + +def list_support_files(resource_type: ResourceType = ResourceType.ANY) -> typing.Generator[pathlib.Path, None, None]: + return empty_list_support_files() diff --git a/src/nunavut/lang/py/support/__init__.py b/src/nunavut/lang/py/support/__init__.py new file mode 100644 index 00000000..8ff6165b --- /dev/null +++ b/src/nunavut/lang/py/support/__init__.py @@ -0,0 +1,19 @@ +# +# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# Copyright (C) 2018-2020 OpenCyphal Development Team +# This software is distributed under the terms of the MIT License. +# +""" +Empty python package to ensure the support generator doesn't explode. +""" +import pathlib +import typing + +from nunavut._utilities import ResourceType, empty_list_support_files + +__version__ = "1.0.0" +"""Version of the py support headers.""" + + +def list_support_files(resource_type: ResourceType = ResourceType.ANY) -> typing.Generator[pathlib.Path, None, None]: + return empty_list_support_files() diff --git a/test/gentest_any/dsdl/uavcan/time/510.GetSynchronizationMasterInfo.0.1.uavcan b/test/gentest_any/dsdl/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl similarity index 100% rename from test/gentest_any/dsdl/uavcan/time/510.GetSynchronizationMasterInfo.0.1.uavcan rename to test/gentest_any/dsdl/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl diff --git a/test/gentest_any/dsdl/uavcan/time/7168.Synchronization.1.0.uavcan b/test/gentest_any/dsdl/uavcan/time/7168.Synchronization.1.0.dsdl similarity index 100% rename from test/gentest_any/dsdl/uavcan/time/7168.Synchronization.1.0.uavcan rename to test/gentest_any/dsdl/uavcan/time/7168.Synchronization.1.0.dsdl diff --git a/test/gentest_any/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.uavcan b/test/gentest_any/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.dsdl similarity index 100% rename from test/gentest_any/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.uavcan rename to test/gentest_any/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.dsdl diff --git a/test/gentest_any/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan b/test/gentest_any/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl similarity index 100% rename from test/gentest_any/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan rename to test/gentest_any/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl diff --git a/test/gentest_any/dsdl/uavcan/time/TimeSystem.0.1.uavcan b/test/gentest_any/dsdl/uavcan/time/TimeSystem.0.1.dsdl similarity index 100% rename from test/gentest_any/dsdl/uavcan/time/TimeSystem.0.1.uavcan rename to test/gentest_any/dsdl/uavcan/time/TimeSystem.0.1.dsdl diff --git a/test/gentest_arrays/dsdl/radar/Phased.0.1.uavcan b/test/gentest_arrays/dsdl/radar/Phased.0.1.dsdl similarity index 100% rename from test/gentest_arrays/dsdl/radar/Phased.0.1.uavcan rename to test/gentest_arrays/dsdl/radar/Phased.0.1.dsdl diff --git a/test/gentest_filters/dsdl/new/hotness.1.0.uavcan b/test/gentest_filters/dsdl/new/hotness.1.0.dsdl similarity index 100% rename from test/gentest_filters/dsdl/new/hotness.1.0.uavcan rename to test/gentest_filters/dsdl/new/hotness.1.0.dsdl diff --git a/test/gentest_filters/dsdl/new/malloc.1.0.uavcan b/test/gentest_filters/dsdl/new/malloc.1.0.dsdl similarity index 100% rename from test/gentest_filters/dsdl/new/malloc.1.0.uavcan rename to test/gentest_filters/dsdl/new/malloc.1.0.dsdl diff --git a/test/gentest_filters/dsdl/one/foo.1.0.uavcan b/test/gentest_filters/dsdl/one/foo.1.0.dsdl similarity index 100% rename from test/gentest_filters/dsdl/one/foo.1.0.uavcan rename to test/gentest_filters/dsdl/one/foo.1.0.dsdl diff --git a/test/gentest_filters/dsdl/uavcan/str/7168.bar.1.0.uavcan b/test/gentest_filters/dsdl/uavcan/str/7168.bar.1.0.dsdl similarity index 100% rename from test/gentest_filters/dsdl/uavcan/str/7168.bar.1.0.uavcan rename to test/gentest_filters/dsdl/uavcan/str/7168.bar.1.0.dsdl diff --git a/test/gentest_filters/dsdl/uavcan/str/bar_svc.1.0.uavcan b/test/gentest_filters/dsdl/uavcan/str/bar_svc.1.0.dsdl similarity index 100% rename from test/gentest_filters/dsdl/uavcan/str/bar_svc.1.0.uavcan rename to test/gentest_filters/dsdl/uavcan/str/bar_svc.1.0.dsdl diff --git a/test/gentest_filters/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan b/test/gentest_filters/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl similarity index 100% rename from test/gentest_filters/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan rename to test/gentest_filters/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl diff --git a/test/gentest_filters/dsdl/vla/uses_vla.0.1.uavcan b/test/gentest_filters/dsdl/vla/uses_vla.0.1.dsdl similarity index 100% rename from test/gentest_filters/dsdl/vla/uses_vla.0.1.uavcan rename to test/gentest_filters/dsdl/vla/uses_vla.0.1.dsdl diff --git a/test/gentest_json/dsdl/uavcan/test/7168.TestType.0.1.uavcan b/test/gentest_json/dsdl/uavcan/test/7168.TestType.0.1.dsdl similarity index 100% rename from test/gentest_json/dsdl/uavcan/test/7168.TestType.0.1.uavcan rename to test/gentest_json/dsdl/uavcan/test/7168.TestType.0.1.dsdl diff --git a/test/gentest_lang/dsdl/langtest/c/7168.TestType.0.1.uavcan b/test/gentest_lang/dsdl/langtest/c/7168.TestType.0.1.dsdl similarity index 100% rename from test/gentest_lang/dsdl/langtest/c/7168.TestType.0.1.uavcan rename to test/gentest_lang/dsdl/langtest/c/7168.TestType.0.1.dsdl diff --git a/test/gentest_lang/dsdl/langtest/cpp/ns/7169.TestType.0.1.uavcan b/test/gentest_lang/dsdl/langtest/cpp/ns/7169.TestType.0.1.dsdl similarity index 100% rename from test/gentest_lang/dsdl/langtest/cpp/ns/7169.TestType.0.1.uavcan rename to test/gentest_lang/dsdl/langtest/cpp/ns/7169.TestType.0.1.dsdl diff --git a/test/gentest_lang/dsdl/langtest/py/7170.TestType.0.1.uavcan b/test/gentest_lang/dsdl/langtest/py/7170.TestType.0.1.dsdl similarity index 100% rename from test/gentest_lang/dsdl/langtest/py/7170.TestType.0.1.uavcan rename to test/gentest_lang/dsdl/langtest/py/7170.TestType.0.1.dsdl diff --git a/test/gentest_lookup/dsdl/uavcan/time/7168.Synchronization.1.0.uavcan b/test/gentest_lookup/dsdl/uavcan/time/7168.Synchronization.1.0.dsdl similarity index 100% rename from test/gentest_lookup/dsdl/uavcan/time/7168.Synchronization.1.0.uavcan rename to test/gentest_lookup/dsdl/uavcan/time/7168.Synchronization.1.0.dsdl diff --git a/test/gentest_lookup/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.uavcan b/test/gentest_lookup/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.dsdl similarity index 100% rename from test/gentest_lookup/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.uavcan rename to test/gentest_lookup/dsdl/uavcan/time/SynchronizedAmbiguousTimestamp.1.0.dsdl diff --git a/test/gentest_lookup/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan b/test/gentest_lookup/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl similarity index 100% rename from test/gentest_lookup/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan rename to test/gentest_lookup/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl diff --git a/test/gentest_lookup/dsdl/uavcan/time/TimeSystem.0.1.uavcan b/test/gentest_lookup/dsdl/uavcan/time/TimeSystem.0.1.dsdl similarity index 100% rename from test/gentest_lookup/dsdl/uavcan/time/TimeSystem.0.1.uavcan rename to test/gentest_lookup/dsdl/uavcan/time/TimeSystem.0.1.dsdl diff --git a/test/gentest_multiple/dsdl/esmeinc/DaughterType.0.1.uavcan b/test/gentest_multiple/dsdl/esmeinc/DaughterType.0.1.dsdl similarity index 100% rename from test/gentest_multiple/dsdl/esmeinc/DaughterType.0.1.uavcan rename to test/gentest_multiple/dsdl/esmeinc/DaughterType.0.1.dsdl diff --git a/test/gentest_multiple/dsdl/huckco/SonType.0.1.uavcan b/test/gentest_multiple/dsdl/huckco/SonType.0.1.dsdl similarity index 100% rename from test/gentest_multiple/dsdl/huckco/SonType.0.1.uavcan rename to test/gentest_multiple/dsdl/huckco/SonType.0.1.dsdl diff --git a/test/gentest_multiple/dsdl/scotec/FatherType.0.1.uavcan b/test/gentest_multiple/dsdl/scotec/FatherType.0.1.dsdl similarity index 100% rename from test/gentest_multiple/dsdl/scotec/FatherType.0.1.uavcan rename to test/gentest_multiple/dsdl/scotec/FatherType.0.1.dsdl diff --git a/test/gentest_namespaces/dsdl/scotec/mcu/Timer.0.1.uavcan b/test/gentest_namespaces/dsdl/scotec/mcu/Timer.0.1.dsdl similarity index 100% rename from test/gentest_namespaces/dsdl/scotec/mcu/Timer.0.1.uavcan rename to test/gentest_namespaces/dsdl/scotec/mcu/Timer.0.1.dsdl diff --git a/test/gentest_namespaces/dsdl/scotec/typedef/str/ATOMIC_TYPE.0.1.uavcan b/test/gentest_namespaces/dsdl/scotec/typedef/str/ATOMIC_TYPE.0.1.dsdl similarity index 100% rename from test/gentest_namespaces/dsdl/scotec/typedef/str/ATOMIC_TYPE.0.1.uavcan rename to test/gentest_namespaces/dsdl/scotec/typedef/str/ATOMIC_TYPE.0.1.dsdl diff --git a/test/gentest_namespaces/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan b/test/gentest_namespaces/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl similarity index 100% rename from test/gentest_namespaces/dsdl/uavcan/time/SynchronizedTimestamp.1.0.uavcan rename to test/gentest_namespaces/dsdl/uavcan/time/SynchronizedTimestamp.1.0.dsdl diff --git a/test/gentest_nnvg/dsdl/fixedid/100.Timer.1.0.uavcan b/test/gentest_nnvg/dsdl/fixedid/100.Timer.1.0.dsdl similarity index 100% rename from test/gentest_nnvg/dsdl/fixedid/100.Timer.1.0.uavcan rename to test/gentest_nnvg/dsdl/fixedid/100.Timer.1.0.dsdl diff --git a/test/gentest_nnvg/dsdl/herringtec/TImer.2.1.uavcan b/test/gentest_nnvg/dsdl/herringtec/TImer.2.1.dsdl similarity index 100% rename from test/gentest_nnvg/dsdl/herringtec/TImer.2.1.uavcan rename to test/gentest_nnvg/dsdl/herringtec/TImer.2.1.dsdl diff --git a/test/gentest_nnvg/dsdl/scotec/Timer.1.0.uavcan b/test/gentest_nnvg/dsdl/scotec/Timer.1.0.dsdl similarity index 100% rename from test/gentest_nnvg/dsdl/scotec/Timer.1.0.uavcan rename to test/gentest_nnvg/dsdl/scotec/Timer.1.0.dsdl diff --git a/test/gentest_nnvg/dsdl/uavcan/test/TestType.0.8.uavcan b/test/gentest_nnvg/dsdl/uavcan/test/TestType.0.8.dsdl similarity index 100% rename from test/gentest_nnvg/dsdl/uavcan/test/TestType.0.8.uavcan rename to test/gentest_nnvg/dsdl/uavcan/test/TestType.0.8.dsdl diff --git a/test/gentest_nnvg/test_nnvg.py b/test/gentest_nnvg/test_nnvg.py index 58c42e48..15d04c72 100644 --- a/test/gentest_nnvg/test_nnvg.py +++ b/test/gentest_nnvg/test_nnvg.py @@ -16,8 +16,8 @@ from nunavut.lang._language import LanguageClassLoader -@pytest.mark.parametrize("env_var_name", ["UAVCAN_DSDL_INCLUDE_PATH", "DSDL_INCLUDE_PATH"]) -def test_UAVCAN_DSDL_INCLUDE_PATH(gen_paths: typing.Any, run_nnvg: typing.Callable, env_var_name: str) -> None: +@pytest.mark.parametrize("env_var_name", ["DSDL_INCLUDE_PATH"]) +def test_DSDL_INCLUDE_PATH(gen_paths: typing.Any, run_nnvg: typing.Callable, env_var_name: str) -> None: """ Verify that supported environment variables are used by nnvg. """ @@ -71,7 +71,7 @@ def test_list_inputs(gen_paths: typing.Any, run_nnvg: typing.Callable, generate_ """ expected_output = [ gen_paths.templates_dir / pathlib.Path("Any.j2"), - gen_paths.dsdl_dir / pathlib.Path("uavcan") / pathlib.Path("test") / pathlib.Path("TestType.0.8.uavcan"), + gen_paths.dsdl_dir / pathlib.Path("uavcan") / pathlib.Path("test") / pathlib.Path("TestType.0.8.dsdl"), ] expected_serialization_support_outputs = [ @@ -81,7 +81,7 @@ def test_list_inputs(gen_paths: typing.Any, run_nnvg: typing.Callable, generate_ / pathlib.Path("serialization").with_suffix(".j2") ] - # when #58 is fixed `(gen_paths.dsdl_dir / pathlib.Path('scotec') / pathlib.Path('Timer.1.0.uavcan')).as_posix()` + # when #58 is fixed `(gen_paths.dsdl_dir / pathlib.Path('scotec') / pathlib.Path('Timer.1.0.dsdl')).as_posix()` # should be added to this list. nnvg_args = [ "--templates", @@ -114,13 +114,13 @@ def test_list_inputs_w_namespaces(gen_paths: typing.Any, run_nnvg: typing.Callab expected_output = sorted( [ gen_paths.templates_dir / pathlib.Path("Any.j2"), - gen_paths.dsdl_dir / pathlib.Path("uavcan") / pathlib.Path("test") / pathlib.Path("TestType.0.8.uavcan"), + gen_paths.dsdl_dir / pathlib.Path("uavcan") / pathlib.Path("test") / pathlib.Path("TestType.0.8.dsdl"), gen_paths.dsdl_dir / pathlib.Path("uavcan"), gen_paths.dsdl_dir / pathlib.Path("uavcan") / pathlib.Path("test"), ] ) - # when #58 is fixed `(gen_paths.dsdl_dir / pathlib.Path('scotec') / pathlib.Path('Timer.1.0.uavcan')).as_posix()` + # when #58 is fixed `(gen_paths.dsdl_dir / pathlib.Path('scotec') / pathlib.Path('Timer.1.0.dsdl')).as_posix()` # and `(gen_paths.dsdl_dir / pathlib.Path('scotec').as_posix()` should be added to this list. nnvg_args = [ "--templates", diff --git a/test/gentest_postprocessors/dsdl/uavcan/test/TestType.0.2.uavcan b/test/gentest_postprocessors/dsdl/uavcan/test/TestType.0.2.dsdl similarity index 100% rename from test/gentest_postprocessors/dsdl/uavcan/test/TestType.0.2.uavcan rename to test/gentest_postprocessors/dsdl/uavcan/test/TestType.0.2.dsdl diff --git a/test/gentest_serialization/dsdl/basic/1.HelloSerialization.1.0.uavcan b/test/gentest_serialization/dsdl/basic/1.HelloSerialization.1.0.dsdl similarity index 100% rename from test/gentest_serialization/dsdl/basic/1.HelloSerialization.1.0.uavcan rename to test/gentest_serialization/dsdl/basic/1.HelloSerialization.1.0.dsdl diff --git a/test/gentest_serialization/dsdl/basic/Basic.1.0.uavcan b/test/gentest_serialization/dsdl/basic/Basic.1.0.dsdl similarity index 100% rename from test/gentest_serialization/dsdl/basic/Basic.1.0.uavcan rename to test/gentest_serialization/dsdl/basic/Basic.1.0.dsdl diff --git a/test/gentest_serialization/dsdl/complex/2.KitchenSink.1.0.uavcan b/test/gentest_serialization/dsdl/complex/2.KitchenSink.1.0.dsdl similarity index 100% rename from test/gentest_serialization/dsdl/complex/2.KitchenSink.1.0.uavcan rename to test/gentest_serialization/dsdl/complex/2.KitchenSink.1.0.dsdl diff --git a/test/gentest_serialization/dsdl/complex/Nested.1.0.uavcan b/test/gentest_serialization/dsdl/complex/Nested.1.0.dsdl similarity index 100% rename from test/gentest_serialization/dsdl/complex/Nested.1.0.uavcan rename to test/gentest_serialization/dsdl/complex/Nested.1.0.dsdl diff --git a/test/gentest_serialization/dsdl/complex/NestedNested.1.0.uavcan b/test/gentest_serialization/dsdl/complex/NestedNested.1.0.dsdl similarity index 100% rename from test/gentest_serialization/dsdl/complex/NestedNested.1.0.uavcan rename to test/gentest_serialization/dsdl/complex/NestedNested.1.0.dsdl diff --git a/test/gentest_serialization/dsdl/complex/NestedUnion.1.0.uavcan b/test/gentest_serialization/dsdl/complex/NestedUnion.1.0.dsdl similarity index 100% rename from test/gentest_serialization/dsdl/complex/NestedUnion.1.0.uavcan rename to test/gentest_serialization/dsdl/complex/NestedUnion.1.0.dsdl diff --git a/test/gentest_serialization/dsdl/complex/NestedUnionWComplexArray.1.0.uavcan b/test/gentest_serialization/dsdl/complex/NestedUnionWComplexArray.1.0.dsdl similarity index 100% rename from test/gentest_serialization/dsdl/complex/NestedUnionWComplexArray.1.0.uavcan rename to test/gentest_serialization/dsdl/complex/NestedUnionWComplexArray.1.0.dsdl diff --git a/test/gentest_tests/dsdl/buncho/serializables.0.1.uavcan b/test/gentest_tests/dsdl/buncho/serializables.0.1.dsdl similarity index 100% rename from test/gentest_tests/dsdl/buncho/serializables.0.1.uavcan rename to test/gentest_tests/dsdl/buncho/serializables.0.1.dsdl diff --git a/test/gentest_uses/dsdl/denada/serializables.0.1.uavcan b/test/gentest_uses/dsdl/denada/serializables.0.1.dsdl similarity index 100% rename from test/gentest_uses/dsdl/denada/serializables.0.1.uavcan rename to test/gentest_uses/dsdl/denada/serializables.0.1.dsdl diff --git a/test/gentest_versions/dsdl/viruses/1.covid.1.10.uavcan b/test/gentest_versions/dsdl/viruses/1.covid.1.10.dsdl similarity index 100% rename from test/gentest_versions/dsdl/viruses/1.covid.1.10.uavcan rename to test/gentest_versions/dsdl/viruses/1.covid.1.10.dsdl diff --git a/test/gentest_versions/dsdl/viruses/1.covid.1.9.uavcan b/test/gentest_versions/dsdl/viruses/1.covid.1.9.dsdl similarity index 100% rename from test/gentest_versions/dsdl/viruses/1.covid.1.9.uavcan rename to test/gentest_versions/dsdl/viruses/1.covid.1.9.dsdl diff --git a/test/gettest_properties/dsdl/proptest/hasvla.1.0.uavcan b/test/gettest_properties/dsdl/proptest/hasvla.1.0.dsdl similarity index 100% rename from test/gettest_properties/dsdl/proptest/hasvla.1.0.uavcan rename to test/gettest_properties/dsdl/proptest/hasvla.1.0.dsdl diff --git a/tox.ini b/tox.ini index dac7f0e4..6d267813 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ envlist = {py36,py37,py38,py39,py310,py311}-{test,nnvg,doctest,rstdoctest},lint, [base] deps = - Sybil >= 3.0.0 + Sybil >= 3.0.0, < 4.0.0 pytest >= 5.4.3, < 7.0.0 pytest-timeout coverage @@ -163,13 +163,17 @@ commands = [testenv:docs] -deps = -rrequirements.txt +deps = + -rrequirements.txt + sphinx ~= 6.2.1 + sphinx-rtd-theme + readthedocs-sphinx-ext commands = sphinx-build -W -b html {toxinidir} {envtmpdir} [testenv:gen-apidoc] -whitelist_externals = rm +allowlist_externals = rm deps = sphinx-autoapi diff --git a/verification/.devcontainer/devcontainer.json b/verification/.devcontainer/devcontainer.json index 816354a8..436f8c1c 100644 --- a/verification/.devcontainer/devcontainer.json +++ b/verification/.devcontainer/devcontainer.json @@ -12,13 +12,12 @@ "extensions": [ "uavcan.dsdl", "wholroyd.jinja", - "ban.spellright", - "ms-python.python", - "ms-vscode.cpptools", "ms-vscode.cpptools-extension-pack", + "streetsidesoftware.code-spell-checker", "xaver.clang-format", - "hbenl.vscode-test-explorer", - "matepek.vscode-catch2-test-adapter" + "vadimcn.vscode-lldb", + "matepek.vscode-catch2-test-adapter", + "ms-python.python" ] } }, diff --git a/verification/nunavut_test_types/test0/regulated/CombinatorialExplosion.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/CombinatorialExplosion.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/CombinatorialExplosion.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/CombinatorialExplosion.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/300.Service.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/300.Service.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/300.Service.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/300.Service.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/7000.Struct_.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/7000.Struct_.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/7000.Struct_.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/7000.Struct_.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/DelimitedFixedSize.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/DelimitedFixedSize.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/DelimitedFixedSize.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/DelimitedFixedSize.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/DelimitedVariableSize.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/DelimitedVariableSize.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/DelimitedVariableSize.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/DelimitedVariableSize.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/Primitive.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/Primitive.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/Primitive.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/Primitive.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayFixed.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayFixed.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayFixed.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayFixed.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayVariable.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayVariable.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayVariable.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/PrimitiveArrayVariable.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/Union.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/Union.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/Union.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/Union.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/basics/UnionWithSameTypes.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/basics/UnionWithSameTypes.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/basics/UnionWithSameTypes.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/basics/UnionWithSameTypes.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/A.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/A.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/A.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/A.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/A.1.1.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/A.1.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/A.1.1.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/A.1.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.1.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.1.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/BDelimited.1.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/BSealed.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/BSealed.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/BSealed.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/BSealed.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.1.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.1.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/CFixed.1.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.1.uavcan b/verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.1.uavcan rename to verification/nunavut_test_types/test0/regulated/delimited/CVariable.1.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/drone/sensor/BMSInfo.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/drone/sensor/BMSInfo.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/drone/sensor/BMSInfo.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/drone/sensor/BMSInfo.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatus.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatus.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatus.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatus.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatusValue.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatusValue.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatusValue.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/drone/sensor/BMSStatusValue.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/drone/sensor/BatteryChemistry.1.0.uavcan b/verification/nunavut_test_types/test0/regulated/drone/sensor/BatteryChemistry.1.0.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/drone/sensor/BatteryChemistry.1.0.uavcan rename to verification/nunavut_test_types/test0/regulated/drone/sensor/BatteryChemistry.1.0.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/AngVelSetpoint.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/AngVelSetpoint.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/AngVelSetpoint.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/AngVelSetpoint.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/RatiometricSetpoint.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/RatiometricSetpoint.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/RatiometricSetpoint.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/RatiometricSetpoint.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/Status.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/Status.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/Status.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/zubax/actuator/esc/Status.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackParams.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackParams.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackParams.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackParams.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackStatus.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackStatus.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackStatus.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/BatteryPackStatus.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/Technology.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/Technology.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/Technology.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/zubax/sensor/bms/Technology.0.1.dsdl diff --git a/verification/nunavut_test_types/test0/regulated/zubax/sensor/wattmeter/DCSample.0.1.uavcan b/verification/nunavut_test_types/test0/regulated/zubax/sensor/wattmeter/DCSample.0.1.dsdl similarity index 100% rename from verification/nunavut_test_types/test0/regulated/zubax/sensor/wattmeter/DCSample.0.1.uavcan rename to verification/nunavut_test_types/test0/regulated/zubax/sensor/wattmeter/DCSample.0.1.dsdl