diff --git a/CHANGES b/CHANGES index 3d0159f126c..47c58187c63 100644 --- a/CHANGES +++ b/CHANGES @@ -155,6 +155,7 @@ Features added * #4182: autodoc: Support :confval:`suppress_warnings` * #5533: autodoc: :confval:`autodoc_default_options` supports ``member-order`` +* #5459: autodoc: :confval:`autodoc_default_options` accepts ``True`` as a value * #4018: htmlhelp: Add :confval:`htmlhelp_file_suffix` and :confval:`htmlhelp_link_suffix` * #5559: text: Support complex tables (colspan and rowspan) diff --git a/doc/usage/extensions/autodoc.rst b/doc/usage/extensions/autodoc.rst index 36d497543db..45789e0a24f 100644 --- a/doc/usage/extensions/autodoc.rst +++ b/doc/usage/extensions/autodoc.rst @@ -376,12 +376,12 @@ There are also new config values that you can set: 'members': 'var1, var2', 'member-order': 'bysource', 'special-members': '__init__', - 'undoc-members': None, + 'undoc-members': True, 'exclude-members': '__weakref__' } - Setting ``None`` is equivalent to giving the option name in the list format - (i.e. it means "yes/true/on"). + Setting ``None`` or ``True`` to the value is equivalent to giving only the + option name to the directives. The supported options are ``'members'``, ``'member-order'``, ``'undoc-members'``, ``'private-members'``, ``'special-members'``, @@ -390,6 +390,9 @@ There are also new config values that you can set: .. versionadded:: 1.8 + .. versionchanged:: 2.0 + Accepts ``True`` as a value. + .. confval:: autodoc_docstring_signature Functions imported from C modules cannot be introspected, and therefore the diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 86f80de8fce..9e65e595da7 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -72,7 +72,7 @@ def identity(x): def members_option(arg): # type: (Any) -> Union[object, List[str]] """Used to convert the :members: option to auto directives.""" - if arg is None: + if arg is None or arg is True: return ALL return [x.strip() for x in arg.split(',')] diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index a25a136396b..5faa0c46b91 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -1511,6 +1511,12 @@ def test_autodoc_default_options(app): assert ' .. py:attribute:: EnumCls.val1' in actual assert ' .. py:attribute:: EnumCls.val4' not in actual + # with :members: = True + app.config.autodoc_default_options = {'members': True} + actual = do_autodoc(app, 'class', 'target.enum.EnumCls') + assert ' .. py:attribute:: EnumCls.val1' in actual + assert ' .. py:attribute:: EnumCls.val4' not in actual + # with :members: and :undoc-members: app.config.autodoc_default_options = { 'members': None,