From 4ab5d6eb5296782ff609d4731deaf1bff1870c65 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 23 Jan 2014 10:24:58 +0100 Subject: [PATCH] Closes #1358: Fix handling of image paths outside of the source directory when using the "wildcard" style reference. --- CHANGES | 2 ++ sphinx/environment.py | 3 ++- sphinx/transforms.py | 3 ++- sphinx/util/__init__.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index b970416af..d043ce4f6 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,8 @@ Bugs fixed * PR#213: Fix a missing import in the setup command. * #1357: Option names documented by :rst:dir:`option` are now again allowed to not start with a dash or slash, and referencing them will work correctly. +* #1358: Fix handling of image paths outside of the source directory when using + the "wildcard" style reference. Documentation ------------- diff --git a/sphinx/environment.py b/sphinx/environment.py index c84f5752c..e3e1cd0aa 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -799,7 +799,8 @@ class BuildEnvironment: node['uri'] = rel_imgpath if rel_imgpath.endswith(os.extsep + '*'): for filename in glob(full_imgpath): - new_imgpath = relative_path(self.srcdir, filename) + new_imgpath = relative_path(path.join(self.srcdir, 'dummy'), + filename) if filename.lower().endswith('.pdf'): candidates['application/pdf'] = new_imgpath elif filename.lower().endswith('.svg'): diff --git a/sphinx/transforms.py b/sphinx/transforms.py index 53bbadb0e..64310d7f6 100644 --- a/sphinx/transforms.py +++ b/sphinx/transforms.py @@ -163,7 +163,8 @@ class Locale(Transform): settings, source = self.document.settings, self.document['source'] # XXX check if this is reliable assert source.startswith(env.srcdir) - docname = path.splitext(relative_path(env.srcdir, source))[0] + docname = path.splitext(relative_path(path.join(env.srcdir, 'dummy'), + source))[0] textdomain = find_catalog(docname, self.document.settings.gettext_compact) diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index a20fc19be..0fd4d49bb 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -142,7 +142,7 @@ def copy_static_entry(source, targetdir, builder, context={}, Handles all possible cases of files, directories and subdirectories. """ if exclude_matchers: - relpath = relative_path(builder.srcdir, source) + relpath = relative_path(path.join(builder.srcdir, 'dummy'), source) for matcher in exclude_matchers: if matcher(relpath): return