Skip to content

Commit

Permalink
⬆️ Drop sphinx 5, support sphinx 8 (#1247)
Browse files Browse the repository at this point in the history
Also update dependencies:

- requests: `^2.25.1` -> `^2.32`
- requests-file: `^1.5.1` -> `^2.1`
- sphinx-data-viewer: `^0.1.1` -> `^0.1.5`
  • Loading branch information
chrisjsewell authored Aug 28, 2024
1 parent 648e007 commit a0e0807
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ jobs:
# 3.9.8 seems to be broken with type_ast
# https://www.mail-archive.com/[email protected]/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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion sphinx_needs/directives/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions sphinx_needs/functions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion tests/test_needs_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
13 changes: 7 additions & 6 deletions tests/test_proper_warning.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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")
Expand Down
7 changes: 4 additions & 3 deletions tests/test_service_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]",
]

Expand Down

0 comments on commit a0e0807

Please sign in to comment.