mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-26 05:07:35 -05:00
autodoc: Improve support for non-weakreferencable objects
This commit is contained in:
@@ -42,6 +42,8 @@ Bugs fixed
|
||||
Patch by Jean-François B.
|
||||
* #14064: LaTeX: TABs ending up in sphinxVerbatim fail to obey tab stops.
|
||||
Patch by Jean-François B.
|
||||
* #14089: autodoc: Improve support for non-weakreferencable objects.
|
||||
Patch by Adam Turner
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
@@ -360,7 +360,8 @@ def _make_props_from_imported_object(
|
||||
|
||||
if objtype == 'data':
|
||||
# Update __annotations__ to support type_comment and so on
|
||||
_ensure_annotations_from_type_comments(parent)
|
||||
if config.autodoc_use_type_comments:
|
||||
_ensure_annotations_from_type_comments(parent)
|
||||
|
||||
# obtain annotation
|
||||
annotations = get_type_hints(
|
||||
@@ -410,7 +411,7 @@ def _make_props_from_imported_object(
|
||||
obj = SLOTS_ATTR
|
||||
elif inspect.isenumattribute(obj):
|
||||
obj = obj.value
|
||||
if parent:
|
||||
if parent and config.autodoc_use_type_comments:
|
||||
# Update __annotations__ to support type_comment and so on
|
||||
_ensure_annotations_from_type_comments(parent)
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ def _ensure_annotations_from_type_comments(obj: Any) -> None:
|
||||
"""
|
||||
if obj in _objects_with_type_comment_annotations:
|
||||
return
|
||||
_objects_with_type_comment_annotations.add(obj)
|
||||
with contextlib.suppress(TypeError):
|
||||
_objects_with_type_comment_annotations.add(obj)
|
||||
|
||||
if isinstance(obj, type):
|
||||
for cls in inspect.getmro(obj):
|
||||
|
||||
Reference in New Issue
Block a user