[Python-checkins] r63582 - in doctools/trunk: CHANGES doc/config.rst sphinx/config.py sphinx/environment.py sphinx/util/__init__.py
georg.brandl
python-checkins at python.org
Sat May 24 18:28:07 CEST 2008
Author: georg.brandl
Date: Sat May 24 18:28:06 2008
New Revision: 63582
Log:
Add exclude_trees config value.
Modified:
doctools/trunk/CHANGES
doctools/trunk/doc/config.rst
doctools/trunk/sphinx/config.py
doctools/trunk/sphinx/environment.py
doctools/trunk/sphinx/util/__init__.py
Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES (original)
+++ doctools/trunk/CHANGES Sat May 24 18:28:06 2008
@@ -14,6 +14,9 @@
* The new config value `html_use_index` can be used to switch index
generation in HTML documents off.
+* The new `exclude_trees` config option can be used to exclude whole
+ subtrees from the search for source files.
+
Bugs fixed
----------
Modified: doctools/trunk/doc/config.rst
==============================================================================
--- doctools/trunk/doc/config.rst (original)
+++ doctools/trunk/doc/config.rst Sat May 24 18:28:06 2008
@@ -117,6 +117,14 @@
.. versionadded:: 0.3
+.. confval:: exclude_trees
+
+ A list of directory names, relative to the source directory, that are to be
+ recursively exlucded from the search for source files, that is, their
+ subdirectories won't be searched too.
+
+ .. versionadded:: 0.4
+
.. confval:: pygments_style
The style name to use for Pygments highlighting of source code. Default is
@@ -252,7 +260,7 @@
If true, add an index to the HTML documents. Default is ``True``.
- .. versionadded:: 0.5
+ .. versionadded:: 0.4
.. confval:: html_copy_source
Modified: doctools/trunk/sphinx/config.py
==============================================================================
--- doctools/trunk/sphinx/config.py (original)
+++ doctools/trunk/sphinx/config.py Sat May 24 18:28:06 2008
@@ -39,6 +39,7 @@
source_suffix = ('.rst', True),
unused_docs = ([], True),
exclude_dirs = ([], True),
+ exclude_trees = ([], True),
add_function_parentheses = (True, True),
add_module_names = (True, True),
show_authors = (False, True),
Modified: doctools/trunk/sphinx/environment.py
==============================================================================
--- doctools/trunk/sphinx/environment.py (original)
+++ doctools/trunk/sphinx/environment.py Sat May 24 18:28:06 2008
@@ -325,10 +325,12 @@
"""
Find all source files in the source dir and put them in self.found_docs.
"""
- exclude_dirs = [d.replace(SEP, path.sep) for d in config.exclude_dirs]
+ exclude_dirs = [d.replace(SEP, path.sep) for d in config.exclude_dirs]
+ exclude_trees = [d.replace(SEP, path.sep) for d in config.exclude_trees]
self.found_docs = set(get_matching_docs(
self.srcdir, config.source_suffix, exclude_docs=set(config.unused_docs),
- exclude_dirs=exclude_dirs, prune_dirs=['_sources']))
+ exclude_dirs=exclude_dirs, exclude_trees=exclude_trees,
+ exclude_dirnames=['_sources']))
def get_outdated_files(self, config_changed):
"""
Modified: doctools/trunk/sphinx/util/__init__.py
==============================================================================
--- doctools/trunk/sphinx/util/__init__.py (original)
+++ doctools/trunk/sphinx/util/__init__.py Sat May 24 18:28:06 2008
@@ -75,12 +75,14 @@
yield top, dirs, nondirs
-def get_matching_docs(dirname, suffix, exclude_docs=(), exclude_dirs=(), prune_dirs=()):
+def get_matching_docs(dirname, suffix, exclude_docs=(), exclude_dirs=(),
+ exclude_trees=(), exclude_dirnames=()):
"""
Get all file names (without suffix) matching a suffix in a
directory, recursively.
- Exclude files in *exclude*, prune directories in *prune*.
+ Exclude docs in *exclude_docs*, exclude dirs in *exclude_dirs*,
+ prune dirs in *exclude_trees*, prune dirnames in *exclude_dirnames*.
"""
pattern = '*' + suffix
# dirname is a normalized absolute path.
@@ -89,9 +91,12 @@
for root, dirs, files in walk(dirname, followlinks=True):
if root[dirlen:] in exclude_dirs:
continue
+ if root[dirlen:] in exclude_trees:
+ del dirs[:]
+ continue
dirs.sort()
files.sort()
- for prunedir in prune_dirs:
+ for prunedir in exclude_dirnames:
if prunedir in dirs:
dirs.remove(prunedir)
for sfile in files:
More information about the Python-checkins
mailing list