【发布时间】:2021-11-05 11:08:46
【问题描述】:
元类:
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:
【问题讨论】:
-
尝试在返回和代码块之间插入一个空行。
-
"blank line" 不会对任何 Python 代码产生任何影响,但对于 linter 警告。 (在这种情况下不是)
标签: python python-sphinx metaclass autodoc