Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-26 07:49:50 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-26 07:53:09 +0300
commit09ca58d0dd2eee4e871da593791fe1d3af628e03 (patch)
tree6e0861e325a9d22306341e32a7640ed75b7ad459 /sphinx/environment
parentff4330abe370895e64d6ea42a58ae8538ec8c087 (diff)
Fix #7768: i18n: Wrong root element is passed to figure_language_filename
The root element should be a user specified path; a relative path from current document or absolute path based on source directory. But an absolute path is passed instead.
Diffstat (limited to 'sphinx/environment')
-rw-r--r--sphinx/environment/collectors/asset.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/sphinx/environment/collectors/asset.py b/sphinx/environment/collectors/asset.py
index 06a0d5198..3da2a6e4b 100644
--- a/sphinx/environment/collectors/asset.py
+++ b/sphinx/environment/collectors/asset.py
@@ -58,17 +58,13 @@ class ImageCollector(EnvironmentCollector):
elif imguri.find('://') != -1:
candidates['?'] = imguri
continue
- rel_imgpath, full_imgpath = app.env.relfn2path(imguri, docname)
- if app.config.language:
- # substitute figures (ex. foo.png -> foo.en.png)
- i18n_full_imgpath = search_image_for_language(full_imgpath, app.env)
- if i18n_full_imgpath != full_imgpath:
- full_imgpath = i18n_full_imgpath
- rel_imgpath = relative_path(path.join(app.srcdir, 'dummy'),
- i18n_full_imgpath)
- # set imgpath as default URI
- node['uri'] = rel_imgpath
- if rel_imgpath.endswith(os.extsep + '*'):
+
+ if imguri.endswith(os.extsep + '*'):
+ # Update `node['uri']` to a relative path from srcdir
+ # from a relative path from current document.
+ rel_imgpath, full_imgpath = app.env.relfn2path(imguri, docname)
+ node['uri'] = rel_imgpath
+
if app.config.language:
# Search language-specific figures at first
i18n_imguri = get_image_filename_for_language(imguri, app.env)
@@ -77,7 +73,15 @@ class ImageCollector(EnvironmentCollector):
self.collect_candidates(app.env, full_imgpath, candidates, node)
else:
- candidates['*'] = rel_imgpath
+ if app.config.language:
+ # substitute imguri by figure_language_filename
+ # (ex. foo.png -> foo.en.png)
+ imguri = search_image_for_language(imguri, app.env)
+
+ # Update `node['uri']` to a relative path from srcdir
+ # from a relative path from current document.
+ node['uri'], _ = app.env.relfn2path(imguri, docname)
+ candidates['*'] = node['uri']
# map image paths to unique image names (so that they can be put
# into a single directory)