Fix fail to load template file if the parent template is archived

This commit is contained in:
Takeshi KOMIYA 2017-04-18 23:22:03 +09:00
parent 13acfd3ce1
commit f1b387bdcf
7 changed files with 16 additions and 4 deletions

View File

@ -117,6 +117,7 @@ Bugs fixed
* C++, properly look up ``any`` references.
* #3624: sphinx.ext.intersphinx couldn't load inventories compressed with gzip
* #3551: PDF information dictionary is lacking author and title data
* Fail to load template file if the parent template is archived
Deprecated
----------

View File

@ -135,8 +135,8 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
if theme:
# the theme's own dir and its bases' dirs
pathchain = theme.get_dirchain()
# then the theme parent paths
loaderchain = pathchain + theme.themepath
# the loader dirs: pathchain + the parent directories for all themes
loaderchain = pathchain + [path.join(p, '..') for p in pathchain]
elif dirs:
pathchain = list(dirs)
loaderchain = list(dirs)

View File

@ -22,6 +22,7 @@ from six.moves import configparser
from sphinx import package_dir
from sphinx.errors import ThemeError
from sphinx.util import logging
from sphinx.util.osutil import ensuredir
logger = logging.getLogger(__name__)
@ -127,12 +128,15 @@ class Theme(object):
tdir, tinfo = self.themes[name]
if tinfo is None:
# already a directory, do nothing
self.rootdir = None
self.themedir = tdir
self.themedir_created = False
else:
# 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
ensuredir(self.themedir)
for name in tinfo.namelist():
if name.endswith('/'):
continue
@ -214,7 +218,7 @@ class Theme(object):
"""Remove temporary directories."""
if self.themedir_created:
try:
shutil.rmtree(self.themedir)
shutil.rmtree(self.rootdir)
except Exception:
pass
if self.base:

Binary file not shown.

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
html_theme = 'test-theme'
html_theme_path = ['.', 'test_theme']
master_doc = 'index'
exclude_patterns = ['_build']

Binary file not shown.

View File

@ -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):
args, kwargs = app_params
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