mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5533 from ericvw/autodoc_member-only_default-options
autodoc: Respect `member-order` in `autodoc_default_options` as documented
This commit is contained in:
commit
44b385e2c9
1
AUTHORS
1
AUTHORS
@ -68,6 +68,7 @@ Other contributors, listed alphabetically, are:
|
||||
* Antonio Valentino -- qthelp builder, docstring inheritance
|
||||
* Filip Vavera -- napoleon todo directive
|
||||
* Pauli Virtanen -- autodoc improvements, autosummary extension
|
||||
* Eric N. Vander Weele -- autodoc improvements
|
||||
* Stefan van der Walt -- autosummary extension
|
||||
* Thomas Waldmann -- apidoc module fixes
|
||||
* John Waltman -- Texinfo builder
|
||||
|
@ -383,9 +383,10 @@ There are also new config values that you can set:
|
||||
Setting ``None`` is equivalent to giving the option name in the list format
|
||||
(i.e. it means "yes/true/on").
|
||||
|
||||
The supported options are ``'members'``, ``'undoc-members'``,
|
||||
``'private-members'``, ``'special-members'``, ``'inherited-members'``,
|
||||
``'show-inheritance'``, ``'ignore-module-all'`` and ``'exclude-members'``.
|
||||
The supported options are ``'members'``, ``'member-order'``,
|
||||
``'undoc-members'``, ``'private-members'``, ``'special-members'``,
|
||||
``'inherited-members'``, ``'show-inheritance'``, ``'ignore-module-all'`` and
|
||||
``'exclude-members'``.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
|
@ -31,7 +31,7 @@ logger = logging.getLogger(__name__)
|
||||
# common option names for autodoc directives
|
||||
AUTODOC_DEFAULT_OPTIONS = ['members', 'undoc-members', 'inherited-members',
|
||||
'show-inheritance', 'private-members', 'special-members',
|
||||
'ignore-module-all', 'exclude-members']
|
||||
'ignore-module-all', 'exclude-members', 'member-order']
|
||||
|
||||
|
||||
class DummyOptionSpec:
|
||||
|
@ -1569,6 +1569,29 @@ def test_autodoc_default_options_with_values(app):
|
||||
assert ' .. py:attribute:: EnumCls.val3' not in actual
|
||||
assert ' .. py:attribute:: EnumCls.val4' not in actual
|
||||
|
||||
# with :member-order:
|
||||
app.config.autodoc_default_options = {
|
||||
'members': None,
|
||||
'member-order': 'bysource',
|
||||
}
|
||||
actual = do_autodoc(app, 'class', 'target.Class')
|
||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||
'.. py:class:: Class(arg)',
|
||||
' .. py:attribute:: Class.descr',
|
||||
' .. py:method:: Class.meth()',
|
||||
' .. py:method:: Class.skipmeth()',
|
||||
' .. py:method:: Class.excludemeth()',
|
||||
' .. py:attribute:: Class.attr',
|
||||
' .. py:attribute:: Class.prop',
|
||||
' .. py:attribute:: Class.docattr',
|
||||
' .. py:attribute:: Class.udocattr',
|
||||
' .. py:attribute:: Class.mdocattr',
|
||||
' .. py:classmethod:: Class.moore(a, e, f) -> happiness',
|
||||
' .. py:attribute:: Class.inst_attr_inline',
|
||||
' .. py:attribute:: Class.inst_attr_comment',
|
||||
' .. py:attribute:: Class.inst_attr_string',
|
||||
]
|
||||
|
||||
# with :special-members:
|
||||
app.config.autodoc_default_options = {
|
||||
'special-members': '__init__,__iter__',
|
||||
|
Loading…
Reference in New Issue
Block a user