summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-04-26 11:24:15 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-04-28 22:33:40 +0900
commit13113fc0b65cf4e801e0ee0aacfa0ef6eb4949cc (patch)
treeff42735622e360a3d5fadc5f32aae39db93c379c /sphinx/util
parent1f5dab6446ebe7b70d1210689026a649b74a280d (diff)
downloadsphinx-git-13113fc0b65cf4e801e0ee0aacfa0ef6eb4949cc.tar.gz
Fix #6588: autodoc: Decorated inherited method has no documentation
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/inspect.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index 0434d7850..38777728a 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -691,13 +691,14 @@ class Signature:
def getdoc(obj: Any, attrgetter: Callable = safe_getattr,
- allow_inherited: bool = False) -> str:
+ allow_inherited: bool = False, cls: Any = None, name: str = None) -> str:
"""Get the docstring for the object.
This tries to obtain the docstring for some kind of objects additionally:
* partial functions
* inherited docstring
+ * inherited decorated methods
"""
doc = attrgetter(obj, '__doc__', None)
if ispartial(obj) and doc == obj.__class__.__doc__:
@@ -705,4 +706,14 @@ def getdoc(obj: Any, attrgetter: Callable = safe_getattr,
elif doc is None and allow_inherited:
doc = inspect.getdoc(obj)
+ if doc is None and cls:
+ # inspect.getdoc() does not support some kind of inherited and decorated methods.
+ # This tries to obtain the docstring from super classes.
+ for basecls in getattr(cls, '__mro__', []):
+ meth = safe_getattr(basecls, name, None)
+ if meth:
+ doc = inspect.getdoc(meth)
+ if doc:
+ break
+
return doc