相关疑难解决方法(0)

Python Sphinx autodoc和装饰成员

我试图使用Sphinx来记录我的Python类.我这样做是使用autodoc:

.. autoclass:: Bus
   :members:
Run Code Online (Sandbox Code Playgroud)

虽然它正确地获取我的方法的文档字符串,那些装饰:

    @checkStale
    def open(self):
        """
        Some docs.
        """
        # Code
Run Code Online (Sandbox Code Playgroud)

@checkStale存在

def checkStale(f):
    @wraps(f)
    def newf(self, *args, **kwargs):
        if self._stale:
            raise Exception
        return f(self, *args, **kwargs)
    return newf
Run Code Online (Sandbox Code Playgroud)

有一个不正确的原型,如open(*args, **kwargs).

我怎样才能解决这个问题?我的印象是使用@wraps会修复这种事情.

python decorator python-sphinx

26
推荐指数
3
解决办法
8646
查看次数

标签 统计

decorator ×1

python ×1

python-sphinx ×1