Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature flag to use other pdf latex binaries #5405

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/guides/feature-flags.rst
Expand Up @@ -16,6 +16,12 @@ Available Flags

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

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

``USE_LUALATEX_BINARY``: :featureflags:`USE_LUALATEX_BINARY`

``USE_PLATEX_BINARY``: :featureflags:`USE_PLATEX_BINARY`

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

``PIP_ALWAYS_UPGRADE``: :featureflags:`PIP_ALWAYS_UPGRADE`
Expand Down
30 changes: 25 additions & 5 deletions readthedocs/doc_builder/backends/sphinx.py
Expand Up @@ -392,13 +392,33 @@ 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'
makeindex_cmd = 'xindy'
elif self.project.has_feature(Feature.USE_LUALATEX_BINARY):
latex_cmd = 'lualatex'
makeindex_cmd = 'xindy'
elif self.project.has_feature(Feature.USE_PLATEX_BINARY):
latex_cmd = 'platex'
makeindex_cmd = 'xindy'
else:
latex_cmd = 'pdflatex'
makeindex_cmd = 'makeindex'

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

if makeindex_cmd == 'xindy':
makeindex_args = ['-C', 'utf8', '-M', 'texindy']
else:
makeindex_args = ['-s', 'python.ist']

makeindex_cmds = [
[
'makeindex', '-s', 'python.ist', '{}.idx'.format(
makeindex_cmd, *makeindex_args, '{}.idx'.format(
os.path.splitext(os.path.relpath(tex_file, latex_cwd))[0],
),
]
Expand All @@ -410,7 +430,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 +446,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
8 changes: 7 additions & 1 deletion readthedocs/projects/models.py
Expand Up @@ -1313,12 +1313,18 @@ 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'
USE_LUALATEX_BINARY = 'use_lualatex_binary'
USE_PLATEX_BINARY = 'use_platex_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')),
(USE_LUALATEX_BINARY, _('Use "lualatex" binary to build PDF files')),
(USE_PLATEX_BINARY, _('Use "platex" binary to build PDF files')),
(SKIP_SUBMODULES, _('Skip git submodule checkout')), (
DONT_OVERWRITE_SPHINX_CONTEXT,
_(
Expand All @@ -1337,7 +1343,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