Repository: sphinx-doc/sphinx

Issue:
autodoc_default_options should accept True values
**Short version**: Instead of this:

```
autodoc_default_options = {"members": None}
```

it would make more sense to be able to write this:

```
autodoc_default_options = {"members": True}
```

---

The new `autodoc_default_options` config option currently requires that its `dict` values be either strings or `None`, where `None` "means 'yes/true/on'".  Seeing as `None` means `True`, it would make more sense to be able to actually write `True` instead (but keep `None` around for backwards compatibility).

Currently (in Sphinx 1.8), setting an `autodoc_default_options` value to `True` just produces an unhelpful error message:
```
Exception occurred:
  File "/Users/jwodder/work/GITHUB/headerparser/.tox/docs/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 82, in members_option
    return [x.strip() for x in arg.split(',')]
AttributeError: 'bool' object has no attribute 'split'
The full traceback has been saved in /var/folders/l7/wrkq93d133d8zpn36fmqrq0r0000gn/T/sphinx-err-dld5die4.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
```

Discussion:

Patch:
diff --git a/CHANGES b/CHANGES
index c96659a84..4f9075689 100644
--- a/CHANGES
+++ b/CHANGES
@@ -156,6 +156,7 @@ Features added
 * #4182: autodoc: Support :confval:`suppress_warnings`
 * #5533: autodoc: :confval:`autodoc_default_options` supports ``member-order``
 * #5394: autodoc: Display readable names in type annotations for mocked objects
+* #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 36d497543..45789e0a2 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 86f80de8f..9e65e595d 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(',')]
 


Test patch:
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index a56226b42..7758f442d 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -1517,6 +1517,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,