From 5dcf03fb2ddcbf67579b1576ab20d6ee665d9d26 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 19 Jan 2014 18:10:19 +0100 Subject: [PATCH] Closes #1330: Fix :confval:`exclude_patterns` behavior with subdirectories in the :confval:`html_static_path`. --- CHANGES | 3 +++ sphinx/util/__init__.py | 23 +++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 0ff050036..78d6b446a 100644 --- a/CHANGES +++ b/CHANGES @@ -116,6 +116,9 @@ Bugs fixed * #1283: Fix a bug in the detection of changed files that would try to access doctrees of deleted documents. +* #1330: Fix :confval:`exclude_patterns` behavior with subdirectories in the + :confval:`html_static_path`. + Documentation ------------- diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 5cbbb61b6..a20fc19be 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -158,18 +158,17 @@ def copy_static_entry(source, targetdir, builder, context={}, else: copyfile(source, target) elif path.isdir(source): - if level == 0: - for entry in os.listdir(source): - if entry.startswith('.'): - continue - copy_static_entry(path.join(source, entry), targetdir, - builder, context, level=1, - exclude_matchers=exclude_matchers) - else: - target = path.join(targetdir, path.basename(source)) - if path.exists(target): - shutil.rmtree(target) - shutil.copytree(source, target) + if not path.isdir(targetdir): + os.mkdir(targetdir) + for entry in os.listdir(source): + if entry.startswith('.'): + continue + newtarget = targetdir + if path.isdir(path.join(source, entry)): + newtarget = path.join(targetdir, entry) + copy_static_entry(path.join(source, entry), newtarget, + builder, context, level=level+1, + exclude_matchers=exclude_matchers) _DEBUG_HEADER = '''\