From b67a58eb6d1ad91628555d2abdd7bc01be759194 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 21 Feb 2010 23:31:58 +0100 Subject: [PATCH] docs: Add module which turns on autodoc for private members with docstrings --- docs/autodoc_private_members.py | 10 ++++++++++ docs/conf.py | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 docs/autodoc_private_members.py diff --git a/docs/autodoc_private_members.py b/docs/autodoc_private_members.py new file mode 100644 index 00000000..9cb2e49b --- /dev/null +++ b/docs/autodoc_private_members.py @@ -0,0 +1,10 @@ +def setup(app): + app.connect('autodoc-skip-member', autodoc_private_members_with_doc) + +def autodoc_private_members_with_doc(app, what, name, obj, skip, options): + if not skip: + return skip + if (name.startswith('_') and obj.__doc__ is not None + and not (name.startswith('__') and name.endswith('__'))): + return False + return skip diff --git a/docs/conf.py b/docs/conf.py index 841260e7..94c08e90 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,13 +16,14 @@ import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.append(os.path.abspath(os.path.dirname(__file__))) sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/../')) # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc'] +extensions = ['sphinx.ext.autodoc', 'autodoc_private_members'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -192,3 +193,4 @@ latex_documents = [ # If false, no module index is generated. #latex_use_modindex = True +