mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #4606: autodoc: the location of the warning is incorrect for inherited method
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -20,6 +20,8 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #4606: autodoc: the location of the warning is incorrect for inherited method
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -543,9 +543,18 @@ class Documenter:
|
|||||||
yield from docstringlines
|
yield from docstringlines
|
||||||
|
|
||||||
def get_sourcename(self) -> str:
|
def get_sourcename(self) -> str:
|
||||||
|
if (getattr(self.object, '__module__', None) and
|
||||||
|
getattr(self.object, '__qualname__', None)):
|
||||||
|
# Get the correct location of docstring from self.object
|
||||||
|
# to support inherited methods
|
||||||
|
fullname = '%s.%s' % (self.object.__module__, self.object.__qualname__)
|
||||||
|
else:
|
||||||
|
fullname = self.fullname
|
||||||
|
|
||||||
if self.analyzer:
|
if self.analyzer:
|
||||||
return '%s:docstring of %s' % (self.analyzer.srcname, self.fullname)
|
return '%s:docstring of %s' % (self.analyzer.srcname, fullname)
|
||||||
return 'docstring of %s' % self.fullname
|
else:
|
||||||
|
return 'docstring of %s' % fullname
|
||||||
|
|
||||||
def add_content(self, more_content: Any, no_docstring: bool = False) -> None:
|
def add_content(self, more_content: Any, no_docstring: bool = False) -> None:
|
||||||
"""Add content from docstrings, attribute documentation and user."""
|
"""Add content from docstrings, attribute documentation and user."""
|
||||||
|
|||||||
Reference in New Issue
Block a user