Skip to content

Commit

Permalink
Merge pull request #8361 from sphinx-doc/4606_incorrect_location_of_d…
Browse files Browse the repository at this point in the history
…ocstring

Fix #4606: autodoc: the location of the warning is incorrect for inherited method
  • Loading branch information
tk0miya committed Nov 8, 2020
2 parents bca35cd + e1e0106 commit 8981e84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -21,6 +21,7 @@ Bugs fixed
----------

* #7613: autodoc: autodoc does not respect __signature__ of the class
* #4606: autodoc: the location of the warning is incorrect for inherited method

Testing
--------
Expand Down
13 changes: 11 additions & 2 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -543,9 +543,18 @@ def process_doc(self, docstrings: List[List[str]]) -> Iterator[str]:
yield from docstringlines

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:
return '%s:docstring of %s' % (self.analyzer.srcname, self.fullname)
return 'docstring of %s' % self.fullname
return '%s:docstring of %s' % (self.analyzer.srcname, fullname)
else:
return 'docstring of %s' % fullname

def add_content(self, more_content: Any, no_docstring: bool = False) -> None:
"""Add content from docstrings, attribute documentation and user."""
Expand Down

0 comments on commit 8981e84

Please sign in to comment.