【发布时间】:2020-05-09 19:09:17
【问题描述】:
我目前正在使用 Sphinx(第一次使用它)为我的模块构建文档,并且我有一些类有一些用默认值初始化的类变量。
例如:
class ConfigSettings(object):
"""Class that manages a config file
"""
#: Contains the path to the config file (root dir of module)
path = Path(util.getAbsCurrentPath('configfile.ini'))
在构建文档时,会评估变量并打印我不想要的文件的完整路径(出于安全原因)。 有没有办法不显示变量值而只显示使用 Sphinx 的注释?
我尝试了 .. autoclass: 和 .. autodata: 的各种组合,但到目前为止都没有奏效......
这是我目前在构建文件中的内容:
Config module
----------------------------
.. automodule:: lib.config
:members:
:undoc-members:
:show-inheritance:
【问题讨论】:
-
第二个
.. autoclass:中的:noindex:选项仅用于防止Sphinx 发出警告以使用.. autoclass:记录YourClass 两次,因为这会导致通用索引中出现重复条目。
标签: python python-sphinx member docstring autodoc