diff --git a/docs/user/guides/pdf-non-ascii-languages.rst b/docs/user/guides/pdf-non-ascii-languages.rst index f05bee5aff8..b181c571a29 100644 --- a/docs/user/guides/pdf-non-ascii-languages.rst +++ b/docs/user/guides/pdf-non-ascii-languages.rst @@ -3,8 +3,6 @@ Sphinx PDFs with Unicode Sphinx offers different `LaTeX engines`_ that have better support for Unicode characters and non-European languages like Japanese or Chinese. -By default Sphinx uses ``pdflatex``, -which does not have good support for Unicode characters and may make the PDF builder fail. .. _LaTeX engines: http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine @@ -17,7 +15,7 @@ to modify Sphinx and Read the Docs behavior to make your documentation to build For docs that are not written in Chinese or Japanese, and if your build fails from a Unicode error, -then try ``xelatex`` as the ``latex_engine`` instead of the default ``pdflatex`` in your ``conf.py``: +then try ``xelatex`` as the ``latex_engine`` in your ``conf.py``: .. code-block:: python diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index 803e14b7fb4..22d1ddb22c3 100644 --- a/readthedocs/doc_builder/backends/sphinx.py +++ b/readthedocs/doc_builder/backends/sphinx.py @@ -336,38 +336,6 @@ def sphinx_parallel_arg(self): return ['-j', 'auto'] return [] - def venv_sphinx_supports_latexmk(self): - """ - Check if ``sphinx`` from the user's venv supports ``latexmk``. - - If the version of ``sphinx`` is greater or equal to 1.6.1 it returns - ``True`` and ``False`` otherwise. - - See: https://www.sphinx-doc.org/en/master/changes.html#release-1-6-1-released-may-16-2017 - """ - - command = [ - self.python_env.venv_bin(filename='python'), - '-c', - ( - '"' - 'import sys; ' - 'import sphinx; ' - 'sys.exit(0 if sphinx.version_info >= (1, 6, 1) else 1)' - '"' - ), - ] - - cmd_ret = self.run( - *command, - bin_path=self.python_env.venv_bin(), - cwd=self.project_path, - escape_command=False, # used on DockerBuildCommand - shell=True, # used on BuildCommand - record=False, - ) - return cmd_ret.exit_code == 0 - class HtmlBuilder(BaseSphinx): relative_output_dir = "_readthedocs/html" @@ -548,12 +516,7 @@ def build(self): raise BuildUserError("No TeX files were found.") # Run LaTeX -> PDF conversions - # Build PDF with ``latexmk`` if Sphinx supports it, otherwise fallback - # to ``pdflatex`` to support old versions - if self.venv_sphinx_supports_latexmk(): - success = self._build_latexmk(self.project_path) - else: - success = self._build_pdflatex(tex_files) + success = self._build_latexmk(self.project_path) self._post_build() return success @@ -625,59 +588,6 @@ def _build_latexmk(self, cwd): return cmd_ret.successful - def _build_pdflatex(self, tex_files): - pdflatex_cmds = [ - ['pdflatex', '-interaction=nonstopmode', tex_file] - for tex_file in tex_files - ] # yapf: disable - makeindex_cmds = [ - [ - "makeindex", - "-s", - "python.ist", - "{}.idx".format( - os.path.splitext( - os.path.relpath(tex_file, self.absolute_output_dir) - )[0], - ), - ] - for tex_file in tex_files - ] # yapf: disable - - if self.build_env.command_class == DockerBuildCommand: - latex_class = DockerLatexBuildCommand - else: - latex_class = LatexBuildCommand - pdf_commands = [] - for cmd in pdflatex_cmds: - cmd_ret = self.build_env.run_command_class( - cls=latex_class, - cmd=cmd, - cwd=self.absolute_output_dir, - warn_only=True, - ) - pdf_commands.append(cmd_ret) - for cmd in makeindex_cmds: - cmd_ret = self.build_env.run_command_class( - cls=latex_class, - cmd=cmd, - cwd=self.absolute_output_dir, - warn_only=True, - ) - pdf_commands.append(cmd_ret) - for cmd in pdflatex_cmds: - cmd_ret = self.build_env.run_command_class( - cls=latex_class, - cmd=cmd, - cwd=self.absolute_output_dir, - warn_only=True, - ) - pdf_match = PDF_RE.search(cmd_ret.output) - if pdf_match: - self.pdf_file_name = pdf_match.group(1).strip() - pdf_commands.append(cmd_ret) - return all(cmd.successful for cmd in pdf_commands) - def _post_build(self): """Internal post build to cleanup PDF output directory and leave only one .pdf file.""" diff --git a/readthedocs/projects/tests/test_build_tasks.py b/readthedocs/projects/tests/test_build_tasks.py index 9eb7f4e5915..9245f2876fa 100644 --- a/readthedocs/projects/tests/test_build_tasks.py +++ b/readthedocs/projects/tests/test_build_tasks.py @@ -719,18 +719,9 @@ def test_build_commands_executed( cwd=mock.ANY, bin_path=mock.ANY, ), + mock.call("cat", "latexmkrc", cwd=mock.ANY), # NOTE: pdf `mv` commands and others are not here because the # PDF resulting file is not found in the process (`_post_build`) - mock.call( - mock.ANY, - "-c", - '"import sys; import sphinx; sys.exit(0 if sphinx.version_info >= (1, 6, 1) else 1)"', - bin_path=mock.ANY, - cwd=mock.ANY, - escape_command=False, - shell=True, - record=False, - ), mock.call( mock.ANY, "-m",