diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 89612e762..3f4d04cd0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,11 +26,14 @@ jobs: # 3.9.8 seems to be broken with type_ast # https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1829077.html python-version: ["3.8", "3.11"] - sphinx-version: ["5.0", "6.0", "7.0"] + sphinx-version: ["6.0", "7.0"] include: + - os: "ubuntu-latest" + python-version: "3.10" + sphinx-version: "8.0" - os: "windows-latest" python-version: "3.8" - sphinx-version: "5.0" + sphinx-version: "6.0" steps: - uses: actions/checkout@v4 - name: Install graphviz (linux) @@ -71,10 +74,10 @@ jobs: include: - os: "ubuntu-latest" python-version: "3.8" - sphinx-version: "5.0" + sphinx-version: "6.0" - os: "ubuntu-latest" python-version: "3.11" - sphinx-version: "7.0" + sphinx-version: "8.0" steps: - uses: actions/checkout@v4 - name: Use Node.js diff --git a/pyproject.toml b/pyproject.toml index bde661e20..fa00cfb1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,11 +33,11 @@ packages = [ # [project.dependencies] [tool.poetry.dependencies] python = ">=3.8,<4" -sphinx = ">=5.0,<8" -requests-file = "^1.5.1" # external links -requests = "^2.25.1" # external_links +sphinx = ">=6.0,<9" +requests-file = "^2.1" # external links +requests = "^2.32" # external_links jsonschema = ">=3.2.0" # needsimport schema validation -sphinx-data-viewer = "^0.1.1" # needservice debug output +sphinx-data-viewer = "^0.1.5" # needservice debug output sphinxcontrib-jquery = "^4" # needed for datatables in sphinx>=6 # [project.optional-dependencies.plotting] diff --git a/sphinx_needs/directives/need.py b/sphinx_needs/directives/need.py index 568c97b62..daeabfd96 100644 --- a/sphinx_needs/directives/need.py +++ b/sphinx_needs/directives/need.py @@ -384,7 +384,7 @@ def post_process_needs_data(app: Sphinx) -> None: if needs and not needs_data.needs_is_post_processed: extend_needs_data(needs, needs_data.get_or_create_extends(), needs_config) resolve_dynamic_values(needs, app) - resolve_variants_options(needs, needs_config, app.builder.tags.tags) + resolve_variants_options(needs, needs_config, app.builder.tags) check_links(needs, needs_config) create_back_links(needs, needs_config) process_constraints(needs, needs_config) diff --git a/sphinx_needs/functions/functions.py b/sphinx_needs/functions/functions.py index 9d2c89511..428eb5ffe 100644 --- a/sphinx_needs/functions/functions.py +++ b/sphinx_needs/functions/functions.py @@ -16,6 +16,7 @@ from sphinx.application import Sphinx from sphinx.environment import BuildEnvironment from sphinx.errors import SphinxError +from sphinx.util.tags import Tags from sphinx_needs.config import NeedsSphinxConfig from sphinx_needs.data import NeedsInfoType, SphinxNeedsData @@ -270,7 +271,7 @@ def resolve_dynamic_values(needs: dict[str, NeedsInfoType], app: Sphinx) -> None def resolve_variants_options( needs: dict[str, NeedsInfoType], needs_config: NeedsSphinxConfig, - tags: dict[str, bool], + tags: Tags, ) -> None: """ Resolve variants options inside need data. @@ -295,7 +296,9 @@ def resolve_variants_options( need_context.update( **needs_config.filter_data ) # Add needs_filter_data to filter context - need_context.update(**tags) # Add sphinx tags to filter context + need_context.update( + **{tag: True for tag in tags} + ) # Add sphinx tags to filter context location = (need["docname"], need["lineno"]) if need.get("docname") else None for var_option in variants_options: diff --git a/tests/test_needs_warning.py b/tests/test_needs_warning.py index b805b57cd..f30e2ec16 100644 --- a/tests/test_needs_warning.py +++ b/tests/test_needs_warning.py @@ -42,7 +42,12 @@ def test_needs_warnings(test_app): "\t\tused filter: my_custom_warning_check [needs.warnings]", ] - if version_info >= (7, 3): + if version_info >= (8, 0): + expected.insert( + 1, + "WARNING: cannot cache unpickable configuration value: 'needs_warnings' (because it contains a function, class, or module object) [config.cache]", + ) + elif version_info >= (7, 3): expected.insert( 1, "WARNING: cannot cache unpickable configuration value: 'needs_warnings' (because it contains a function, class, or module object)", diff --git a/tests/test_proper_warning.py b/tests/test_proper_warning.py index 67cd396d5..ad14809fe 100644 --- a/tests/test_proper_warning.py +++ b/tests/test_proper_warning.py @@ -1,6 +1,7 @@ from pathlib import Path import pytest +from sphinx import version_info from sphinx.application import Sphinx from sphinx.util.console import strip_colors @@ -14,13 +15,13 @@ def test_proper_warning(test_app: Sphinx): test_app.build() warnings = strip_colors(test_app._warning.getvalue()).splitlines() - + prefix = " [docutils]" if version_info >= (8, 0) else "" assert warnings == [ - f'{Path(str(test_app.srcdir)) / "index.rst"}:9: ERROR: Unknown interpreted text role "unknown0".', - f'{Path(str(test_app.srcdir)) / "index.rst"}:16: ERROR: Unknown interpreted text role "unknown1".', - f'{Path(str(test_app.srcdir)) / "index.rst"}:24: ERROR: Unknown interpreted text role "unknown2".', - f'{Path(str(test_app.srcdir)) / "index.rst"}:31: ERROR: Unknown interpreted text role "unknown3".', - f'{Path(str(test_app.srcdir)) / "index.rst"}:6: ERROR: Unknown interpreted text role "unknown4".', + f'{Path(str(test_app.srcdir)) / "index.rst"}:9: ERROR: Unknown interpreted text role "unknown0".{prefix}', + f'{Path(str(test_app.srcdir)) / "index.rst"}:16: ERROR: Unknown interpreted text role "unknown1".{prefix}', + f'{Path(str(test_app.srcdir)) / "index.rst"}:24: ERROR: Unknown interpreted text role "unknown2".{prefix}', + f'{Path(str(test_app.srcdir)) / "index.rst"}:31: ERROR: Unknown interpreted text role "unknown3".{prefix}', + f'{Path(str(test_app.srcdir)) / "index.rst"}:6: ERROR: Unknown interpreted text role "unknown4".{prefix}', ] html = Path(test_app.outdir, "index.html").read_text(encoding="utf8") diff --git a/tests/test_service_github.py b/tests/test_service_github.py index e9527b2c7..8055f8648 100644 --- a/tests/test_service_github.py +++ b/tests/test_service_github.py @@ -3,6 +3,7 @@ import pytest import responses +from sphinx import version_info from sphinx.util.console import strip_colors from syrupy.filters import props @@ -85,11 +86,11 @@ def test_build(test_app, snapshot): app = test_app app.build() warnings = strip_colors(app._warning.getvalue()) - print(warnings) - + # print(warnings) + prefix = " [docutils]" if version_info >= (8, 0) else "" expected_warnings = [ f'{Path(str(app.srcdir)) / "index.rst"}:4: WARNING: "query" or "specific" missing as option for github service. [needs.github]', - f'{Path(str(app.srcdir)) / "index.rst"}:23: WARNING: Bullet list ends without a blank line; unexpected unindent.', + f'{Path(str(app.srcdir)) / "index.rst"}:23: WARNING: Bullet list ends without a blank line; unexpected unindent.{prefix}', f"{Path(str(app.srcdir)) / 'index.rst'}:22: WARNING: GitHub: API rate limit exceeded (twice). Stop here. [needs.github]", ]