summaryrefslogtreecommitdiff
path: root/tools/docs/sphinx-build-wrapper
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2025-09-18 14:54:52 +0300
committerJonathan Corbet <corbet@lwn.net>2025-09-18 20:18:39 +0300
commit0d9abc7627f5aeaaa8db6e856d800819cc9d85b1 (patch)
treeff29af42402d02a13415a427b3db9d9727203c68 /tools/docs/sphinx-build-wrapper
parent82c294d453c0f065133da064f92a121500cc5643 (diff)
downloadlinux-0d9abc7627f5aeaaa8db6e856d800819cc9d85b1.tar.xz
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>
Diffstat (limited to 'tools/docs/sphinx-build-wrapper')
-rwxr-xr-xtools/docs/sphinx-build-wrapper20
1 files changed, 9 insertions, 11 deletions
diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrapper
index 6c2580303e8e..8d1f77c4a880 100755
--- a/tools/docs/sphinx-build-wrapper
+++ b/tools/docs/sphinx-build-wrapper
@@ -329,9 +329,6 @@ class SphinxBuilder:
continue
name = name[:-len(tex_suffix)]
-
- max_len = max(max_len, len(name))
-
has_tex = True
future = executor.submit(self.build_pdf_file, latex_cmd,
@@ -343,34 +340,35 @@ class SphinxBuilder:
pdf_name = name + ".pdf"
pdf_from = os.path.join(from_dir, pdf_name)
+ pdf_to = os.path.join(pdf_dir, pdf_name)
+ out_name = os.path.relpath(pdf_to, self.builddir)
+ max_len = max(max_len, len(out_name))
try:
success = future.result()
if success and os.path.exists(pdf_from):
- pdf_to = os.path.join(pdf_dir, pdf_name)
-
os.rename(pdf_from, pdf_to)
#
# if verbose, get the name of built PDF file
#
if self.verbose:
- builds[name] = os.path.relpath(pdf_to, self.builddir)
+ builds[out_name] = "SUCCESS"
else:
- builds[name] = "FAILED"
+ builds[out_name] = "FAILED"
build_failed = True
except futures.Error as e:
- builds[name] = f"FAILED ({repr(e)})"
+ builds[out_name] = f"FAILED ({repr(e)})"
build_failed = True
#
# Handle case where no .tex files were found
#
if not has_tex:
- name = "Sphinx LaTeX builder"
- max_len = max(max_len, len(name))
- builds[name] = "FAILED (no .tex file was generated)"
+ out_name = "LaTeX files"
+ max_len = max(max_len, len(out_name))
+ builds[out_name] = "FAILED: no .tex files were generated"
build_failed = True
return builds, build_failed, max_len