Reputation: 266
When i have a decorator with a closure defined like this:
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
Which I use like this:
class MyClass(object):
@Decorator("ARG")
def foo(self):
pass
@Decorator("Other ARG")
def bar(self):
pass
I can see the correct doc-strings for 'foo' and 'bar using the interactive-shell with:
>>> help(MyClass)
My question is: Is there a way to generate autodoc for methods 'foo' and 'bar' with sphinx? I tried,
.. autoclass:: MyClass
:members:
but that does not work.
Thx so far
Upvotes: 1
Views: 1166
Reputation: 266
This answer helped me to get it work: https://stackoverflow.com/a/15693082/1901330
As answer to my example code i do following:
.. autoclass:: module.MyClass
.. automethod:: module.MyClass.foo(self)
.. automethod:: module.MyClass.bar(self)
Upvotes: 1