Skip to content

Commit 0fa8c9e

Browse files
committed
props.name
1 parent fa18c4d commit 0fa8c9e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

sphinx/ext/autodoc/_documenters.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,11 @@ def add_directive_header(self, sig: str) -> None:
19131913
self.config.autodoc_type_aliases,
19141914
include_extras=True,
19151915
)
1916-
if self.props.parts[-1] in annotations:
1916+
if self.props.name in annotations:
19171917
mode = _get_render_mode(self.config.autodoc_typehints_format)
19181918
short_literals = self.config.python_display_short_literal_types
19191919
objrepr = stringify_annotation(
1920-
annotations.get(self.props.parts[-1]),
1920+
annotations.get(self.props.name),
19211921
mode,
19221922
short_literals=short_literals,
19231923
)
@@ -1953,7 +1953,7 @@ def get_module_comment(self, attrname: str) -> list[str] | None:
19531953

19541954
def get_doc(self) -> list[list[str]] | None:
19551955
# Check the variable has a docstring-comment
1956-
comment = self.get_module_comment(self.props.parts[-1])
1956+
comment = self.get_module_comment(self.props.name)
19571957
if comment:
19581958
return [comment]
19591959
else:
@@ -2084,7 +2084,7 @@ def format_signature(self, **kwargs: Any) -> str:
20842084
sig = super().format_signature(**kwargs)
20852085
sigs.append(sig)
20862086

2087-
meth = self.parent.__dict__.get(self.props.parts[-1])
2087+
meth = self.parent.__dict__.get(self.props.name)
20882088
if inspect.is_singledispatch_method(meth):
20892089
# append signature of singledispatch'ed functions
20902090
for typ, func in meth.dispatcher.registry.items():
@@ -2182,7 +2182,7 @@ def get_doc(self) -> list[list[str]] | None:
21822182
# ``__docstring_signature__ = True``. Just return the
21832183
# previously-computed result, so that we don't loose the processing.
21842184
return self._new_docstrings
2185-
if self.props.parts[-1] == '__init__':
2185+
if self.props.name == '__init__':
21862186
docstring = getdoc(
21872187
self.object,
21882188
self.get_attr,
@@ -2200,7 +2200,7 @@ def get_doc(self) -> list[list[str]] | None:
22002200
return [prepare_docstring(docstring, tabsize=tab_width)]
22012201
else:
22022202
return []
2203-
elif self.props.parts[-1] == '__new__':
2203+
elif self.props.name == '__new__':
22042204
docstring = getdoc(
22052205
self.object,
22062206
self.get_attr,
@@ -2322,11 +2322,11 @@ def add_directive_header(self, sig: str) -> None:
23222322
self.config.autodoc_type_aliases,
23232323
include_extras=True,
23242324
)
2325-
if self.props.parts[-1] in annotations:
2325+
if self.props.name in annotations:
23262326
mode = _get_render_mode(self.config.autodoc_typehints_format)
23272327
short_literals = self.config.python_display_short_literal_types
23282328
objrepr = stringify_annotation(
2329-
annotations.get(self.props.parts[-1]),
2329+
annotations.get(self.props.name),
23302330
mode,
23312331
short_literals=short_literals,
23322332
)
@@ -2370,7 +2370,7 @@ def get_doc(self) -> list[list[str]] | None:
23702370
try:
23712371
parent___slots__ = inspect.getslots(self.parent)
23722372
if parent___slots__ and (
2373-
docstring := parent___slots__.get(self.props.parts[-1])
2373+
docstring := parent___slots__.get(self.props.name)
23742374
):
23752375
docstring = prepare_docstring(docstring)
23762376
return [docstring]

0 commit comments

Comments
 (0)