diff --git a/setup.cfg b/setup.cfg index 1dbf9f9..d5ecfad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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] @@ -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] diff --git a/sphinxcontrib/hy_documenters.py b/sphinxcontrib/hy_documenters.py index b065d36..d81aac6 100644 --- a/sphinxcontrib/hy_documenters.py +++ b/sphinxcontrib/hy_documenters.py @@ -1,5 +1,4 @@ import builtins -import logging import re import traceback from inspect import getfullargspec @@ -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, @@ -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\(.*?\) | .*?)\s+)? # Optional: return annotation - (?P[\w.]+::)? # Explicit module name + (?P[\w.]+::)? # Explicit module name (?P.*\.)? # Module and/or class name(s) (?P.+?) \s* # Thing name (?: # Arguments/close or just close @@ -60,8 +59,8 @@ hy_var_sig_re = re.compile( r"""^ (?P[\w.]+::)? # Explicit module name - (?P.*\.)? # Module and/or class name(s) - (?P.+?) # thing name + (?P.*\.)? # Module and/or class name(s) + (?P.+?) # thing name $""", re.VERBOSE, ) @@ -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) @@ -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, @@ -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) diff --git a/sphinxcontrib/hydomain.py b/sphinxcontrib/hydomain.py index 91ae348..b626941 100644 --- a/sphinxcontrib/hydomain.py +++ b/sphinxcontrib/hydomain.py @@ -14,7 +14,6 @@ import ast import inspect -import logging import re import sys from inspect import Parameter @@ -38,8 +37,8 @@ ) 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 @@ -47,13 +46,13 @@ 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\(.*\) | [^\s]+?)\s+)? # Optional: return annotation - (?P[\w.]+::)? # Explicit module name + (?:\s*\^(?P\(.*\) | [^\s]+?)\s+)? # Optional: return annotation + (?P[\w.]+::)? # Explicit module name (?P.*\.)? # Module and/or class name(s) (?P.+?) \s* # Thing name (?: # Arguments/close or just close @@ -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): @@ -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(): @@ -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( @@ -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" @@ -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),