Sphinx:共享函数文档字符串

时间:2021-05-03 22:10:18

标签: python-3.x python-sphinx docstring

我想在多个类中重用用于同一函数的文档字符串。

例如

class square:
     def getArea(L,W):
     """ [description]
     L (int) ... 
     W (int) ... 

     return (int) area of shape
     """
     return L*W

 class rectangle:
     def getArea(L,W):
     """ use docstring from above"""
     return L*W

有没有办法在多个函数中使用相同的文档字符串?这是一个简单的例子,但有些函数有 10 个不同的参数,能够使用相同的文档字符串将确保一致性。

0 个答案:

没有答案