mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix fail to load template file if the parent template is archived
This commit is contained in:
parent
13acfd3ce1
commit
f1b387bdcf
1
CHANGES
1
CHANGES
@ -117,6 +117,7 @@ Bugs fixed
|
|||||||
* C++, properly look up ``any`` references.
|
* C++, properly look up ``any`` references.
|
||||||
* #3624: sphinx.ext.intersphinx couldn't load inventories compressed with gzip
|
* #3624: sphinx.ext.intersphinx couldn't load inventories compressed with gzip
|
||||||
* #3551: PDF information dictionary is lacking author and title data
|
* #3551: PDF information dictionary is lacking author and title data
|
||||||
|
* Fail to load template file if the parent template is archived
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
@ -135,8 +135,8 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
|||||||
if theme:
|
if theme:
|
||||||
# the theme's own dir and its bases' dirs
|
# the theme's own dir and its bases' dirs
|
||||||
pathchain = theme.get_dirchain()
|
pathchain = theme.get_dirchain()
|
||||||
# then the theme parent paths
|
# the loader dirs: pathchain + the parent directories for all themes
|
||||||
loaderchain = pathchain + theme.themepath
|
loaderchain = pathchain + [path.join(p, '..') for p in pathchain]
|
||||||
elif dirs:
|
elif dirs:
|
||||||
pathchain = list(dirs)
|
pathchain = list(dirs)
|
||||||
loaderchain = list(dirs)
|
loaderchain = list(dirs)
|
||||||
|
@ -22,6 +22,7 @@ from six.moves import configparser
|
|||||||
from sphinx import package_dir
|
from sphinx import package_dir
|
||||||
from sphinx.errors import ThemeError
|
from sphinx.errors import ThemeError
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
|
from sphinx.util.osutil import ensuredir
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -127,12 +128,15 @@ class Theme(object):
|
|||||||
tdir, tinfo = self.themes[name]
|
tdir, tinfo = self.themes[name]
|
||||||
if tinfo is None:
|
if tinfo is None:
|
||||||
# already a directory, do nothing
|
# already a directory, do nothing
|
||||||
|
self.rootdir = None
|
||||||
self.themedir = tdir
|
self.themedir = tdir
|
||||||
self.themedir_created = False
|
self.themedir_created = False
|
||||||
else:
|
else:
|
||||||
# extract the theme to a temp directory
|
# extract the theme to a temp directory
|
||||||
self.themedir = tempfile.mkdtemp('sxt')
|
self.rootdir = tempfile.mkdtemp('sxt')
|
||||||
|
self.themedir = path.join(self.rootdir, name)
|
||||||
self.themedir_created = True
|
self.themedir_created = True
|
||||||
|
ensuredir(self.themedir)
|
||||||
for name in tinfo.namelist():
|
for name in tinfo.namelist():
|
||||||
if name.endswith('/'):
|
if name.endswith('/'):
|
||||||
continue
|
continue
|
||||||
@ -214,7 +218,7 @@ class Theme(object):
|
|||||||
"""Remove temporary directories."""
|
"""Remove temporary directories."""
|
||||||
if self.themedir_created:
|
if self.themedir_created:
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(self.themedir)
|
shutil.rmtree(self.rootdir)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if self.base:
|
if self.base:
|
||||||
|
BIN
tests/roots/test-theming/child.zip
Normal file
BIN
tests/roots/test-theming/child.zip
Normal file
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
html_theme = 'test-theme'
|
html_theme = 'test-theme'
|
||||||
|
html_theme_path = ['.', 'test_theme']
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
exclude_patterns = ['_build']
|
exclude_patterns = ['_build']
|
||||||
|
|
||||||
|
BIN
tests/roots/test-theming/parent.zip
Normal file
BIN
tests/roots/test-theming/parent.zip
Normal file
Binary file not shown.
@ -100,3 +100,9 @@ def test_double_inheriting_theme(make_app, app_params):
|
|||||||
with mock.patch('sphinx.theming.load_theme_plugins', side_effect=load_themes):
|
with mock.patch('sphinx.theming.load_theme_plugins', side_effect=load_themes):
|
||||||
args, kwargs = app_params
|
args, kwargs = app_params
|
||||||
make_app(*args, **kwargs)
|
make_app(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx(testroot='theming',
|
||||||
|
confoverrides={'html_theme': 'child'})
|
||||||
|
def test_nested_zipped_theme(app, status, warning):
|
||||||
|
app.build() # => not raises TemplateNotFound
|
||||||
|
Loading…
Reference in New Issue
Block a user