Skip to content

Commit

Permalink
Fix sphinx-doc#9655: autodoc: mocked object having doc comment is war…
Browse files Browse the repository at this point in the history
…ned unexpectedly

A warning for mocked object should not be emitted if it has doc comment.
  • Loading branch information
tk0miya committed Sep 23, 2021
1 parent 3774c12 commit 42b02f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -21,6 +21,7 @@ Bugs fixed
* #9630: autodoc: Failed to build cross references if :confval:`primary_domain`
is not 'py'
* #9644: autodoc: Crashed on getting source info from problematic object
* #9655: autodoc: mocked object having doc comment is warned unexpectedly
* #9630: autosummary: Failed to build summary table if :confval:`primary_domain`
is not 'py'

Expand Down
3 changes: 2 additions & 1 deletion sphinx/ext/autodoc/__init__.py
Expand Up @@ -913,7 +913,8 @@ def generate(self, more_content: Optional[StringList] = None, real_modname: str
if not self.import_object():
return

if ismock(self.object):
docstrings: List[str] = sum(self.get_doc() or [], [])
if ismock(self.object) and not docstrings:
logger.warning(__('A mocked object is detected: %r'),
self.name, type='autodoc')

Expand Down

0 comments on commit 42b02f2

Please sign in to comment.