summaryrefslogtreecommitdiffstats
path: root/doc/conf.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-11 10:32:30 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-11 10:32:30 -0400
commit71c679e1a0105490bd5845a15de5e8f1a32e2166 (patch)
treec528e62098b599d7ae74ea53908a045ccf2ffb63 /doc/conf.py
parentb682d9e3c11f94a9a9dc254a6d53e44f953a74bf (diff)
downloadbcfg2-71c679e1a0105490bd5845a15de5e8f1a32e2166.tar.gz
bcfg2-71c679e1a0105490bd5845a15de5e8f1a32e2166.tar.bz2
bcfg2-71c679e1a0105490bd5845a15de5e8f1a32e2166.zip
Cfg: documented all Cfg modules, added development docs
Diffstat (limited to 'doc/conf.py')
-rw-r--r--doc/conf.py40
1 files changed, 27 insertions, 13 deletions
diff --git a/doc/conf.py b/doc/conf.py
index c10c073c3..31a7960fe 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -219,23 +219,37 @@ latex_use_modindex = False
autodoc_default_flags = ['members', 'show-inheritance']
autoclass_content = "both"
-private_re = re.compile(r'^\s*\.\.\s*private-include\s*$')
+private_re = re.compile(r'^\s*\.\.\s*private-include:\s*(.+)$')
+
+private_include = []
def skip_member_from_docstring(app, what, name, obj, skip, options):
""" since sphinx 1.0 autodoc doesn't support the :private-members:
directive, this function allows you to specify
- ``.. private-include`` in the docstring of a private method, etc.,
- to ensure that it's included. This only works on things with
- docstrings """
- if (not skip or
- not hasattr(obj, '__doc__') or not obj.__doc__):
- return skip
-
- for line in obj.__doc__.splitlines():
- if private_re.match(line):
- return False
-
- return skip
+ ``.. private-include: <name>[,<name,...]`` in the docstring of a
+ class containing a private method, etc., to ensure that it's
+ included. Due to a bug in Sphinx, this doesn't work for attributes
+ -- only things that actually have docstrings. If you want to
+ include private attributes, you have to explicitly include them,
+ either with :members:, or by putting :autoattribute: in the
+ __init__ docstring for a class or module docstring."""
+ global private_include
+ if name == '__doc__':
+ private_include = []
+ if not obj:
+ return None
+ for line in obj.splitlines():
+ match = private_re.match(line)
+ if match:
+ private_include.extend(re.split(r',\s*', match.group(1)))
+ return None
+
+ if not skip:
+ return None
+
+ if name in private_include:
+ return False
+ return None
def setup(app):
app.connect('autodoc-skip-member', skip_member_from_docstring)