refactor: latex: Initialize 'logofilename' on context

This commit is contained in:
Takeshi KOMIYA 2018-12-16 01:13:48 +09:00
parent db02ae1b81
commit a2ec232c71
4 changed files with 9 additions and 7 deletions

View File

@ -90,6 +90,7 @@ Deprecated
* ``sphinx.writers.text.TextTranslator._make_depart_admonition()``
* template variables for LaTeX template
- ``logo``
- ``pageautorefname``
- ``translatablestrings``

View File

@ -198,6 +198,9 @@ class LaTeXBuilder(Builder):
self.context['date'] = format_date(self.config.today_fmt or _('%b %d, %Y'),
language=self.config.language)
if self.config.latex_logo:
self.context['logofilename'] = path.basename(self.config.latex_logo)
# for compatibilities
self.context['indexname'] = _('Index')
if self.config.release:

View File

@ -48,7 +48,11 @@
\date{<%= date %>}
\release{<%= release %>}
\author{<%= author %>}
\newcommand{\sphinxlogo}{<%= logo %>}
<%- if logofilename %>
\newcommand{\sphinxlogo}{\sphinxincludegraphics{<%= logofilename %>}\par}
<%- else %>
\newcommand{\sphinxlogo}{\vbox{}}
<%- endif %>
<%- if releasename or release %>
\renewcommand{\releasename}{<%= releasename or _('Release') | e %>}
<%- else %>

View File

@ -157,7 +157,6 @@ DEFAULT_SETTINGS = {
'title': '',
'release': '',
'author': '',
'logo': '\\vbox{}',
'releasename': '',
'makeindex': '\\makeindex',
'shorthandoff': '',
@ -578,11 +577,6 @@ class LaTeXTranslator(SphinxTranslator):
except AttributeError:
pass
if self.config.latex_logo:
# no need for \\noindent here, used in flushright
self.elements['logo'] = '\\sphinxincludegraphics{%s}\\par' % \
path.basename(self.config.latex_logo)
if (self.config.language not in {None, 'en', 'ja'} and
'fncychap' not in self.config.latex_elements):
# use Sonny style if any language specified (except English)