diff --git a/CHANGES.rst b/CHANGES.rst index d05a09e9050..a048f6d520a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -65,6 +65,11 @@ Bugs fixed * #12714: LaTeX: Let ``\mathbf{\Lambda}`` work as expected if :confval:`latex_engine` is ``'xelatex'`` or ``'lualatex'``, via usage of ``unicode-math`` with XITS Math font. +* #12717: LaTeX: let :option:`-q ` (quiet) option for + :program:`sphinx-build -M latexpdf` or :program:`make latexpdf` (``O=-q``) + get passed to :program:`latexmk`. Let :option:`-Q ` + (silent) apply as well to the PDF build phase. + Patch by Jean-François B. Testing ------- diff --git a/sphinx/cmd/make_mode.py b/sphinx/cmd/make_mode.py index 01929469cca..65df9f6227e 100644 --- a/sphinx/cmd/make_mode.py +++ b/sphinx/cmd/make_mode.py @@ -106,7 +106,34 @@ def build_latexpdf(self) -> int: raise RuntimeError('Invalid $MAKE command: %r' % makecmd) try: with chdir(self.builddir_join('latex')): - return subprocess.call([makecmd, 'all-pdf']) + if '-Q' in self.opts: + with open('__LATEXSTDOUT__', 'w') as outfile: + returncode = subprocess.call([makecmd, + 'all-pdf', + 'LATEXOPTS=-halt-on-error', + ], + stdout=outfile, + stderr=subprocess.STDOUT, + ) + if returncode: + print('Latex error: check %s' % + self.builddir_join('latex', '__LATEXSTDOUT__') + ) + elif '-q' in self.opts: + returncode = subprocess.call( + [makecmd, + 'all-pdf', + 'LATEXOPTS=-halt-on-error', + 'LATEXMKOPTS=-silent', + ], + ) + if returncode: + print('Latex error: check .log file in %s' % + self.builddir_join('latex') + ) + else: + returncode = subprocess.call([makecmd, 'all-pdf']) + return returncode except OSError: print('Error: Failed to run: %s' % makecmd) return 1