[Python-checkins] r62631 - in doctools/trunk: CHANGES doc/config.rst sphinx/config.py sphinx/environment.py sphinx/quickstart.py sphinx/util/__init__.py
georg.brandl
python-checkins at python.org
Fri May 2 11:16:00 CEST 2008
Author: georg.brandl
Date: Fri May 2 11:15:59 2008
New Revision: 62631
Log:
Add exclude_dirs config value.
Modified:
doctools/trunk/CHANGES
doctools/trunk/doc/config.rst
doctools/trunk/sphinx/config.py
doctools/trunk/sphinx/environment.py
doctools/trunk/sphinx/quickstart.py
doctools/trunk/sphinx/util/__init__.py
Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES (original)
+++ doctools/trunk/CHANGES Fri May 2 11:15:59 2008
@@ -7,6 +7,9 @@
* If the `pygments_style` config value contains a dot it's treated as the
import path of a custom Pygments style class.
+* A new config value, `exclude_dirs`, can be used to exclude whole
+ directories 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 Fri May 2 11:15:59 2008
@@ -57,11 +57,6 @@
The configuration file itself can be an extension; for that, you only need to
provide a :func:`setup` function in it.
-.. confval:: templates_path
-
- A list of paths that contain extra templates (or templates that overwrite
- builtin templates).
-
.. confval:: source_suffix
The file name extension of source files. Only files with this suffix will be
@@ -113,22 +108,12 @@
toctree. Use this setting to suppress the warning that is normally emitted
in that case.
-.. confval:: add_function_parentheses
+.. confval:: exclude_dirs
- A boolean that decides whether parentheses are appended to function and
- method role text (e.g. the content of ``:func:`input```) to signify that the
- name is callable. Default is ``True``.
+ A list of directory names, relative to the source directory, that are to be
+ excluded from the search for source files.
-.. confval:: add_module_names
-
- A boolean that decides whether module names are prepended to all
- :term:`description unit` titles, e.g. for :dir:`function` directives.
- Default is ``True``.
-
-.. confval:: show_authors
-
- A boolean that decides whether :dir:`moduleauthor` and :dir:`sectionauthor`
- directives produce any output in the built files.
+ .. versionadded:: 0.2.1
.. confval:: pygments_style
@@ -140,6 +125,11 @@
If the value is a fully-qualified name of a custom Pygments style class,
this is then used as custom style.
+.. confval:: templates_path
+
+ A list of paths that contain extra templates (or templates that overwrite
+ builtin templates).
+
.. confval:: template_bridge
A string with the fully-qualified name of a callable (or simply a class) that
@@ -147,6 +137,23 @@
instance is then used to render HTML documents, and possibly the output of
other builders (currently the changes builder).
+.. confval:: add_function_parentheses
+
+ A boolean that decides whether parentheses are appended to function and
+ method role text (e.g. the content of ``:func:`input```) to signify that the
+ name is callable. Default is ``True``.
+
+.. confval:: add_module_names
+
+ A boolean that decides whether module names are prepended to all
+ :term:`description unit` titles, e.g. for :dir:`function` directives.
+ Default is ``True``.
+
+.. confval:: show_authors
+
+ A boolean that decides whether :dir:`moduleauthor` and :dir:`sectionauthor`
+ directives produce any output in the built files.
+
.. _html-options:
Modified: doctools/trunk/sphinx/config.py
==============================================================================
--- doctools/trunk/sphinx/config.py (original)
+++ doctools/trunk/sphinx/config.py Fri May 2 11:15:59 2008
@@ -38,6 +38,7 @@
master_doc = ('contents', True),
source_suffix = ('.rst', True),
unused_docs = ([], True),
+ exclude_dirs = ([], 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 Fri May 2 11:15:59 2008
@@ -325,9 +325,10 @@
"""
Find all source files in the source dir and put them in self.found_docs.
"""
- self.found_docs = set(get_matching_docs(self.srcdir, config.source_suffix,
- exclude=set(config.unused_docs),
- prune=['_sources']))
+ exclude_dirs = [d.replace(SEP, path.sep) for d in config.exclude_dirs]
+ 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']))
def get_outdated_files(self, config_changed):
"""
Modified: doctools/trunk/sphinx/quickstart.py
==============================================================================
--- doctools/trunk/sphinx/quickstart.py (original)
+++ doctools/trunk/sphinx/quickstart.py Fri May 2 11:15:59 2008
@@ -73,6 +73,10 @@
# List of documents that shouldn't be included in the build.
#unused_docs = []
+# List of directories, relative to source directories, that shouldn't be searched
+# for source files.
+#exclude_dirs = []
+
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
Modified: doctools/trunk/sphinx/util/__init__.py
==============================================================================
--- doctools/trunk/sphinx/util/__init__.py (original)
+++ doctools/trunk/sphinx/util/__init__.py Fri May 2 11:15:59 2008
@@ -74,7 +74,7 @@
yield top, dirs, nondirs
-def get_matching_docs(dirname, suffix, exclude=(), prune=()):
+def get_matching_docs(dirname, suffix, exclude_docs=(), exclude_dirs=(), prune_dirs=()):
"""
Get all file names (without suffix) matching a suffix in a
directory, recursively.
@@ -86,9 +86,11 @@
dirname = path.normpath(path.abspath(dirname))
dirlen = len(dirname) + 1 # exclude slash
for root, dirs, files in walk(dirname, followlinks=True):
+ if root[dirlen:] in exclude_dirs:
+ continue
dirs.sort()
files.sort()
- for prunedir in prune:
+ for prunedir in prune_dirs:
if prunedir in dirs:
dirs.remove(prunedir)
for sfile in files:
@@ -96,7 +98,7 @@
continue
qualified_name = path.join(root[dirlen:], sfile[:-len(suffix)])
qualified_name = qualified_name.replace(os.path.sep, SEP)
- if qualified_name in exclude:
+ if qualified_name in exclude_docs:
continue
yield qualified_name
More information about the Python-checkins
mailing list