diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-06-17 02:19:33 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-06-17 02:19:33 +0900 |
commit | 4d7558e968d74f73e11c5460fe095b51a5a9f172 (patch) | |
tree | 2f67856b0b2022caec491c37766280b77c48ed2f /sphinx/ext/autodoc/importer.py | |
parent | 571b55328d401a6e1d50e37407df56586065a7be (diff) | |
parent | 949984c4e26671fdf5490c33cf90d4db118aaa86 (diff) | |
download | sphinx-git-4d7558e968d74f73e11c5460fe095b51a5a9f172.tar.gz |
Merge branch '5.0.x' into 5.x
Diffstat (limited to 'sphinx/ext/autodoc/importer.py')
-rw-r--r-- | sphinx/ext/autodoc/importer.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index 85c1e81be..d392ae75d 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -205,8 +205,8 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable, return members -def get_class_members(subject: Any, objpath: List[str], attrgetter: Callable - ) -> Dict[str, "ObjectMember"]: +def get_class_members(subject: Any, objpath: List[str], attrgetter: Callable, + inherit_docstrings: bool = True) -> Dict[str, "ObjectMember"]: """Get members and attributes of target class.""" from sphinx.ext.autodoc import INSTANCEATTR, ObjectMember @@ -290,6 +290,11 @@ def get_class_members(subject: Any, objpath: List[str], attrgetter: Callable elif (ns == qualname and docstring and isinstance(members[name], ObjectMember) and not members[name].docstring): + if cls != subject and not inherit_docstrings: + # If we are in the MRO of the class and not the class itself, + # and we do not want to inherit docstrings, then skip setting + # the docstring below + continue # attribute is already known, because dir(subject) enumerates it. # But it has no docstring yet members[name].docstring = '\n'.join(docstring) |