You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a class with decorated methods. The function used as a decorator is provided by a module not available when building the documentation, hence this module is mocked in conf.py using autodoc_mock_imports = ['module_with_decorator'].
.. automodule:: my_class
:members:
from module_with_decorator import my_decorator
class MyClass:
"""
My test class.
"""
@staticmethod
def my_undecorated_static_method():
"""This is my_undecorated_static_method."""
@staticmethod
@my_decorator(param0, param1)
def my_decorated_static_method():
"""This is my_decorated_static_method."""
@classmethod
def my_undecorated_class_method(cls):
"""This is my_undecorated_class_method."""
@classmethod
@my_decorator(param0, param1)
def my_decorated_class_method(cls):
"""This is my_decorated_class_method."""
def my_undecorated_instance_method(self):
"""This is my_undecorated_instance_method."""
@my_decorator(param0, param1)
def my_decorated_instance_method(self):
"""This is my_decorated_instance_method."""
The decorated class methods are not shown in the documentation - others are shown correctly.
Any suggestions regarding this issue?
How to Reproduce
Decorate a class method with a function from a mocked module.
PowerShell:
$builder_name = "html" ; $doc_source = "...\test\doc\tp_testcase_docstring" ; $dest = "$doc_source_build$builder_name" ; conda activate $conda_env ; sphinx-build "$doc_source" "$dest" -b $builder_name
Expected behavior
The class methods should be visible in the documentation.
At present, decorators on the mocked module are not working because they return mocked objects instead of functions or methods. I don't have good ideas to generate documents for them. So I marked this as "help wanted".
Please post your idea or send a PR to implement it. Thanks,
Describe the bug
I have a class with decorated methods. The function used as a decorator is provided by a module not available when building the documentation, hence this module is mocked in
conf.py
usingautodoc_mock_imports = ['module_with_decorator']
.The decorated class methods are not shown in the documentation - others are shown correctly.
Any suggestions regarding this issue?
How to Reproduce
Decorate a class method with a function from a mocked module.
PowerShell:
$builder_name = "html" ; $doc_source = "...\test\doc\tp_testcase_docstring" ; $dest = "$doc_source_build$builder_name" ; conda activate $conda_env ; sphinx-build "$doc_source" "$dest" -b $builder_name
Expected behavior
The class methods should be visible in the documentation.
Your project
test.zip
Screenshots
No response
OS
Windows
Python version
3.9.7
Sphinx version
4.4.0
Sphinx extensions
sphinx.ext.autodoc
Extra tools
No response
Additional context
Related to stackoverflow.com.
The text was updated successfully, but these errors were encountered: