hir*_*ist 4 python python-3.x python-sphinx
我知道我可以在 sphinx 中记录(模块)常量
#: a tuple of primes
primes = (2, 3, 5, 7, 11, 13, 17)
Run Code Online (Sandbox Code Playgroud)
或者
primes = (2, 3, 5, 7, 11, 13, 17)
"""a tuple of primes"""
Run Code Online (Sandbox Code Playgroud)
然后它将出现在 sphinx 生成的文档中;即它看起来像这样:
somemodule.primes
= (2, 3, 5, 7, 11, 13, 17)素数元组
但如果数据是一个很长的列表怎么办?那么我希望能够在文档中包含文档字符串,但在文档中不包含实际数据本身。
这就是我想要在文档中包含的内容:
somemodule.primes素数元组
有什么方法可以实现这个目标吗?
为了完整性:
我运行sphinx-quickstart并启用了 autodoc:
autodoc: automatically insert docstrings from modules (y/n) [n]: y
Run Code Online (Sandbox Code Playgroud)
我唯一添加的index.rst是:
``somemodule``
**************
.. automodule:: somemodule
:members:
Run Code Online (Sandbox Code Playgroud)
并somemodule.py包含这个:
#: a tuple of primes
primes = (2, 3, 5, 7, 11, 13, 17)
Run Code Online (Sandbox Code Playgroud)
然后我就适应sys.path了conf.py这somemodule.py条道路。
以防万一有人来到这里。要隐藏变量的内容,请使用元信息列表字段。
Example:
primes = (2, 3, 5, 7, 11, 13, 17)
"""A tuple of primes.
:meta hide-value:
"""
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1013 次 |
| 最近记录: |