【发布时间】:2013-12-12 04:26:08
【问题描述】:
我有一个模块,errors.py,其中定义了几个全局常量(注意:我知道 Python 没有常量,但我已经按照约定使用大写来定义它们)。
"""Indicates some unknown error."""
API_ERROR = 1
"""Indicates that the request was bad in some way."""
BAD_REQUEST = 2
"""Indicates that the request is missing required parameters."""
MISSING_PARAMS = 3
使用 reStructuredText 如何记录这些常量?如您所见,我在它们上方列出了一个文档字符串,但我没有找到任何表明这样做的文档,我只是猜测。
【问题讨论】:
-
“我如何记录这些常量?”是什么意思。添加 cmets(或您的情况下的字符串)已经是一种文档形式。您是在问如何让 sphinx-autodoc 识别您的内部文档并将其显示在 sphinx 的输出中?
标签: python python-sphinx restructuredtext