Skip to content

Commit

Permalink
Allow users to suppress autodoc.mocked_object warnings (#9732)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <[email protected]>
  • Loading branch information
CyrilRoelandteNovance and AA-Turner authored Jan 19, 2025
1 parent fc62472 commit 34037aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Features added
pattern doesn't match any documents, via the new ``toc.glob_not_matching``
warning sub-type.
Patch by Slawek Figiel.
* #9732: Add the new ``autodoc.mock_objects`` warnings sub-type.
Patch by Cyril Roelandt.

Bugs fixed
----------
Expand Down
6 changes: 6 additions & 0 deletions doc/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,7 @@ Options for warning control

* ``autodoc``
* ``autodoc.import_object``
* ``autodoc.mocked_object``
* ``autosectionlabel.<document name>``
* ``autosummary``
* ``autosummary.import_cycle``
Expand Down Expand Up @@ -1453,6 +1454,11 @@ Options for warning control
.. versionadded:: 8.2
Added ``toc.empty_glob``.

.. versionadded:: 8.2

Added ``autodoc.mocked_object``


Builder options
===============

Expand Down
5 changes: 4 additions & 1 deletion sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,10 @@ def generate(
)
if ismock(self.object) and not docstrings:
logger.warning(
__('A mocked object is detected: %r'), self.name, type='autodoc'
__('A mocked object is detected: %r'),
self.name,
type='autodoc',
subtype='mocked_object',
)

# check __module__ of object (for members not given explicitly)
Expand Down

0 comments on commit 34037aa

Please sign in to comment.