Sphinx/readthedocs的谷歌风格文档字符串的样式指南检查?

2024-10-03 02:47:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我们正在使用SphinxV3构建文档,并使用Sphinx.ext.napoleon和谷歌风格的docstring读取文档。当我们在本地构建时,Sphinx不会将格式错误的Google文档字符串作为警告捕获。例如:

"""
This should go next to the triple quotes above.

Args: there should be nothing here
    sample_arg (int): there also shouldn't be anything here
    Some documentation that is missing a tab at the beginning.

Missing return
"""

使用make html在本地构建,这不会抛出任何警告,但会严重破坏它在readthedocs上的显示方式。我们在conf.py{}变量中添加了sphinx.ext.napoleon,并保持了原始Makefile的原样,除了在SPHINXOPTS下添加标志-W --keep-going -a -E

如果有人试图用糟糕的Google风格的文档运行make build,有没有办法让Sphinx使构建失败?还是我们必须接受手动检查和识别这些错误


Tags: the文档警告makehere风格错误sphinx