Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes that inherit mocked imports do not generate docstrings using autodoc. #8164

Closed
Shutchinson opened this issue Aug 31, 2020 · 1 comment

Comments

@Shutchinson
Copy link

Shutchinson commented Aug 31, 2020

Describe the bug
When a class inherits another class from a mocked import as defined in autodoc_mock_imports, the docstring is skipped by autodoc when building documentation.

To Reproduce
Example project taken from #4965

Project module foo.py:

import bar

class FooClass(bar.BarClass):
    """This is myclass"""
    pass

conf.py:

import sys
import os

autodoc_mock_imports = ['bar']

sys.path.insert(0, os.path.abspath('.'))

extensions = [
    'sphinx.ext.autodoc',
]

contents.rst:

foo
===

.. automodule:: foo
    :members:
    :undoc-members:
    :show-inheritance:

Build Command

$ sphinx-apidoc -f -o docs/ .
$ sphinx-build -b html docs/ docs/build/html -E -a

Expected behavior
The built documentation would include the foo.FooClass class and its docstring.

Your project
mocked_import_issue.zip

Environment info

  • OS: Linux
  • Python version: 3.8.5
  • Sphinx version: 3.2.1
  • Sphinx extensions: sphinx.ext.autodoc
  • Extra tools:

Additional context
Sphinx 3.0.1 build correctly, later versions skip the foo.FooClass when building documentation.

@tk0miya tk0miya added this to the 3.3.0 milestone Aug 31, 2020
@tk0miya
Copy link
Member

tk0miya commented Aug 31, 2020

Note: This was changed since #7504.

@tk0miya tk0miya modified the milestones: 3.3.0, 3.4.0 Nov 1, 2020
tk0miya added a commit to tk0miya/sphinx that referenced this issue Nov 11, 2020
The mock objects set up via `autosummary_mock_imports` causes slow down
of autosummary stub generation because AttributeDocumenter falls into
infinite recursion call to unwrap decorators of mocked objects.

To avoid the trouble, this blocks unwrapping decorators of mocked
objects.
@tk0miya tk0miya modified the milestones: 3.4.0, 3.5.0 Dec 20, 2020
tk0miya added a commit to tk0miya/sphinx that referenced this issue Dec 28, 2020
@tk0miya tk0miya modified the milestones: 3.5.0, 3.4.2 Dec 28, 2020
tk0miya added a commit to tk0miya/sphinx that referenced this issue Dec 28, 2020
…ot documented

Use ismock() to check a module member is a mocked or not. It allows not
to skip subclasses of mocked class.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Dec 28, 2020
…ot documented

Use ismock() to check a module member is a mocked or not. It allows not
to skip subclasses of mocked class.
tk0miya added a commit that referenced this issue Dec 29, 2020
Fix #8164: autodoc: Classes that inherit mocked class are not documented
@tk0miya tk0miya closed this as completed Dec 29, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants