Merge pull request #2899 from shibukawa/fix/hasdoc

Fix hasdoc() function in Jinja2 template.
This commit is contained in:
Takeshi KOMIYA 2016-08-27 23:15:45 +09:00 committed by GitHub
commit 8606de3963
2 changed files with 12 additions and 1 deletions

View File

@ -10,6 +10,7 @@ Bugs fixed
* #2902: jsdump.loads fails to load search index if keywords starts with * #2902: jsdump.loads fails to load search index if keywords starts with
underscore underscore
* #2900: Fix epub content.opf: add auto generated orphan files to spine. * #2900: Fix epub content.opf: add auto generated orphan files to spine.
* #2899: Fix ``hasdoc()`` function in Jinja2 template. It can detect ``genindex``, ``search`` collectly.
Release 1.4.6 (released Aug 20, 2016) Release 1.4.6 (released Aug 20, 2016)
===================================== =====================================

View File

@ -785,7 +785,17 @@ class StandaloneHTMLBuilder(Builder):
uri = relative_uri(baseuri, otheruri) or '#' uri = relative_uri(baseuri, otheruri) or '#'
return uri return uri
ctx['pathto'] = pathto ctx['pathto'] = pathto
ctx['hasdoc'] = lambda name: name in self.env.all_docs
def hasdoc(name):
if name in self.env.all_docs:
return True
elif name == 'search' and self.search:
return True
elif name == 'genindex' and self.get_builder_config('use_index', 'html'):
return True
return False
ctx['hasdoc'] = hasdoc
if self.name != 'htmlhelp': if self.name != 'htmlhelp':
ctx['encoding'] = encoding = self.config.html_output_encoding ctx['encoding'] = encoding = self.config.html_output_encoding
else: else: