2

Assume that you have multiple classes and generate documentation using Sphinx. Instead of writing:

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__

you can define:

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

in conf.py.

That will enable to simplify the above code to:

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

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


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

Question: is there a similar way to inject "defaults" to automodules, which will enable something like this:

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

MAC
~~~~~~~~~~~~~~~~
.. automodule:: miprometheus.models.mac
mzjn
  • 48,958
  • 13
  • 128
  • 248
  • As far as I can tell, `autodoc_default_options` applies to both `autoclass` and `automodule`. – mzjn Jan 13 '19 at 12:56
  • Ok, I have just discovered that this is a problem with ReadTheDoc - locally "when I set autodoc_default_options" it seems to work. properly But, when I check the documentation on RTD, it contains only main description of classes, thus clearly ignores the default settings. Any hints here? – Tomasz Kornuta Jan 17 '19 at 01:31
  • Different Sphinx versions? `autodoc_default_options` was added in Sphinx 1.8. – mzjn Jan 17 '19 at 07:32

0 Answers0