Skip to content

Commit 0d9abc7

Browse files
mchehabJonathan Corbet
authored andcommitted
tools/docs: sphinx-build-wrapper: Fix output for duplicated names
When SPHINXDIRS is used, basename may be identical for different files. If this happens, the summary and error detection won't be accurate. Fix it by using relative names from builddir. While here, don't duplicate names. Report, instead: - SUCCESS output PDF file was built - FAILED latexmk/xelatex didn't build any PDF output - FAILED: no .tex files were generated Sphinx didn't build any tex file for SPHINXDIRS directories - FAILED ({python exception}) When a concurrent.futures is catched. Usually indicates an internal error at the build logic. With that, building multiple dirs with the same name is reported properly: $ make V=1 SPHINXDIRS="admin-guide/media driver-api/media userspace-api/media" pdfdocs Summary ======= admin-guide/media/pdf/media.pdf : SUCCESS driver-api/media/pdf/media.pdf : SUCCESS userspace-api/media/pdf/media.pdf: SUCCESS And if at least one of them fails, return code will be 1. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Message-ID: <d4a4f16f6c0c423ad38531a490888be3bf01e574.1758196090.git.mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 82c294d commit 0d9abc7

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

tools/docs/sphinx-build-wrapper

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ class SphinxBuilder:
329329
continue
330330

331331
name = name[:-len(tex_suffix)]
332-
333-
max_len = max(max_len, len(name))
334-
335332
has_tex = True
336333

337334
future = executor.submit(self.build_pdf_file, latex_cmd,
@@ -343,34 +340,35 @@ class SphinxBuilder:
343340

344341
pdf_name = name + ".pdf"
345342
pdf_from = os.path.join(from_dir, pdf_name)
343+
pdf_to = os.path.join(pdf_dir, pdf_name)
344+
out_name = os.path.relpath(pdf_to, self.builddir)
345+
max_len = max(max_len, len(out_name))
346346

347347
try:
348348
success = future.result()
349349

350350
if success and os.path.exists(pdf_from):
351-
pdf_to = os.path.join(pdf_dir, pdf_name)
352-
353351
os.rename(pdf_from, pdf_to)
354352

355353
#
356354
# if verbose, get the name of built PDF file
357355
#
358356
if self.verbose:
359-
builds[name] = os.path.relpath(pdf_to, self.builddir)
357+
builds[out_name] = "SUCCESS"
360358
else:
361-
builds[name] = "FAILED"
359+
builds[out_name] = "FAILED"
362360
build_failed = True
363361
except futures.Error as e:
364-
builds[name] = f"FAILED ({repr(e)})"
362+
builds[out_name] = f"FAILED ({repr(e)})"
365363
build_failed = True
366364

367365
#
368366
# Handle case where no .tex files were found
369367
#
370368
if not has_tex:
371-
name = "Sphinx LaTeX builder"
372-
max_len = max(max_len, len(name))
373-
builds[name] = "FAILED (no .tex file was generated)"
369+
out_name = "LaTeX files"
370+
max_len = max(max_len, len(out_name))
371+
builds[out_name] = "FAILED: no .tex files were generated"
374372
build_failed = True
375373

376374
return builds, build_failed, max_len

0 commit comments

Comments
 (0)