mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#176: Provide `private-members
` option for autodoc directives.
This commit is contained in:
parent
7401622583
commit
92cb77a131
2
CHANGES
2
CHANGES
@ -12,6 +12,8 @@ Release 1.1 (in development)
|
|||||||
|
|
||||||
* #460: Allow limiting the depth of section numbers for HTML.
|
* #460: Allow limiting the depth of section numbers for HTML.
|
||||||
|
|
||||||
|
* #176: Provide ``private-members`` option for autodoc directives.
|
||||||
|
|
||||||
* #138: Add an ``index`` role, to make inline index entries.
|
* #138: Add an ``index`` role, to make inline index entries.
|
||||||
|
|
||||||
* #443: Allow referencing external graphviz files.
|
* #443: Allow referencing external graphviz files.
|
||||||
|
@ -93,8 +93,8 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
|||||||
.. autoclass:: Noodle
|
.. autoclass:: Noodle
|
||||||
:members: eat, slurp
|
:members: eat, slurp
|
||||||
|
|
||||||
* If you want to make the ``members`` option the default, see
|
* If you want to make the ``members`` option (or other flag options described
|
||||||
:confval:`autodoc_default_flags`.
|
below) the default, see :confval:`autodoc_default_flags`.
|
||||||
|
|
||||||
* Members without docstrings will be left out, unless you give the
|
* Members without docstrings will be left out, unless you give the
|
||||||
``undoc-members`` flag option::
|
``undoc-members`` flag option::
|
||||||
@ -103,6 +103,15 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
|||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
|
|
||||||
|
* Private members will be included if the ``private-members`` flag option is
|
||||||
|
given::
|
||||||
|
|
||||||
|
.. autoclass:: my.Class
|
||||||
|
:members:
|
||||||
|
:private-members:
|
||||||
|
|
||||||
|
.. versionadded:: 1.1
|
||||||
|
|
||||||
* For classes and exceptions, members inherited from base classes will be
|
* For classes and exceptions, members inherited from base classes will be
|
||||||
left out, unless you give the ``inherited-members`` flag option, in
|
left out, unless you give the ``inherited-members`` flag option, in
|
||||||
addition to ``members``::
|
addition to ``members``::
|
||||||
@ -152,8 +161,8 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
|||||||
|
|
||||||
.. versionadded:: 0.5
|
.. versionadded:: 0.5
|
||||||
|
|
||||||
* :rst:dir:`automodule` and :rst:dir:`autoclass` also has an ``member-order`` option
|
* :rst:dir:`automodule` and :rst:dir:`autoclass` also has an ``member-order``
|
||||||
that can be used to override the global value of
|
option that can be used to override the global value of
|
||||||
:confval:`autodoc_member_order` for one directive.
|
:confval:`autodoc_member_order` for one directive.
|
||||||
|
|
||||||
.. versionadded:: 0.6
|
.. versionadded:: 0.6
|
||||||
@ -173,9 +182,9 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
|||||||
|
|
||||||
|
|
||||||
.. rst:directive:: autofunction
|
.. rst:directive:: autofunction
|
||||||
autodata
|
autodata
|
||||||
automethod
|
automethod
|
||||||
autoattribute
|
autoattribute
|
||||||
|
|
||||||
These work exactly like :rst:dir:`autoclass` etc., but do not offer the options
|
These work exactly like :rst:dir:`autoclass` etc., but do not offer the options
|
||||||
used for automatic member documentation.
|
used for automatic member documentation.
|
||||||
@ -193,11 +202,11 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
|||||||
|
|
||||||
baz = 2
|
baz = 2
|
||||||
"""Docstring for class attribute Foo.baz."""
|
"""Docstring for class attribute Foo.baz."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#: Doc comment for instance attribute qux.
|
#: Doc comment for instance attribute qux.
|
||||||
self.qux = 3
|
self.qux = 3
|
||||||
|
|
||||||
self.spam = 4
|
self.spam = 4
|
||||||
"""Docstring for instance attribute spam."""
|
"""Docstring for instance attribute spam."""
|
||||||
|
|
||||||
@ -253,7 +262,8 @@ There are also new config values that you can set:
|
|||||||
|
|
||||||
This value is a list of autodoc directive flags that should be automatically
|
This value is a list of autodoc directive flags that should be automatically
|
||||||
applied to all autodoc directives. The supported flags are ``'members'``,
|
applied to all autodoc directives. The supported flags are ``'members'``,
|
||||||
``'undoc-members'``, ``'inherited-members'`` and ``'show-inheritance'``.
|
``'undoc-members'``, ``'private-members'``, ``'inherited-members'`` and
|
||||||
|
``'show-inheritance'``.
|
||||||
|
|
||||||
If you set one of these flags in this config value, you can use a negated
|
If you set one of these flags in this config value, you can use a negated
|
||||||
form, :samp:`'no-{flag}'`, in an autodoc directive, to disable it once.
|
form, :samp:`'no-{flag}'`, in an autodoc directive, to disable it once.
|
||||||
|
@ -518,8 +518,9 @@ class Documenter(object):
|
|||||||
|
|
||||||
Members are skipped if
|
Members are skipped if
|
||||||
|
|
||||||
- they are private (except if given explicitly)
|
- they are private (except if given explicitly or the private-members
|
||||||
- they are undocumented (except if undoc-members is given)
|
option is set)
|
||||||
|
- they are undocumented (except if the undoc-members option is set)
|
||||||
|
|
||||||
The user can override the skipping decision by connecting to the
|
The user can override the skipping decision by connecting to the
|
||||||
``autodoc-skip-member`` event.
|
``autodoc-skip-member`` event.
|
||||||
@ -541,7 +542,7 @@ class Documenter(object):
|
|||||||
|
|
||||||
if want_all and membername.startswith('_'):
|
if want_all and membername.startswith('_'):
|
||||||
# ignore members whose name starts with _ by default
|
# ignore members whose name starts with _ by default
|
||||||
skip = True
|
skip = not self.options.private_members
|
||||||
elif (namespace, membername) in attr_docs:
|
elif (namespace, membername) in attr_docs:
|
||||||
# keep documented attributes
|
# keep documented attributes
|
||||||
skip = False
|
skip = False
|
||||||
@ -713,6 +714,7 @@ class ModuleDocumenter(Documenter):
|
|||||||
'show-inheritance': bool_option, 'synopsis': identity,
|
'show-inheritance': bool_option, 'synopsis': identity,
|
||||||
'platform': identity, 'deprecated': bool_option,
|
'platform': identity, 'deprecated': bool_option,
|
||||||
'member-order': identity, 'exclude-members': members_set_option,
|
'member-order': identity, 'exclude-members': members_set_option,
|
||||||
|
'private-members': bool_option,
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -866,7 +868,7 @@ class ClassDocumenter(ModuleLevelDocumenter):
|
|||||||
'members': members_option, 'undoc-members': bool_option,
|
'members': members_option, 'undoc-members': bool_option,
|
||||||
'noindex': bool_option, 'inherited-members': bool_option,
|
'noindex': bool_option, 'inherited-members': bool_option,
|
||||||
'show-inheritance': bool_option, 'member-order': identity,
|
'show-inheritance': bool_option, 'member-order': identity,
|
||||||
'exclude-members': members_set_option,
|
'exclude-members': members_set_option, 'private-members': bool_option,
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -1134,7 +1136,7 @@ class AutoDirective(Directive):
|
|||||||
|
|
||||||
# flags that can be given in autodoc_default_flags
|
# flags that can be given in autodoc_default_flags
|
||||||
_default_flags = set(['members', 'undoc-members', 'inherited-members',
|
_default_flags = set(['members', 'undoc-members', 'inherited-members',
|
||||||
'show-inheritance'])
|
'show-inheritance', 'private-members'])
|
||||||
|
|
||||||
# standard docutils directive settings
|
# standard docutils directive settings
|
||||||
has_content = True
|
has_content = True
|
||||||
|
@ -30,6 +30,7 @@ def setup_module():
|
|||||||
options = Struct(
|
options = Struct(
|
||||||
inherited_members = False,
|
inherited_members = False,
|
||||||
undoc_members = False,
|
undoc_members = False,
|
||||||
|
private_members = False,
|
||||||
show_inheritance = False,
|
show_inheritance = False,
|
||||||
noindex = False,
|
noindex = False,
|
||||||
synopsis = '',
|
synopsis = '',
|
||||||
|
Loading…
Reference in New Issue
Block a user