From b3ee43700cd6a88881c440fa845995d17dddf2b6 Mon Sep 17 00:00:00 2001 From: mcantor Date: Wed, 1 Dec 2010 21:45:47 -0500 Subject: [PATCH] added a :private-members: option to autodoc, which will instruct directives to include members whose names start with an underscore --- sphinx/ext/autodoc.py | 7 ++++--- tests/test_autodoc.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 696e5f1d08..2c67461002 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -541,7 +541,7 @@ class Documenter(object): if want_all and membername.startswith('_'): # ignore members whose name starts with _ by default - skip = True + skip = not self.options.private_members elif (namespace, membername) in attr_docs: # keep documented attributes skip = False @@ -713,6 +713,7 @@ class ModuleDocumenter(Documenter): 'show-inheritance': bool_option, 'synopsis': identity, 'platform': identity, 'deprecated': bool_option, 'member-order': identity, 'exclude-members': members_set_option, + 'private-members': bool_option, } @classmethod @@ -866,7 +867,7 @@ class ClassDocumenter(ModuleLevelDocumenter): 'members': members_option, 'undoc-members': bool_option, 'noindex': bool_option, 'inherited-members': bool_option, 'show-inheritance': bool_option, 'member-order': identity, - 'exclude-members': members_set_option, + 'exclude-members': members_set_option, 'private-members': bool_option, } @classmethod @@ -1134,7 +1135,7 @@ class AutoDirective(Directive): # flags that can be given in autodoc_default_flags _default_flags = set(['members', 'undoc-members', 'inherited-members', - 'show-inheritance']) + 'show-inheritance', 'private-members']) # standard docutils directive settings has_content = True diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 8f983471ce..f2aa922081 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -38,6 +38,7 @@ def setup_module(): members = [], member_order = 'alphabetic', exclude_members = set(), + private_members = False ) directive = Struct(