diff --git a/docs/guides/feature-flags.rst b/docs/guides/feature-flags.rst index 91ba814356b..e1bd9c57d87 100644 --- a/docs/guides/feature-flags.rst +++ b/docs/guides/feature-flags.rst @@ -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` diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index c5a664835fa..959bebf2ff0 100644 --- a/readthedocs/doc_builder/backends/sphinx.py +++ b/readthedocs/doc_builder/backends/sphinx.py @@ -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( @@ -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, @@ -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, diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index 5991a41bb14..30d07d24b4f 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -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, _( @@ -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(