Skip to content

Commit 9d3087c

Browse files
authored
LaTeX: let latexpdf implement '-q' and '-Q' sphinx-build options (#12729)
1 parent 0cbdd98 commit 9d3087c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ Bugs fixed
4949
Patch by Hugo van Kemenade.
5050
* #12645: Correctly support custom gettext output templates.
5151
Patch by Jeremy Bowman.
52+
* #12717: LaTeX: let :option:`-q <sphinx-build -q>` (quiet) option for
53+
:program:`sphinx-build -M latexpdf` or :program:`make latexpdf` (``O=-q``)
54+
get passed to :program:`latexmk`. Let :option:`-Q <sphinx-build -Q>`
55+
(silent) apply as well to the PDF build phase.
56+
Patch by Jean-François B.
5257

5358
Testing
5459
-------

sphinx/cmd/make_mode.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,34 @@ def build_latexpdf(self) -> int:
106106
raise RuntimeError('Invalid $MAKE command: %r' % makecmd)
107107
try:
108108
with chdir(self.builddir_join('latex')):
109-
return subprocess.call([makecmd, 'all-pdf'])
109+
if '-Q' in self.opts:
110+
with open('__LATEXSTDOUT__', 'w') as outfile:
111+
returncode = subprocess.call([makecmd,
112+
'all-pdf',
113+
'LATEXOPTS=-halt-on-error',
114+
],
115+
stdout=outfile,
116+
stderr=subprocess.STDOUT,
117+
)
118+
if returncode:
119+
print('Latex error: check %s' %
120+
self.builddir_join('latex', '__LATEXSTDOUT__')
121+
)
122+
elif '-q' in self.opts:
123+
returncode = subprocess.call(
124+
[makecmd,
125+
'all-pdf',
126+
'LATEXOPTS=-halt-on-error',
127+
'LATEXMKOPTS=-silent',
128+
],
129+
)
130+
if returncode:
131+
print('Latex error: check .log file in %s' %
132+
self.builddir_join('latex')
133+
)
134+
else:
135+
returncode = subprocess.call([makecmd, 'all-pdf'])
136+
return returncode
110137
except OSError:
111138
print('Error: Failed to run: %s' % makecmd)
112139
return 1

0 commit comments

Comments
 (0)