mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9797 from tk0miya/9757_inherited_classmethods
Fix #9757: autodoc_inherit_docstrings does not effect to overriden classmethods
This commit is contained in:
commit
2b5c55e45a
2
CHANGES
2
CHANGES
@ -64,6 +64,8 @@ Bugs fixed
|
||||
* #9755: autodoc: memory addresses are shown for aliases
|
||||
* #9752: autodoc: Failed to detect type annotation for slots attribute
|
||||
* #9756: autodoc: Crashed if classmethod does not have __func__ attribute
|
||||
* #9757: autodoc: :confval:`autodoc_inherit_docstrings` does not effect to
|
||||
overriden classmethods
|
||||
* #9630: autosummary: Failed to build summary table if :confval:`primary_domain`
|
||||
is not 'py'
|
||||
* #9670: html: Fix download file with special characters
|
||||
|
@ -866,7 +866,9 @@ def getdoc(obj: Any, attrgetter: Callable = safe_getattr,
|
||||
for basecls in getmro(cls):
|
||||
meth = basecls.__dict__.get(name)
|
||||
if meth and hasattr(meth, '__func__'):
|
||||
return getdoc(meth.__func__)
|
||||
doc = getdoc(meth.__func__)
|
||||
if doc is not None or not allow_inherited:
|
||||
return doc
|
||||
|
||||
doc = attrgetter(obj, '__doc__', None)
|
||||
if ispartial(obj) and doc == obj.__class__.__doc__:
|
||||
|
@ -677,6 +677,25 @@ def test_unpartial():
|
||||
assert inspect.unpartial(func3) is func1
|
||||
|
||||
|
||||
def test_getdoc_inherited_classmethod():
|
||||
class Foo:
|
||||
@classmethod
|
||||
def meth(self):
|
||||
"""
|
||||
docstring
|
||||
indented text
|
||||
"""
|
||||
|
||||
class Bar(Foo):
|
||||
@classmethod
|
||||
def meth(self):
|
||||
# inherited classmethod
|
||||
pass
|
||||
|
||||
assert inspect.getdoc(Bar.meth, getattr, False, Bar, "meth") is None
|
||||
assert inspect.getdoc(Bar.meth, getattr, True, Bar, "meth") == Foo.meth.__doc__
|
||||
|
||||
|
||||
def test_getdoc_inherited_decorated_method():
|
||||
class Foo:
|
||||
def meth(self):
|
||||
|
Loading…
Reference in New Issue
Block a user