autodoc
,因为我非常喜欢在我的文档字符串中简单地正确记录代码,然后让Sphinx自动为我构建API文档。问题在于它使用的reStructuredText语法-在呈现之前,我认为它完全无法阅读。例如:
:param path: The path of the file to wrap
:type path: str
:param field_storage: The :class:`FileStorage` instance to wrap
:type field_storage: FileStorage
:param temporary: Whether or not to delete the file when the File instance
is destructed
:type temporary: bool
您需要真正放慢速度,花费一分钟来理解那个语法混乱的东西。我更喜欢谷歌的方式(Google Python Style Guide),它的对应物如下所示:
Args: path (str): 要包装的文件路径 field_storage (FileStorage): 要包装的 FileStorage 实例 temporary (bool): 当 File 实例被销毁时是否删除该文件非常好!但当然,Sphinx 不会接受这一点,并将
Args:
后面的所有文本渲染为一行。因此,总结一下,在我玷污我的代码库之前,我想知道除了编写自己的 API 文档之外,是否有任何真正的替代使用它和 Sphinx 的方法。例如,是否有一个处理 Google Style Guide 的文档字符串风格的 Sphinx 扩展程序?
sphinx.ext.napoleon
打包在Sphinx中。这实际上是更好的答案。 - ostrokach