From 9323de2b3d94c092e1d4dfc27ceb8457f438e175 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 6 Oct 2024 03:10:07 +0900 Subject: [PATCH] Fix typos (#11936) Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com> --- sphinx/ext/autodoc/__init__.py | 6 +++--- sphinx/registry.py | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index ed2b750f3c0..f0908a10bb8 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -2507,7 +2507,7 @@ def is_uninitialized_instance_attribute(self, parent: Any) -> bool: return self.objpath[-1] in annotations def import_object(self, raiseerror: bool = False) -> bool: - """Check the exisitence of uninitialized instance attribute when failed to import + """Check the existence of uninitialized instance attribute when failed to import the attribute. """ try: @@ -2728,7 +2728,7 @@ def can_document_member( return False def import_object(self, raiseerror: bool = False) -> bool: - """Check the exisitence of uninitialized instance attribute when failed to import + """Check the existence of uninitialized instance attribute when failed to import the attribute. """ ret = super().import_object(raiseerror) @@ -2801,7 +2801,7 @@ def _get_property_getter(self) -> Callable | None: def autodoc_attrgetter(app: Sphinx, obj: Any, name: str, *defargs: Any) -> Any: """Alternative getattr() for types""" - for typ, func in app.registry.autodoc_attrgettrs.items(): + for typ, func in app.registry.autodoc_attrgetters.items(): if isinstance(obj, typ): return func(obj, name, *defargs) diff --git a/sphinx/registry.py b/sphinx/registry.py index caa8c2daf8c..da21aefcee3 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -55,7 +55,7 @@ class SphinxComponentRegistry: def __init__(self) -> None: #: special attrgetter for autodoc; class object -> attrgetter - self.autodoc_attrgettrs: dict[type, Callable[[Any, str, Any], Any]] = {} + self.autodoc_attrgetters: dict[type, Callable[[Any, str, Any], Any]] = {} #: builders; a dict of builder name -> builder class self.builders: dict[str, type[Builder]] = {} @@ -113,7 +113,7 @@ def __init__(self) -> None: #: post transforms; list of transforms self.post_transforms: list[type[Transform]] = [] - #: source paresrs; file type -> parser class + #: source parsers; file type -> parser class self.source_parsers: dict[str, type[Parser]] = {} #: source suffix: suffix -> file type @@ -132,6 +132,10 @@ def __init__(self) -> None: # private cache of Docutils Publishers (file type -> publisher object) self.publishers: dict[str, Publisher] = {} + @property + def autodoc_attrgettrs(self) -> dict[type, Callable[[Any, str, Any], Any]]: + return self.autodoc_attrgetters + def add_builder(self, builder: type[Builder], override: bool = False) -> None: logger.debug('[app] adding builder: %r', builder) if not hasattr(builder, 'name'): @@ -377,7 +381,7 @@ def add_documenter(self, objtype: str, documenter: type[Documenter]) -> None: def add_autodoc_attrgetter(self, typ: type, attrgetter: Callable[[Any, str, Any], Any]) -> None: - self.autodoc_attrgettrs[typ] = attrgetter + self.autodoc_attrgetters[typ] = attrgetter def add_css_files(self, filename: str, **attributes: Any) -> None: self.css_files.append((filename, attributes))