docs: Add module which turns on autodoc for private members with docstrings
This commit is contained in:
parent
c96d9d9108
commit
b67a58eb6d
10
docs/autodoc_private_members.py
Normal file
10
docs/autodoc_private_members.py
Normal file
@ -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
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user