From 87a7fd46fdd03c42b786e3ee2c1c98573b2ae4cf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 7 Jan 2024 16:14:43 -0800 Subject: [PATCH] Update dependency clang to v17 (#233) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nick --- .github/codecov.yml | 8 ++++++++ .github/workflows/pythonpackage.yml | 27 ++++++++++++++------------- poetry.lock | 24 ++++++++++++++++++++---- pyproject.toml | 1 + src/sphinx_c_autodoc/loader.py | 6 +++--- tests/assets/c_source/variables.c | 4 +--- tests/directives/test_autocdata.py | 18 +++++++++++++----- tox.ini | 2 +- 8 files changed, 61 insertions(+), 29 deletions(-) create mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 00000000..d6e8f695 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,8 @@ + coverage: + status: + project: + default: + target: 100% + threshold: 0% + paths: + - "src" diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index b19a372f..7fcd81d1 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -24,14 +24,14 @@ jobs: uses: actions/cache@v3 with: path: llvm/lib/libclang.so* - key: llvm-16 + key: llvm-17 - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1 with: - version: "16.0" + version: "17.0" cached: ${{ steps.cache-llvm.outputs.cache-hit }} - name: Symlink libclang.so - run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-16.so + run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-17.so - name: Install dependencies run: | python -m pip install --upgrade pip @@ -49,14 +49,14 @@ jobs: uses: actions/cache@v3 with: path: llvm/lib/libclang.so* - key: llvm-16 + key: llvm-17 - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1 with: - version: "16.0" + version: "17.0" cached: ${{ steps.cache-llvm.outputs.cache-hit }} - name: Symlink libclang.so - run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-16.so + run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-17.so - name: Install dependencies run: | python -m pip install --upgrade pip @@ -68,8 +68,9 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - files: ./tests/coverage.xml + files: ./coverage.xml verbose: true + fail_ci_if_error: true checks: runs-on: ubuntu-latest @@ -83,14 +84,14 @@ jobs: uses: actions/cache@v3 with: path: llvm/lib/libclang.so* - key: llvm-16 + key: llvm-17 - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1 with: - version: "16.0" + version: "17.0" cached: ${{ steps.cache-llvm.outputs.cache-hit }} - name: Symlink libclang.so - run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-16.so + run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-17.so - name: Install dependencies run: | python -m pip install --upgrade pip @@ -108,14 +109,14 @@ jobs: uses: actions/cache@v3 with: path: llvm/lib/libclang.so* - key: llvm-16 + key: llvm-17 - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1 with: - version: "16.0" + version: "17.0" cached: ${{ steps.cache-llvm.outputs.cache-hit }} - name: Symlink libclang.so - run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-16.so + run: sudo ln -s ${{ env.LLVM_PATH }}/lib/libclang.so /usr/lib/x86_64-linux-gnu/libclang-17.so - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/poetry.lock b/poetry.lock index e47ce74b..4351464f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -200,13 +200,13 @@ files = [ [[package]] name = "clang" -version = "16.0.1.1" +version = "17.0.6" description = "libclang python bindings" optional = false python-versions = "*" files = [ - {file = "clang-16.0.1.1-py3-none-any.whl", hash = "sha256:aa80abef73cb9994f038346d6f32920d0fb273217641ccbacf2e8eddbfc499e8"}, - {file = "clang-16.0.1.1.tar.gz", hash = "sha256:4d5918f5a8985f157947238e19b6043a93fb5f77b7a9f2b01faf8e948b4478a9"}, + {file = "clang-17.0.6-py3-none-any.whl", hash = "sha256:d05ad6dddc9b360e94b9420e239c639a9117902cce8a57fd288a5226eea3092e"}, + {file = "clang-17.0.6.tar.gz", hash = "sha256:d228511e6a29e866dcbe99e10ed10649317b9b3e636ba805f6867b7afb6e8c44"}, ] [[package]] @@ -759,6 +759,22 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "setuptools" +version = "69.0.3" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, + {file = "setuptools-69.0.3.tar.gz", hash = "sha256:be1af57fc409f93647f2e8e4573a142ed38724b8cdd389706a867bb4efcf1e78"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.1)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + [[package]] name = "six" version = "1.16.0" @@ -1080,4 +1096,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "5fcec4cbd1b612534ea0490419919c589d4d6806df5e1137f2241c7ffa23a38b" +content-hash = "cab51a3f9ea2ec5a533824a5d3d432583c6507ca0b97e5b76de3525653998fb4" diff --git a/pyproject.toml b/pyproject.toml index 6adb6578..52a5ff77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ sphinxcontrib-autoprogram = "0.1.8" types-docutils = "0.20.0.20240106" pylint = "^3.0.0" furo = "^2023.5.20" +setuptools = "^69.0.3" [build-system] requires = ["poetry-core"] diff --git a/src/sphinx_c_autodoc/loader.py b/src/sphinx_c_autodoc/loader.py index 54668a39..69d4cbee 100644 --- a/src/sphinx_c_autodoc/loader.py +++ b/src/sphinx_c_autodoc/loader.py @@ -712,9 +712,9 @@ def _find_declaration_type(self) -> str: ) try: type_ = tokens[-2].spelling - except IndexError: - # For array variables with unknown types libclang fails to provide the - # tokens. + except IndexError: # pragma: no cover + # For versions 16 and before, libclang fails to provide the tokens for array + # variables with unknown types pass # clang doesn't provide the storage class in the type name, so we'll add it here diff --git a/tests/assets/c_source/variables.c b/tests/assets/c_source/variables.c index 67c2ce1d..9d728597 100644 --- a/tests/assets/c_source/variables.c +++ b/tests/assets/c_source/variables.c @@ -22,9 +22,7 @@ static MAYBE_CONST /* throw in a pinch of comment to the mix */ /** * A an array variable with an unknown type. - * For whatever reason clang will come back with no extent on this so - * we have to fall back to this being treated as an int -*/ + */ unknown_type unknown_array_type_var[24]; /** diff --git a/tests/directives/test_autocdata.py b/tests/directives/test_autocdata.py index 2bebf56f..bff594a2 100644 --- a/tests/directives/test_autocdata.py +++ b/tests/directives/test_autocdata.py @@ -4,9 +4,12 @@ from textwrap import dedent import pytest +import pkg_resources from sphinx.ext.autodoc.directive import AutodocDirective +CLANG_VERSION = pkg_resources.get_distribution("clang").parsed_version + class TestAutoCData: """ @@ -36,10 +39,8 @@ class TestAutoCData: MAYBE_CONST is the type.""" unknown_file_level_array_type = """\ - int unknown_array_type_var[24] - A an array variable with an unknown type. - For whatever reason clang will come back with no extent on this so - we have to fall back to this being treated as an int""" + unknown_type unknown_array_type_var[24] + A an array variable with an unknown type.""" unknown_extern_file_variable = """\ extern unknown_type *unknown_extern_type_var @@ -49,7 +50,14 @@ class TestAutoCData: ("variables.c::file_level_variable", file_level_variable), ("example.c::inline_struct_variable", inline_struct_variable), ("variables.c::unknown_type_var", unknown_file_level_variable_type), - ("variables.c::unknown_array_type_var", unknown_file_level_array_type), + pytest.param( + "variables.c::unknown_array_type_var", + unknown_file_level_array_type, + marks=pytest.mark.skipif( + CLANG_VERSION.release < (17,), + reason="Clang 17+ fixes array type parsing", + ), + ), ("variables.c::unknown_extern_type_var", unknown_extern_file_variable), ] diff --git a/tox.ini b/tox.ini index 94251c10..f978728b 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ commands = flake8: flake8 {toxinidir}/src/sphinx_c_autodoc black: black --check {toxinidir}/src/sphinx_c_autodoc {toxinidir}/tests {posargs} mypy: poetry run mypy {toxinidir}/src/sphinx_c_autodoc {posargs} - cov: poetry run pytest --cov=sphinx_c_autodoc --cov-config={[coverage]file} --cov-report=xml --cov-fail-under=100 {posargs} + cov: poetry run pytest --cov=sphinx_c_autodoc --cov-config={[coverage]file} --cov-report=xml {posargs} docs: poetry run sphinx-build {toxinidir}/docs {toxinidir}/docs/_build [testenv:py{38, 39, 310, 311, 312}]