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

时间:2019-01-11 00:49:41

标签: python default python-sphinx autodoc

假设您有多个类,并使用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__

您可以定义:

autodoc_default_options = {
    'members': None, # Include all members (methods).
    'special-members': None,
    'exclude-members': '__dict__,__weakref__' # Exclude "standard" methods.
    }

在conf.py中。

这将使上面的代码简化为:

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

0 个答案:

没有答案