我将 Sphinx 用于自动文档,但我发现它默认将父类文档字符串附加到我的文档字符串的方式很烦人。
结果是,对于每个继承自 unittest.TestCase
的文档化测试类,我得到了文档字符串 “创建一个类的实例,该实例将在执行时使用指定的测试方法. 如果实例没有具有指定名称的方法,则引发 ValueError。” 附加。所以这两句话一遍又一遍地在我的测试文档中乱扔垃圾。
如何阻止 Sphinx 从父级中提取文档字符串?
最佳答案
有一个 setting :
autodoc_inherit_docstrings
This value controls the docstrings inheritance. If set to
True
the docstring for classes or methods, if not explicitly set, is inherited form (sic) parents.The default is
True
.New in version 1.7.
尽管要小心使用 - 此设置似乎会破坏我在文档字符串中调用的指令。
关于python - 在 Sphinx 中避免来自父级的文档字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16518834/