Skip to content

Commit

Permalink
Merge pull request #7829 from tk0miya/7805_retval_of_descriptors
Browse files Browse the repository at this point in the history
Fix #7805: autodoc: an object which descriptors returns is documented
  • Loading branch information
tk0miya authored Jun 14, 2020
2 parents 02acad6 + 6c3db6d commit b567721
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Bugs fixed
* #7808: autodoc: Warnings raised on variable and attribute type annotations
* #7802: autodoc: EOFError is raised on parallel build
* #7821: autodoc: TypeError is raised for overloaded C-ext function
* #7805: autodoc: an object which descriptors returns is unexpectedly documented
* #7812: autosummary: generates broken stub files if the target code contains
an attribute and module that are same name
* #7808: napoleon: Warnings raised on variable and attribute type annotations
Expand Down
11 changes: 11 additions & 0 deletions sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,17 @@ def add_directive_header(self, sig: str) -> None:
else:
self.add_line(' :annotation: %s' % self.options.annotation, sourcename)

def get_doc(self, encoding: str = None, ignore: int = None) -> List[List[str]]:
try:
# Disable `autodoc_inherit_docstring` temporarily to avoid to obtain
# a docstring from the value which descriptor returns unexpectedly.
# ref: https://github.com/sphinx-doc/sphinx/issues/7805
orig = self.env.config.autodoc_inherit_docstrings
self.env.config.autodoc_inherit_docstrings = False # type: ignore
return super().get_doc(encoding, ignore)
finally:
self.env.config.autodoc_inherit_docstrings = orig # type: ignore

def add_content(self, more_content: Any, no_docstring: bool = False) -> None:
if not self._datadescriptor:
# if it's not a data descriptor, its docstring is very probably the
Expand Down

0 comments on commit b567721

Please sign in to comment.