我正在使用sphinx来记录一个项目,并且在使用装饰器中包装的函数时遇到问题。我见过类似的问题,但似乎没有适合我的问题的解决方案
我有数百个函数都包装在一个自定义装饰器中,该装饰器本身可以接受参数
from functools import wraps
def CustomFunctionDecorator(id, name):
"""Custom decorator"""
def outer(f):
@wraps(f)
def inner(*args, **kwargs):
...do stuff....
f(*args, **kwargs)
return inner
return outer
然后我的功能将如下所示
@CustomFunctionDecorator(123, 'Test')
def TestFunction(a, b, c=None):
"""Test Documentation"""
..do something....
现在,当我使用 sphinx 和 autodoc 来生成我的文档时,包装在 CustomFunctionDecorator 中的所有函数都隐藏了 sphinx 文档中函数的实际参数,并且看起来像这样
TestFunction(*args, **kwargs)
测试文档
该文档有效,但函数参数不....
有任何想法吗?希望我说清楚了