diff --git a/CHANGES b/CHANGES index 3621be4be..36b38e03c 100644 --- a/CHANGES +++ b/CHANGES @@ -102,7 +102,7 @@ Bugs fixed * #848: Always take the newest code in incremental rebuilds with the :mod:`sphinx.ext.viewcode` extension. -* #979: Fix exclude handling in ``sphinx-apidoc``. +* #979, #1266: Fix exclude handling in ``sphinx-apidoc``. Documentation ------------- diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py index 4430cdd00..7e95cdaed 100644 --- a/sphinx/apidoc.py +++ b/sphinx/apidoc.py @@ -182,6 +182,7 @@ def recurse_tree(rootpath, excludes, opts): toplevels = [] followlinks = getattr(opts, 'followlinks', False) + includeprivate = getattr(opts, 'includeprivate', False) for root, subs, files in os.walk(rootpath, followlinks=followlinks): # document only Python module files (that aren't excluded) py_files = sorted(f for f in files @@ -197,7 +198,11 @@ def recurse_tree(rootpath, excludes, opts): continue # remove hidden ('.') and private ('_') directories, as well as # 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)) if is_pkg: