mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #8967 from tk0miya/8959_unix_pathsep_on_windows
Fix #8959: using UNIX path separator confuses Sphinx on Windows
This commit is contained in:
commit
11144ea009
2
CHANGES
2
CHANGES
@ -13,6 +13,8 @@ Deprecated
|
|||||||
Features added
|
Features added
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
* #8959: using UNIX path separator in image directive confuses Sphinx on Windows
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import posixpath
|
|
||||||
import warnings
|
import warnings
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from copy import copy
|
from copy import copy
|
||||||
@ -34,6 +33,7 @@ from sphinx.util import DownloadFiles, FilenameUniqDict, logging
|
|||||||
from sphinx.util.docutils import LoggingReporter
|
from sphinx.util.docutils import LoggingReporter
|
||||||
from sphinx.util.i18n import CatalogRepository, docname_to_domain
|
from sphinx.util.i18n import CatalogRepository, docname_to_domain
|
||||||
from sphinx.util.nodes import is_translatable
|
from sphinx.util.nodes import is_translatable
|
||||||
|
from sphinx.util.osutil import canon_path, os_path
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@ -351,6 +351,7 @@ class BuildEnvironment:
|
|||||||
source dir, while relative filenames are relative to the dir of the
|
source dir, while relative filenames are relative to the dir of the
|
||||||
containing document.
|
containing document.
|
||||||
"""
|
"""
|
||||||
|
filename = os_path(filename)
|
||||||
if filename.startswith('/') or filename.startswith(os.sep):
|
if filename.startswith('/') or filename.startswith(os.sep):
|
||||||
rel_fn = filename[1:]
|
rel_fn = filename[1:]
|
||||||
else:
|
else:
|
||||||
@ -358,7 +359,7 @@ class BuildEnvironment:
|
|||||||
base=None))
|
base=None))
|
||||||
rel_fn = path.join(docdir, filename)
|
rel_fn = path.join(docdir, filename)
|
||||||
|
|
||||||
return (posixpath.normpath(rel_fn),
|
return (canon_path(path.normpath(rel_fn)),
|
||||||
path.normpath(path.join(self.srcdir, rel_fn)))
|
path.normpath(path.join(self.srcdir, rel_fn)))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -16,7 +16,6 @@ import pytest
|
|||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
|
||||||
from sphinx.errors import SphinxError
|
from sphinx.errors import SphinxError
|
||||||
from sphinx.testing.path import path
|
|
||||||
|
|
||||||
|
|
||||||
def request_session_head(url, **kwargs):
|
def request_session_head(url, **kwargs):
|
||||||
@ -137,17 +136,16 @@ def test_image_glob(app, status, warning):
|
|||||||
doctree = app.env.get_doctree('subdir/index')
|
doctree = app.env.get_doctree('subdir/index')
|
||||||
|
|
||||||
assert isinstance(doctree[0][1], nodes.image)
|
assert isinstance(doctree[0][1], nodes.image)
|
||||||
sub = path('subdir')
|
assert doctree[0][1]['candidates'] == {'*': 'subdir/rimg.png'}
|
||||||
assert doctree[0][1]['candidates'] == {'*': sub / 'rimg.png'}
|
assert doctree[0][1]['uri'] == 'subdir/rimg.png'
|
||||||
assert doctree[0][1]['uri'] == sub / 'rimg.png'
|
|
||||||
|
|
||||||
assert isinstance(doctree[0][2], nodes.image)
|
assert isinstance(doctree[0][2], nodes.image)
|
||||||
assert doctree[0][2]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf',
|
assert doctree[0][2]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf',
|
||||||
'image/svg+xml': 'subdir/svgimg.svg'}
|
'image/svg+xml': 'subdir/svgimg.svg'}
|
||||||
assert doctree[0][2]['uri'] == sub / 'svgimg.*'
|
assert doctree[0][2]['uri'] == 'subdir/svgimg.*'
|
||||||
|
|
||||||
assert isinstance(doctree[0][3], nodes.figure)
|
assert isinstance(doctree[0][3], nodes.figure)
|
||||||
assert isinstance(doctree[0][3][0], nodes.image)
|
assert isinstance(doctree[0][3][0], nodes.image)
|
||||||
assert doctree[0][3][0]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf',
|
assert doctree[0][3][0]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf',
|
||||||
'image/svg+xml': 'subdir/svgimg.svg'}
|
'image/svg+xml': 'subdir/svgimg.svg'}
|
||||||
assert doctree[0][3][0]['uri'] == sub / 'svgimg.*'
|
assert doctree[0][3][0]['uri'] == 'subdir/svgimg.*'
|
||||||
|
Loading…
Reference in New Issue
Block a user