首页 > 解决方案 > 用于 Sphinx/readthedocs 的 Google 样式文档字符串的样式指南检查?

问题描述

我们正在使用 Sphinx v3 构建文档,并使用 sphinx.ext.napoleon 和 Google 样式的文档字符串阅读文档。当我们在本地构建时,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 上的显示方式。我们sphinx.ext.napoleonconf.py extensions变量中添加并保持原始 Makefile 不变,除了-W --keep-going -a -ESPHINXOPTS.

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

标签: pythonpython-sphinxread-the-docs

解决方案


推荐阅读