mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add exclude_dirs config value.
This commit is contained in:
parent
9050ba428e
commit
7ad49d5756
3
CHANGES
3
CHANGES
@ -7,6 +7,9 @@ New features added
|
||||
* 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
|
||||
----------
|
||||
|
||||
|
@ -57,11 +57,6 @@ General configuration
|
||||
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,6 +108,35 @@ General configuration
|
||||
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
|
||||
@ -130,23 +154,6 @@ General configuration
|
||||
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:
|
||||
|
||||
|
@ -38,6 +38,7 @@ class Config(object):
|
||||
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),
|
||||
|
@ -325,9 +325,10 @@ class BuildEnvironment:
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
|
@ -73,6 +73,10 @@ today_fmt = '%%B %%d, %%Y'
|
||||
# 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
|
||||
|
||||
|
@ -74,7 +74,7 @@ def walk(top, topdown=True, followlinks=False):
|
||||
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 @@ def get_matching_docs(dirname, suffix, exclude=(), prune=()):
|
||||
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 @@ def get_matching_docs(dirname, suffix, exclude=(), prune=()):
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user