1. Georg Brandl
  2. sphinx

Commits

georg.brandl  committed a37bd71

Add exclude_dirs config value.

  • Participants
  • Parent commits ece3261
  • Branches default

Comments (0)

Files changed (6)

File CHANGES

View file
  • Ignore whitespace
 * 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
 ----------
 

File doc/config.rst

View file
  • Ignore whitespace
    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
    toctree.  Use this setting to suppress the warning that is normally emitted
    in that case.
 
+.. confval:: exclude_dirs
+
+   A list of directory names, relative to the source directory, that are to be
+   excluded from the search for source files.
+
+   .. versionadded:: 0.2.1
+
+.. confval:: pygments_style
+
+   The style name to use for Pygments highlighting of source code.  Default is
+   ``'sphinx'``, which is a builtin style designed to match Sphinx' default
+   style.
+
+   .. versionchanged:: 0.2.1
+      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
+   returns an instance of :class:`~sphinx.application.TemplateBridge`.  This
+   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
    A boolean that decides whether :dir:`moduleauthor` and :dir:`sectionauthor`
    directives produce any output in the built files.
 
-.. confval:: pygments_style
-
-   The style name to use for Pygments highlighting of source code.  Default is
-   ``'sphinx'``, which is a builtin style designed to match Sphinx' default
-   style.
-
-   .. versionchanged:: 0.2.1
-      If the value is a fully-qualified name of a custom Pygments style class,
-      this is then used as custom style.
-
-.. confval:: template_bridge
-
-   A string with the fully-qualified name of a callable (or simply a class) that
-   returns an instance of :class:`~sphinx.application.TemplateBridge`.  This
-   instance is then used to render HTML documents, and possibly the output of
-   other builders (currently the changes builder).
-
 
 .. _html-options:
 

File sphinx/config.py

View file
  • Ignore whitespace
         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),

File sphinx/environment.py

View file
  • Ignore whitespace
         """
         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):
         """

File sphinx/quickstart.py

View file
  • Ignore whitespace
 # 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
 

File sphinx/util/__init__.py

View file
  • Ignore whitespace
         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.
     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:
                 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