如何设置许多自动模块的默认设置?

2024-06-28 16:21:04 发布

您现在位置:Python中文网/ 问答频道 /正文

假设您有多个类,并使用Sphinx生成文档。而不是写:

ReverseRecallCommandLines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: ReverseRecallCommandLines
    :members:
    :special-members:
    :exclude-members: __dict__,__weakref__

ScratchPadCommandLines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: ScratchPadCommandLines
    :members:
    :special-members:
    :exclude-members: __dict__,__weakref__

SerialRecallCommandLines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: SerialRecallCommandLines
    :members:
    :special-members:
    :exclude-members: __dict__,__weakref__

您可以定义:

^{pr2}$

在配置文件. 在

这将使上述代码简化为:

ReverseRecallCommandLines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: ReverseRecallCommandLines

ScratchPadCommandLines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: ScratchPadCommandLines


SerialRecallCommandLines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: SerialRecallCommandLines

问题:是否有类似的方式将“默认值”注入到自动模块中,从而实现以下功能:

Stacked Attention Networks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: miprometheus.models.vqa_baselines.stacked_attention_networks

MAC
~~~~~~~~~~~~~~~~
.. automodule:: miprometheus.models.mac

Tags: 文档定义modelssphinxdictexcludespecialmembers