当我有一个闭包定义如下的decorator时:
def Decorator(arg):
class InnerDecorator:
"""Here i use the arg: {arg}"""
__doc__ = __doc__.format(arg=arg)
def __init__(self, func):
self.func = func
# make arg an instance attribute
self.arg = arg
def __call__(self):
return self.func()
return InnerDecorator
我是这样用的:
^{pr2}$使用交互式shell,我可以看到'foo'和'bar的正确doc字符串:
>>> help(MyClass)
我的问题是: 有没有办法用sphinx为“foo”和“bar”方法生成autodoc? 我试过了
.. autoclass:: MyClass
:members:
但这行不通。在
目前为止Thx
这个答案帮助我成功了:https://stackoverflow.com/a/15693082/1901330
作为对示例代码的回答,我执行以下操作:
相关问题 更多 >
编程相关推荐