Skip to content

Commit

Permalink
Closes #5459: autodoc: autodoc_default_options accepts True as a value
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Feb 10, 2019
1 parent 3a237f7 commit b0148c6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions doc/usage/extensions/autodoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'``,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(',')]

Expand Down
6 changes: 6 additions & 0 deletions tests/test_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b0148c6

Please sign in to comment.