Python 如何在Sphinx中的方法内自动记录函数

Python 如何在Sphinx中的方法内自动记录函数,python,scope,python-sphinx,restructuredtext,autodoc,Python,Scope,Python Sphinx,Restructuredtext,Autodoc,代码示例: class A(object): def do_something(self): """ doc_a """ def inside_function(): """ doc_b """ pass pass 我试过: .. autoclass:: A .. autofunction:: A.do_something.inside_function 但它不起作用 有什么方法可

代码示例:

class A(object):
    def do_something(self):
        """ doc_a """
        def inside_function():
            """ doc_b """
            pass
        pass
我试过:

.. autoclass:: A
    .. autofunction:: A.do_something.inside_function
但它不起作用


有什么方法可以为我生成
文档吗?

函数中的函数位于局部变量范围内。函数的局部变量无法从函数外部访问:

>>> def x():
...    def y():
...       pass
... 
>>> x
<function x at 0x7f68560295f0>
>>> x.y
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'y'
一开始无法访问:

>>> x.y
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'y'
>>x.y
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
AttributeError:“函数”对象没有属性“y”
但在第一次调用函数后,它将是:

>>> x()
>>> x.y
<function _y at 0x1a720c8>
>>x()
>>>x.y
如果在Sphinx导入模块时执行该函数,这可能会起作用

>>> x()
>>> x.y
<function _y at 0x1a720c8>