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:
Georg Brandl 2008-12-15 12:49:40 +01:00
parent 69ff09917c
commit 037954d850
3 changed files with 31 additions and 7 deletions

11
CHANGES
View File

@ -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

View File

@ -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

View File

@ -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."""