元类:
class RequestMeta(type):
def __new__(mcs, what, bases, attrs):
_attrs = {name: decimal_to_string(attr) if callable(attr) else attr for name, attr in attrs.items()}
return super().__new__(mcs, what, bases, _attrs)
当我们为元类导入RequestMeta时,Sphinx无法生成成员:
Class_name(metaclass=RequestMeta)
def test
"""
Get test
:return:
.. code-block:: json
[
{
"message":"test",
"timestamp": 123
}
]
"""
test.rst:
Test
____
.. autoclass:: my_prog.a.Class_name
:members:
问题可能在于
decimal_to_string
装饰器。Sphinx不会关心元类,但是如果在装饰函数时去掉它的属性,那么它就无能为力了检查
decimal_to_string
是否正在functools.wraps
中包装其目标函数-这可能会解决您的问题相关问题 更多 >
编程相关推荐