Skip to content

Commit

Permalink
Update sphinx to 7.2.6 (#216)
Browse files Browse the repository at this point in the history
Bump sphinx to 7.2.6.

Sphinx 7.2 dropped support for python 3.8 and this project still supports 3.8. In order to work around this limitation the `[tool.poetry.group.dev.dependencies]` was expanded to use a multiple constraint dependency for sphinx
  • Loading branch information
speedyleion authored Oct 7, 2023
1 parent ed21c41 commit 9bca6e3
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 37 deletions.
81 changes: 55 additions & 26 deletions poetry.lock

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

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ beautifulsoup4 = "*"
sphinx-c-apidoc = 'sphinx_c_autodoc.apidoc:main'

[tool.poetry.group.dev.dependencies]
sphinx = [
{version = ">=3.1,<7.2", python = "<3.9"},
{version = ">=7.2", python = ">=3.9"}
]
black = "23.9.1"
pycodestyle = "2.11.0"
mypy = "1.5.1"
Expand Down
14 changes: 9 additions & 5 deletions src/sphinx_c_autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,18 @@ def parse_name(self) -> bool:
else:
parents = path.rstrip(".").split(".")

self.modname, self.objpath = self.resolve_name(fullname, parents, path, base)
# The implementation of self.resolve_name() always returns back a str,
# but typing wise it says optional to be nsync with the Sphinx definition.
self.modname, self.objpath = self.resolve_name( # type: ignore
fullname, parents, path, base
)

self.fullname = self.modname
return True

def resolve_name(
self, modname: str, parents: List[str], path: Optional[str], base: str
) -> Tuple[str, List[str]]:
self, modname: Optional[str], parents: List[str], path: Optional[str], base: str
) -> Tuple[Optional[str], List[str]]:
"""
Resolve the module and object name of the object to document.
This can be derived in two ways:
Expand Down Expand Up @@ -297,7 +301,7 @@ def get_doc(self) -> Optional[List[List[str]]]:
tab_width = self.directive.state.document.settings.tab_width
return [prepare_docstring(docstring, tabsize=tab_width)]

def get_object_members(self, want_all: bool) -> Tuple[bool, List[Tuple[str, Any]]]:
def get_object_members(self, want_all: bool) -> Tuple[bool, List[Any]]:
"""Return `(members_check_module, members)` where `members` is a
list of `(membername, member)` pairs of the members of *self.object*.
Expand All @@ -311,7 +315,7 @@ def get_object_members(self, want_all: bool) -> Tuple[bool, List[Tuple[str, Any]
# should be safe to assume this is a list or None at this point.
desired_members = self.options.members or []

object_members: List[Tuple[str, Any]] = []
object_members: List[Any] = []
for member in desired_members:
if member in self.object.children:
object_members.append((member, self.object.children[member]))
Expand Down
13 changes: 7 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
"""

import os
import sys

import pytest
import sphinx

from docutils.parsers.rst.states import RSTStateMachine, Struct, Inliner, state_classes
from docutils.parsers.rst.languages import en
from docutils.statemachine import StringList
from docutils.utils import new_document
from sphinx.testing.path import path
from sphinx.util.docutils import sphinx_domains

# SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
# sys.path.append(os.path.join(SCRIPT_DIR, '..', 'src'))
if sphinx.version_info < (7, 2):
from sphinx.testing.path import path as Path
else:
from pathlib import Path

pytest_plugins = "sphinx.testing.fixtures"

Expand All @@ -34,8 +35,8 @@ def local_app(make_app):
# Provide sphinx with the path to the documentation directory.
conf_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "assets"))

# Note the sphinx fixture expects a :class:`path` object, not a string
yield make_app(srcdir=path(conf_dir))
# Note the sphinx fixture expects a :class:`Path` object, not a string
yield make_app(srcdir=Path(conf_dir))


@pytest.fixture()
Expand Down

0 comments on commit 9bca6e3

Please sign in to comment.