mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
The `autodoc_skip_member
` event now also gets to decide
whether to skip members whose name starts with underscores. Previously, these members were always automatically skipped. Therefore, if you handle this event, add something like this to your event handler to restore the old behavior:: if name.startswith('_'): return True
This commit is contained in:
parent
69ff09917c
commit
037954d850
11
CHANGES
11
CHANGES
@ -4,6 +4,17 @@ Release 0.6 (in development)
|
||||
New features added
|
||||
------------------
|
||||
|
||||
* Incompatible changes:
|
||||
|
||||
- The ``autodoc_skip_member`` event now also gets to decide
|
||||
whether to skip members whose name starts with underscores.
|
||||
Previously, these members were always automatically skipped.
|
||||
Therefore, if you handle this event, add something like this
|
||||
to your event handler to restore the old behavior::
|
||||
|
||||
if name.startswith('_'):
|
||||
return True
|
||||
|
||||
* Configuration:
|
||||
|
||||
- The new ``html_add_permalinks`` config value can be used to
|
||||
|
@ -525,14 +525,15 @@ class RstGenerator(object):
|
||||
all_members = sorted(todoc.__dict__.iteritems())
|
||||
else:
|
||||
all_members = [(mname, getattr(todoc, mname)) for mname in members]
|
||||
for (membername, member) in all_members:
|
||||
# ignore members whose name starts with _ by default
|
||||
if _all and membername.startswith('_'):
|
||||
continue
|
||||
|
||||
# ignore undocumented members if :undoc-members: is not given
|
||||
doc = getattr(member, '__doc__', None)
|
||||
skip = not self.options.undoc_members and not doc
|
||||
for (membername, member) in all_members:
|
||||
if _all and membername.startswith('_'):
|
||||
# ignore members whose name starts with _ by default
|
||||
skip = True
|
||||
else:
|
||||
# ignore undocumented members if :undoc-members: is not given
|
||||
doc = getattr(member, '__doc__', None)
|
||||
skip = not self.options.undoc_members and not doc
|
||||
# give the user a chance to decide whether this member should be skipped
|
||||
if self.env.app:
|
||||
# let extensions preprocess docstrings
|
||||
|
@ -24,6 +24,7 @@ def setup_module():
|
||||
app.builder.env.app = app
|
||||
app.connect('autodoc-process-docstring', process_docstring)
|
||||
app.connect('autodoc-process-signature', process_signature)
|
||||
app.connect('autodoc-skip-member', skip_member)
|
||||
|
||||
options = Struct(
|
||||
inherited_members = False,
|
||||
@ -71,6 +72,13 @@ def process_signature(app, what, name, obj, options, args, retann):
|
||||
return '42', None
|
||||
|
||||
|
||||
def skip_member(app, what, name, obj, skip, options):
|
||||
if name.startswith('_'):
|
||||
return True
|
||||
if name == 'skipmeth':
|
||||
return True
|
||||
|
||||
|
||||
def test_resolve_name():
|
||||
# for modules
|
||||
assert gen.resolve_name('module', 'test_autodoc') == \
|
||||
@ -380,6 +388,10 @@ class Class(Base):
|
||||
def undocmeth(self):
|
||||
pass
|
||||
|
||||
def skipmeth(self):
|
||||
"""Method that should be skipped."""
|
||||
pass
|
||||
|
||||
@property
|
||||
def prop(self):
|
||||
"""Property."""
|
||||
|
Loading…
Reference in New Issue
Block a user