summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2016-07-03 18:14:19 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2016-07-19 11:03:10 +0900
commit0bafd9ee21eee9f2f800a79062dd6590a2a51575 (patch)
treed968e13a75004d00cee29778faa2cad8ab71972e
parent2c5a9f39754b904402d7d8e2a2f619c0010d74cc (diff)
downloadsphinx-git-0bafd9ee21eee9f2f800a79062dd6590a2a51575.tar.gz
Support multiple LaTeX engines through `latex_engine`
-rw-r--r--CHANGES1
-rw-r--r--sphinx/builders/latex.py25
-rw-r--r--sphinx/make_mode.py14
-rw-r--r--sphinx/quickstart.py16
-rw-r--r--sphinx/texinputs/Makefile_t (renamed from sphinx/texinputs/Makefile)2
5 files changed, 14 insertions, 44 deletions
diff --git a/CHANGES b/CHANGES
index 64ba439db..995370a77 100644
--- a/CHANGES
+++ b/CHANGES
@@ -35,7 +35,6 @@ Features added
--------------
* Add ``:caption:`` option for sphinx.ext.inheritance_diagram.
-* #894: Add ``lualatexpdf`` and ``xelatexpdf`` as a make target to build PDF using lualatex or xelatex
* #2471: Add config variable for default doctest flags.
* Convert linkcheck builder to requests for better encoding handling
* #2463, #2516: Add keywords of "meta" directive to search index
diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py
index 5c41a8799..6b9c5b138 100644
--- a/sphinx/builders/latex.py
+++ b/sphinx/builders/latex.py
@@ -20,13 +20,14 @@ from docutils.frontend import OptionParser
from sphinx import package_dir, addnodes, highlighting
from sphinx.util import texescape
-from sphinx.config import string_classes
+from sphinx.config import string_classes, ENUM
from sphinx.errors import SphinxError
from sphinx.locale import _
from sphinx.builders import Builder
from sphinx.environment import NoUri
from sphinx.util.nodes import inline_all_toctrees
-from sphinx.util.osutil import SEP, copyfile, make_filename
+from sphinx.util.fileutil import copy_asset_file
+from sphinx.util.osutil import SEP, make_filename
from sphinx.util.console import bold, darkgreen
from sphinx.writers.latex import LaTeXWriter
@@ -188,35 +189,33 @@ class LaTeXBuilder(Builder):
self.info(bold('copying images...'), nonl=1)
for src, dest in iteritems(self.images):
self.info(' '+src, nonl=1)
- copyfile(path.join(self.srcdir, src),
- path.join(self.outdir, dest))
+ copy_asset_file(path.join(self.srcdir, src),
+ path.join(self.outdir, dest))
self.info()
# copy TeX support files from texinputs
+ context = {'latex_engine': self.config.latex_engine}
self.info(bold('copying TeX support files...'))
staticdirname = path.join(package_dir, 'texinputs')
for filename in os.listdir(staticdirname):
if not filename.startswith('.'):
- copyfile(path.join(staticdirname, filename),
- path.join(self.outdir, filename))
+ copy_asset_file(path.join(staticdirname, filename),
+ self.outdir, context=context)
# copy additional files
if self.config.latex_additional_files:
self.info(bold('copying additional files...'), nonl=1)
for filename in self.config.latex_additional_files:
self.info(' '+filename, nonl=1)
- copyfile(path.join(self.confdir, filename),
- path.join(self.outdir, path.basename(filename)))
+ copy_asset_file(path.join(self.confdir, filename), self.outdir)
self.info()
# the logo is handled differently
if self.config.latex_logo:
- logobase = path.basename(self.config.latex_logo)
- logotarget = path.join(self.outdir, logobase)
if not path.isfile(path.join(self.confdir, self.config.latex_logo)):
raise SphinxError('logo file %r does not exist' % self.config.latex_logo)
- elif not path.isfile(logotarget):
- copyfile(path.join(self.confdir, self.config.latex_logo), logotarget)
+ else:
+ copy_asset_file(path.join(self.confdir, self.config.latex_logo), self.outdir)
self.info('done')
@@ -264,6 +263,8 @@ def setup(app):
app.add_builder(LaTeXBuilder)
app.connect('builder-inited', validate_config_values)
+ app.add_config_value('latex_engine', 'pdflatex', None,
+ ENUM('pdflatex', 'xelatex', 'lualatex'))
app.add_config_value('latex_documents',
lambda self: [(self.master_doc, make_filename(self.project) + '.tex',
self.project, '', 'manual')],
diff --git a/sphinx/make_mode.py b/sphinx/make_mode.py
index 9a17895bd..3b7c29383 100644
--- a/sphinx/make_mode.py
+++ b/sphinx/make_mode.py
@@ -42,8 +42,6 @@ BUILDERS = [
("", "latex", "to make LaTeX files, you can set PAPER=a4 or PAPER=letter"),
("posix", "latexpdf", "to make LaTeX files and run them through pdflatex"),
("posix", "latexpdfja", "to make LaTeX files and run them through platex/dvipdfmx"),
- ("posix", "lualatexpdf", "to make LaTeX files and run them through lualatex"),
- ("posix", "xelatexpdf", "to make LaTeX files and run them through xelatex"),
("", "text", "to make text files"),
("", "man", "to make manual pages"),
("", "texinfo", "to make Texinfo files"),
@@ -173,18 +171,6 @@ class Make(object):
with cd(self.builddir_join('latex')):
os.system('make all-pdf-ja')
- def build_lualatexpdf(self):
- if self.run_generic_build('latex') > 0:
- return 1
- with cd(self.builddir_join('latex')):
- os.system('make PDFLATEX=lualatex all-pdf')
-
- def build_xelatexpdf(self):
- if self.run_generic_build('latex') > 0:
- return 1
- with cd(self.builddir_join('latex')):
- os.system('make PDFLATEX=xelatex all-pdf')
-
def build_text(self):
if self.run_generic_build('text') > 0:
return 1
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index 5aa47cb61..ae4d90ad3 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -565,8 +565,6 @@ help:
\t@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
\t@echo " latexpdf to make LaTeX files and run them through pdflatex"
\t@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
-\t@echo " lualatexpdf to make LaTeX files and run them through lualatex"
-\t@echo " xelatexpdf to make LaTeX files and run them through xelatex"
\t@echo " text to make text files"
\t@echo " man to make manual pages"
\t@echo " texinfo to make Texinfo files"
@@ -686,20 +684,6 @@ latexpdfja:
\t$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
\t@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-.PHONY: lualatexpdf
-lualatexpdf:
-\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-\t@echo "Running LaTeX files through lualatex..."
-\t$(MAKE) PDFLATEX=lualatex -C $(BUILDDIR)/latex all-pdf
-\t@echo "lualatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-.PHONY: xelatexpdf
-xelatexpdf:
-\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-\t@echo "Running LaTeX files through xelatex..."
-\t$(MAKE) PDFLATEX=xelatex -C $(BUILDDIR)/latex all-pdf
-\t@echo "xelatex finished; the PDF files are in $(BUILDDIR)/latex."
-
.PHONY: text
text:
\t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
diff --git a/sphinx/texinputs/Makefile b/sphinx/texinputs/Makefile_t
index c0676e3ee..ca66b554d 100644
--- a/sphinx/texinputs/Makefile
+++ b/sphinx/texinputs/Makefile_t
@@ -13,7 +13,7 @@ LATEXOPTS =
FMT = pdf
LATEX = latex
-PDFLATEX = pdflatex
+PDFLATEX = {{ latex_engine }}
MAKEINDEX = makeindex
all: $(ALLPDF)