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

LaTeX: let latexpdf implement '-q' and '-Q' sphinx-build options #12729

Merged
merged 8 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ Bugs fixed
Patch by Hugo van Kemenade.
* #12645: Correctly support custom gettext output templates.
Patch by Jeremy Bowman.
* #12717: LaTeX: let :option:`-q <sphinx-build -q>` (quiet) option for
:program:`sphinx-build -M latexpdf` or :program:`make latexpdf` (``O=-q``)
get passed to :program:`latexmk`. Let :option:`-Q <sphinx-build -Q>`
(silent) apply as well to the PDF build phase.
Patch by Jean-François B.

Testing
-------
Expand Down
29 changes: 28 additions & 1 deletion sphinx/cmd/make_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down