Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Sphinx 7.2.x #28

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ packages = find_namespace:
python_requires = >= 3.8
include_package_data = True
install_requires =
Sphinx == 5.0.2
Sphinx >= 7.2.2, < 7.3.0
hy@git+https://github.com/hylang/hy@master#egg

[options.packages.find]
Expand All @@ -34,7 +34,7 @@ dev =
bump2version == 1.0.1
flake8 == 3.8.4
pytest == 6.2.2
sphinx_rtd_theme == 1.2.2
sphinx_rtd_theme >= 1.2.2, < 1.3.0
pre-commit

[aliases]
Expand Down
24 changes: 10 additions & 14 deletions sphinxcontrib/hy_documenters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import builtins
import logging
import re
import traceback
from inspect import getfullargspec
Expand Down Expand Up @@ -30,7 +29,7 @@
from sphinx.ext.autodoc.importer import Attribute, import_module
from sphinx.ext.autodoc.mock import mock
from sphinx.locale import __
from sphinx.util import inspect
from sphinx.util import inspect, logging
from sphinx.util.inspect import (
getall,
getannotations,
Expand All @@ -41,13 +40,13 @@
)
from sphinx.util.typing import is_system_TypeVar

logger = logging.getLogger("hy-domain")
logger = logging.getLogger("sphinx.contrib.hylang.documenter")

hy_ext_sig_re = re.compile(
r"""
^\(
(?:\s*\^(?P<retann>\(.*?\) | .*?)\s+)? # Optional: return annotation
(?P<module>[\w.]+::)? # Explicit module name
(?P<module>[\w.]+::)? # Explicit module name
(?P<classes>.*\.)? # Module and/or class name(s)
(?P<object>.+?) \s* # Thing name
(?: # Arguments/close or just close
Expand All @@ -60,8 +59,8 @@

hy_var_sig_re = re.compile(
r"""^ (?P<module>[\w.]+::)? # Explicit module name
(?P<classes>.*\.)? # Module and/or class name(s)
(?P<object>.+?) # thing name
(?P<classes>.*\.)? # Module and/or class name(s)
(?P<object>.+?) # thing name
$""",
re.VERBOSE,
)
Expand Down Expand Up @@ -487,7 +486,7 @@ def run(self) -> List[Node]:

# record all filenames as dependencies -- this will at least
# partially make automatic invalidation possible
for fn in params.filename_set:
for fn in params.record_dependencies:
self.state.document.settings.record_dependencies.add(fn)

result = parse_generated_content(self.state, params.result, documenter)
Expand Down Expand Up @@ -560,7 +559,7 @@ def format_signature(self, **kwargs: Any) -> str:
macro=isinstance(self, HyMacroDocumenter),
)
except Exception as exc:
logging.warning(
logger.warning(
("error while formatting arguments for %s: %s"),
self.fullname,
exc,
Expand Down Expand Up @@ -660,17 +659,14 @@ def document_members(self, all_members=False):
self.env.temp_data["autodoc:module"] = None
self.env.temp_data["autodoc:class"] = None

def get_object_members(self, want_all: bool) -> tuple[bool, list[ObjectMember]]:
return (False, [])


class HyModuleDocumenter(HyDocumenter, PyModuleDocumenter):
option_spec = PyModuleDocumenter.option_spec.copy()
option_spec.update({"macros": members_option, "readers": members_option})

def add_directive_header(self, sig: str) -> None:
return super().add_directive_header(sig)

def parse_name(self) -> bool:
return super().parse_name()

def import_object(self, raiseerror: bool = False) -> bool:
ret = super().import_object(raiseerror)

Expand Down
24 changes: 9 additions & 15 deletions sphinxcontrib/hydomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import ast
import inspect
import logging
import re
import sys
from inspect import Parameter
Expand All @@ -38,22 +37,22 @@
)
from sphinx.environment import BuildEnvironment
from sphinx.locale import _, __
from sphinx.pycode.ast import parse as ast_parse
from sphinx.roles import XRefRole
from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective
from sphinx.util.inspect import signature_from_ast
from sphinx.util.nodes import make_id, make_refnode

import sphinxcontrib.hy_documenters as doc

# ** Consts
logging.getLogger().setLevel(logging.DEBUG)
logger = logging.getLogger("sphinx.contrib.hylang.domain")

hy_sexp_sig_re = re.compile(
r"""
^\(
(?:\s*\^(?P<retann>\(.*\) | [^\s]+?)\s+)? # Optional: return annotation
(?P<module>[\w.]+::)? # Explicit module name
(?:\s*\^(?P<retann>\(.*\) | [^\s]+?)\s+)? # Optional: return annotation
(?P<module>[\w.]+::)? # Explicit module name
(?P<classes>.*\.)? # Module and/or class name(s)
(?P<object>.+?) \s* # Thing name
(?: # Arguments/close or just close
Expand Down Expand Up @@ -280,7 +279,7 @@ def unparse(node: ast.AST, isslice=False) -> List[Node]:
raise SyntaxError # unsupported syntax

try:
tree = ast_parse(annotation)
tree = ast.parse(annotation)
result = unparse(tree)
for i, node in enumerate(result):
if isinstance(node, nodes.Text):
Expand Down Expand Up @@ -405,7 +404,7 @@ def handle_signature(self, sig: str, signode) -> Tuple[str, str]:
# it supports to represent optional arguments (ex. "func(foo [, bar])")
_pseudo_parse_arglist(signode, arglist)
except NotImplementedError as exc:
logging.warning("could not parse arglist (%r): %s", exc)
logger.warning("could not parse arglist (%r): %s", exc)
_pseudo_parse_arglist(signode, arglist)
else:
if self.needs_arglist():
Expand Down Expand Up @@ -589,12 +588,7 @@ def run(self) -> List[Node]:
target = nodes.target("", "", ids=[node_id], ismod=True)
self.set_source_info(target)

# Assign old styled node_id not to break old hyperlinks (if possible)
# Note: Will removed in Sphinx-5.0 (RemovedInSphinx50Warning)
old_node_id = self.make_old_id(modname)
if node_id != old_node_id and old_node_id not in self.state.document.ids:
target["ids"].append(old_node_id)

node_id = make_id(self.env, self.state.document, "", modname)
self.state.document.note_explicit_target(target)

domain.note_module(
Expand Down Expand Up @@ -894,7 +888,7 @@ def note_object(
) -> None:
if name in self.objects:
other = self.objects[name]
logging.warning(
logger.warning(
__(
"duplicate object description of %s, "
"other instance in %s, use :noindex: for one of them"
Expand Down Expand Up @@ -1033,7 +1027,7 @@ def resolve_xref(
if not matches:
return None
elif len(matches) > 1:
logging.warning(
logger.warning(
__("more than one target found for cross-reference %r: %s"),
target,
", ".join(match[0] for match in matches),
Expand Down
Loading