1 year ago

#334362

test-img

Guti_Haz

Sphinx automodule: class method not documented when decorated with mocked function

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.

Missing class method decorated with mocked function

Any suggestions regarding this issue?

mocking

python-sphinx

python-decorators

class-method

autodoc

0 Answers

Your Answer

Accepted video resources