summaryrefslogtreecommitdiff
path: root/pbr/builddoc.py
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2015-05-05 14:21:56 +0200
committerJulien Danjou <julien@danjou.info>2015-05-21 15:00:47 -0700
commite943f760851d193cc4d808deeef59d1a5f789c03 (patch)
tree9605bb4dfefce608319348302eda4926a80cbc7f /pbr/builddoc.py
parent3cec7c8782d8ccecdf8c3e08b21d9d9342b096da (diff)
downloadpbr-e943f760851d193cc4d808deeef59d1a5f789c03.tar.gz
builddoc: allow to use fnmatch-style exclusion for autodoc
This allows to use patterns such as heat.tests.* to exlude modules from autodoc genereation. Change-Id: Ibfc4161670fd9344da88c4a85a3aea992fcdf519
Diffstat (limited to 'pbr/builddoc.py')
-rw-r--r--pbr/builddoc.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/pbr/builddoc.py b/pbr/builddoc.py
index 7c9916b..3c9a9a1 100644
--- a/pbr/builddoc.py
+++ b/pbr/builddoc.py
@@ -15,6 +15,7 @@
# under the License.
from distutils import log
+import fnmatch
import os
import sys
@@ -85,10 +86,12 @@ class LocalBuildDoc(setup_command.BuildDoc):
if '.' not in pkg:
for dirpath, dirnames, files in os.walk(pkg):
_find_modules(modules, dirpath, files)
- module_list = set(modules.keys())
- if excluded_modules is not None:
- module_list -= set(excluded_modules)
- module_list = sorted(module_list)
+
+ def include(module):
+ return not any(fnmatch.fnmatch(module, pat)
+ for pat in excluded_modules)
+
+ module_list = sorted(mod for mod in modules.keys() if include(mod))
autoindex_filename = os.path.join(source_dir, 'autoindex.rst')
with open(autoindex_filename, 'w') as autoindex:
autoindex.write(""".. toctree::
@@ -171,9 +174,9 @@ class LocalBuildDoc(setup_command.BuildDoc):
self._sphinx_tree()
if auto_index:
self.generate_autoindex(
- option_dict.get(
+ set(option_dict.get(
"autodoc_exclude_modules",
- [None, ""])[1].split())
+ [None, ""])[1].split()))
for builder in self.builders:
self.builder = builder