【发布时间】:2018-07-11 23:01:04
【问题描述】:
这和How to document a module constant in Python?有点关系,但不一样。
我在模块中有一个常量(它是一个字典):
possiblestringencodings = dict(
StringsAsBytes=1,
ascii=1,
utf8=1, utf_8=1, U8=1,
utf16=2, utf_16=2, U16=2, utf_16_be=2, utf_16_le=2,
utf32=4, utf_32=4, U32=4, utf_32_be=4, utf_32_le=4,
)
readthedocs 页面有 (see autodata docs):
.. autodata:: construct.possiblestringencodings
但是,这会从 dict docstring(它的 ctor)生成 docstring。如何记录该字典的内容,仅使用 Sphinx 记录其项目?
如果有人想测试修补它,只需 fork 存储库并在 docs/ 文件夹中运行“make html”。 https://github.com/construct/construct/blob/1b53d9122a2c652db64c6558d101caee5bbbab3a/construct/core.py#L1280 https://github.com/construct/construct/blob/1b53d9122a2c652db64c6558d101caee5bbbab3a/docs/api/strings.rst
【问题讨论】:
标签: python dictionary constants python-sphinx