|
17 | 17 |
|
18 | 18 | from ..base import BaseBuilder, restoring_chdir
|
19 | 19 | from ..exceptions import BuildEnvironmentError
|
| 20 | +from ..environments import BuildCommand |
20 | 21 |
|
21 | 22 |
|
22 | 23 | log = logging.getLogger(__name__)
|
@@ -225,6 +226,17 @@ def move(self, **kwargs):
|
225 | 226 | self.run('mv', '-f', from_file, to_file)
|
226 | 227 |
|
227 | 228 |
|
| 229 | +class LatexBuildCommand(BuildCommand): |
| 230 | + '''Ignore LaTeX exit code if there was file output''' |
| 231 | + |
| 232 | + def run(self): |
| 233 | + super(LatexBuildCommand, self).run() |
| 234 | + # Force LaTeX exit code to be a little more optimistic. If LaTeX |
| 235 | + # reports an output file, let's just assume we're fine. |
| 236 | + if PDF_RE.search(self.output): |
| 237 | + self.exit_code = 0 |
| 238 | + |
| 239 | + |
228 | 240 | class PdfBuilder(BaseSphinx):
|
229 | 241 | type = 'sphinx_pdf'
|
230 | 242 | sphinx_build_dir = '_build/latex'
|
@@ -268,20 +280,18 @@ def build(self, **kwargs):
|
268 | 280 |
|
269 | 281 | pdf_commands = []
|
270 | 282 | for cmd in pdflatex_cmds:
|
271 |
| - cmd_ret = self.run(*cmd, cwd=latex_cwd, warn_only=True) |
272 |
| - # Force LaTeX exit code to be a little more optimistic. If LaTeX |
273 |
| - # reports an output file, let's just assume we're fine. |
274 |
| - if PDF_RE.search(cmd_ret.output): |
275 |
| - cmd_ret.exit_code = 0 |
| 283 | + cmd_ret = self.build_env.run_command_class( |
| 284 | + cls=LatexBuildCommand, cmd=cmd, cwd=latex_cwd, warn_only=True) |
276 | 285 | pdf_commands.append(cmd_ret)
|
277 | 286 | for cmd in makeindex_cmds:
|
278 |
| - cmd_ret = self.run(*cmd, cwd=latex_cwd, warn_only=True) |
| 287 | + cmd_ret = self.build_env.run_command_class( |
| 288 | + cls=LatexBuildCommand, cmd=cmd, cwd=latex_cwd, warn_only=True) |
279 | 289 | pdf_commands.append(cmd_ret)
|
280 | 290 | for cmd in pdflatex_cmds:
|
281 |
| - cmd_ret = self.run(*cmd, cwd=latex_cwd, warn_only=True) |
| 291 | + cmd_ret = self.build_env.run_command_class( |
| 292 | + cls=LatexBuildCommand, cmd=cmd, cwd=latex_cwd, warn_only=True) |
282 | 293 | pdf_match = PDF_RE.search(cmd_ret.output)
|
283 | 294 | if pdf_match:
|
284 |
| - cmd_ret.exit_code = 0 |
285 | 295 | self.pdf_file_name = pdf_match.group(1).strip()
|
286 | 296 | pdf_commands.append(cmd_ret)
|
287 | 297 | return all(cmd.successful for cmd in pdf_commands)
|
|
0 commit comments