Skip to content

Commit

Permalink
Allow to use xelatex by a project feature flag
Browse files Browse the repository at this point in the history
References,

#4454
#1556
  • Loading branch information
humitos committed Mar 6, 2019
1 parent bdb4aa5 commit 00c3e89
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/guides/feature-flags.rst
Expand Up @@ -16,6 +16,8 @@ Available Flags

``USE_SETUPTOOLS_LATEST``: :featureflags:`USE_SETUPTOOLS_LATEST`

``USE_XELATEX_BINARY``: :featureflags:`USE_XELATEX_BINARY`

``ALLOW_DEPRECATED_WEBHOOKS``: :featureflags:`ALLOW_DEPRECATED_WEBHOOKS`

``PIP_ALWAYS_UPGRADE``: :featureflags:`PIP_ALWAYS_UPGRADE`
Expand Down
15 changes: 11 additions & 4 deletions readthedocs/doc_builder/backends/sphinx.py
Expand Up @@ -392,10 +392,17 @@ def build(self):
raise BuildEnvironmentError('No TeX files were found')

# Run LaTeX -> PDF conversions
pdflatex_cmds = [
['pdflatex', '-interaction=nonstopmode', tex_file]
# https://github.com/rtfd/readthedocs.org/issues/4454
if self.project.has_feature(Feature.USE_XELATEX_BINARY):
latex_cmd = 'xelatex'
else:
latex_cmd = 'pdflatex'

latex_cmds = [
[latex_cmd, '-interaction=nonstopmode', tex_file]
for tex_file in tex_files
] # yapf: disable

makeindex_cmds = [
[
'makeindex', '-s', 'python.ist', '{}.idx'.format(
Expand All @@ -410,7 +417,7 @@ def build(self):
else:
latex_class = LatexBuildCommand
pdf_commands = []
for cmd in pdflatex_cmds:
for cmd in latex_cmds:
cmd_ret = self.build_env.run_command_class(
cls=latex_class,
cmd=cmd,
Expand All @@ -426,7 +433,7 @@ def build(self):
warn_only=True,
)
pdf_commands.append(cmd_ret)
for cmd in pdflatex_cmds:
for cmd in latex_cmds:
cmd_ret = self.build_env.run_command_class(
cls=latex_class,
cmd=cmd,
Expand Down
4 changes: 3 additions & 1 deletion readthedocs/projects/models.py
Expand Up @@ -1313,12 +1313,14 @@ def add_features(sender, **kwargs):
API_LARGE_DATA = 'api_large_data'
DONT_SHALLOW_CLONE = 'dont_shallow_clone'
USE_TESTING_BUILD_IMAGE = 'use_testing_build_image'
USE_XELATEX_BINARY = 'use_xelatex_binary'

FEATURES = (
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
(USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')),
(ALLOW_DEPRECATED_WEBHOOKS, _('Allow deprecated webhook views')),
(PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')),
(USE_XELATEX_BINARY, _('Use "xelatex" binary to build PDF files')),
(SKIP_SUBMODULES, _('Skip git submodule checkout')), (
DONT_OVERWRITE_SPHINX_CONTEXT,
_(
Expand All @@ -1337,7 +1339,7 @@ def add_features(sender, **kwargs):
_(
'Use Docker image labelled as `testing` to build the docs',
),
), (API_LARGE_DATA, _('Try alternative method of posting large data'))
), (API_LARGE_DATA, _('Try alternative method of posting large data')),
)

projects = models.ManyToManyField(
Expand Down

0 comments on commit 00c3e89

Please sign in to comment.