Closes #1266: include private modules if includeprivate is true.

This commit is contained in:
Georg Brandl 2014-01-19 11:14:38 +01:00
parent 644c87c9d5
commit 8b986fe4db
2 changed files with 7 additions and 2 deletions

View File

@ -102,7 +102,7 @@ Bugs fixed
* #848: Always take the newest code in incremental rebuilds with the * #848: Always take the newest code in incremental rebuilds with the
:mod:`sphinx.ext.viewcode` extension. :mod:`sphinx.ext.viewcode` extension.
* #979: Fix exclude handling in ``sphinx-apidoc``. * #979, #1266: Fix exclude handling in ``sphinx-apidoc``.
Documentation Documentation
------------- -------------

View File

@ -182,6 +182,7 @@ def recurse_tree(rootpath, excludes, opts):
toplevels = [] toplevels = []
followlinks = getattr(opts, 'followlinks', False) followlinks = getattr(opts, 'followlinks', False)
includeprivate = getattr(opts, 'includeprivate', False)
for root, subs, files in os.walk(rootpath, followlinks=followlinks): for root, subs, files in os.walk(rootpath, followlinks=followlinks):
# document only Python module files (that aren't excluded) # document only Python module files (that aren't excluded)
py_files = sorted(f for f in files py_files = sorted(f for f in files
@ -197,7 +198,11 @@ def recurse_tree(rootpath, excludes, opts):
continue continue
# remove hidden ('.') and private ('_') directories, as well as # remove hidden ('.') and private ('_') directories, as well as
# excluded dirs # excluded dirs
subs[:] = sorted(sub for sub in subs if sub[0] not in ['.', '_'] if includeprivate:
exclude_prefixes = ('.',)
else:
exclude_prefixes = ('.', '_')
subs[:] = sorted(sub for sub in subs if not sub.startswith(exclude_prefixes)
and not is_excluded(path.join(root, sub), excludes)) and not is_excluded(path.join(root, sub), excludes))
if is_pkg: if is_pkg: