Skip to content

Commit

Permalink
Update dependency clang to v17 (#233)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Nick <[email protected]>
  • Loading branch information
renovate[bot] and speedyleion authored Jan 8, 2024
1 parent 35e3995 commit 87a7fd4
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 29 deletions.
8 changes: 8 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
target: 100%
threshold: 0%
paths:
- "src"
27 changes: 14 additions & 13 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 20 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
6 changes: 3 additions & 3 deletions src/sphinx_c_autodoc/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions tests/assets/c_source/variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

/**
Expand Down
18 changes: 13 additions & 5 deletions tests/directives/test_autocdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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
Expand All @@ -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),
]

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
Expand Down

0 comments on commit 87a7fd4

Please sign in to comment.