Skip to content

Commit

Permalink
Fix #9479: autodoc: Emit a warning if target is a mocked object
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jul 27, 2021
1 parent f590268 commit a7daa19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -14,6 +14,7 @@ Features added
--------------

* #9445: autodoc: Support class properties
* #9479: autodoc: Emit a warning if target is a mocked object
* #9445: py domain: ``:py:property:`` directive supports ``:classmethod:``
option to describe the class property

Expand Down
4 changes: 4 additions & 0 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -913,6 +913,10 @@ def generate(self, more_content: Optional[StringList] = None, real_modname: str
if not self.import_object():
return

if ismock(self.object):
logger.warning(__('A mocked object is detected: %r'),
self.name, type='autodoc')

# If there is no real module defined, figure out which to use.
# The real module is used in the module analyzer to look up the module
# where the attribute documentation would actually be found in.
Expand Down

0 comments on commit a7daa19

Please sign in to comment.