Skip to contentSkip to conversation

Drop another script used during doc builds

PATCH New Mauro Carvalho Chehab 1 participant 4 messages Sep 12, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Drop another script used during doc builds

Hi Jon,

Heh, with all those scripts and hacks that were accumulated with time for docs makefile, placing them there with absolutely no documentation, I ended missing scripts/check-variable-fonts.sh.

I only realized today when searching for the "|| exit" hack we added in 2017 to fix an issue where make pdfdocs were always returning errors (again, not documented).

This series comes after(*):

    https://lore.kernel.org/linux-doc/[email protected]/T/#t

(*) I should probably have named such series as:
"Move the trick-or-treat build hacks accumulated over time into a single place and document them."

This specific script is called only when PDF build fails. Re-add it at sphinx-build-wrapper logic. After it, problematic PDF builds will warn again about possible issues with CJK variable fonts:

	$ make SPHINXDIRS=translations pdfdocs
	Summary
	=======
	translations: FAILED

	=============================================================================
	XeTeX is confused by "variable font" files listed below:
	    /usr/share/fonts/google-noto-sans-cjk-vf-fonts/NotoSansCJK-VF.ttc
	    /usr/share/fonts/google-noto-sans-mono-cjk-vf-fonts/NotoSansMonoCJK-VF.ttc
	    /usr/share/fonts/google-noto-serif-cjk-vf-fonts/NotoSerifCJK-VF.ttc

	For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.
	Or, CJK pages can be skipped by uninstalling texlive-xecjk.

	For more info on denylisting, other options, and variable font, see header
	comments of tools/docs/lib/latex_fonts.py.
	=============================================================================
	PDF build failed: not all PDF files were created.
	make[2]: *** [Documentation/Makefile:58: pdfdocs] Error 1
	make[1]: *** [/new_devel/docs/Makefile:1806: pdfdocs] Error 2
	make: *** [Makefile:248: __sub-make] Error 2

The output message is identical, except that it now uses __file__ to get the actual location of the verify code (which is now part of a docs lib).

All comments from the original code were preserved, but I opted to use python docstring to store it. This way, we may even add something like print(__doc__) in the future, if needed.

I also opted to preserve a command-line interface, which does nothing but call the check function:

	$ ./tools/docs/check-variable-fonts.py
	=============================================================================
	XeTeX is confused by "variable font" files listed below:
	    /usr/share/fonts/google-noto-sans-cjk-vf-fonts/NotoSansCJK-VF.ttc
	    /usr/share/fonts/google-noto-sans-mono-cjk-vf-fonts/NotoSansMonoCJK-VF.ttc
	    /usr/share/fonts/google-noto-serif-cjk-vf-fonts/NotoSerifCJK-VF.ttc

For CJK pages in PDF, they need to be hidden from XeTeX by denylisting. Or, CJK pages can be skipped by uninstalling texlive-xecjk.

For more info on denylisting, other options, and variable font, see header comments of tools/docs/lib/latex_fonts.py.
=============================================================================

I opted to place it into a class, as we can one day add more functions there, for instance to create the proposed XML file under ~/deny-vc, as the script's documentation proposes.

By using a class, we only need to import the class: all functions from such class are automatically imported altogether. Plus, we don't have to deal with namespaces for a function called "check()".

Mauro Carvalho Chehab (3):
scripts/check-variable-fonts.sh: convert to Python
scripts: check-variable-fonts.py: split into a lib and an exec file tools/docs: sphinx-build-wrapper: warn about broken PDF fonts

 MAINTAINERS                        |   1 -
 scripts/check-variable-fonts.sh    | 115 --------------------
 tools/docs/check-variable-fonts.py |  23 ++++
 tools/docs/lib/latex_fonts.py      | 162 +++++++++++++++++++++++++++++
 tools/docs/sphinx-build-wrapper    |   9 +-
 5 files changed, 192 insertions(+), 118 deletions(-)
 delete mode 100755 scripts/check-variable-fonts.sh
 create mode 100755 tools/docs/check-variable-fonts.py
 create mode 100755 tools/docs/lib/latex_fonts.py
Signature · 1 line
2.50.1
#1 lore raw

PATCH 1/3 scripts/check-variable-fonts.sh: convert to Python

This script handle errors when trying to build translations with make pdfdocs.

As part of our cleanup work to remove hacks from docs Makefile, convert this to python, preparing it to be part of a library to be called by sphinx-build-wrapper.

---
 MAINTAINERS                                   |   2 +-
 ...iable-fonts.sh => check-variable-fonts.py} | 104 +++++++++++++-----
 2 files changed, 78 insertions(+), 28 deletions(-)
 rename scripts/{check-variable-fonts.sh => check-variable-fonts.py} (61%)
MAINTAINERS +1 -1
index 06bbed30b788..8cc14c85fdf5 100644
@@ -7301,7 +7301,7 @@ S:	Maintained
 P:	Documentation/doc-guide/maintainer-profile.rst
 T:	git git://git.lwn.net/linux.git docs-next
 F:	Documentation/
-F:	scripts/check-variable-fonts.sh
+F:	scripts/check-variable-fonts.py
 F:	scripts/checktransupdate.py
 F:	scripts/documentation-file-ref-check
 F:	scripts/get_abi.py
scripts/check-variable-fonts.py renamed from scripts/check-variable-fonts.sh +77 -27

113 lines not on this page · raw message

Signature · 1 line
2.50.1
#2 lore raw

PATCH 2/3 scripts: check-variable-fonts.py: split into a lib and an exec file

In reply to Mauro Carvalho Chehab

As we'll be using the actual code inside sphinx-build-wrapper, split the library from the executable, placing the exec at the new place we've been using:

tools/docs

No functional changes.

---
 MAINTAINERS                        |   1 -
 scripts/check-variable-fonts.py    | 165 -----------------------------
 tools/docs/check-variable-fonts.py |  23 ++++
 tools/docs/lib/latex_fonts.py      | 162 ++++++++++++++++++++++++++++
 4 files changed, 185 insertions(+), 166 deletions(-)
 delete mode 100755 scripts/check-variable-fonts.py
 create mode 100755 tools/docs/check-variable-fonts.py
 create mode 100755 tools/docs/lib/latex_fonts.py
MAINTAINERS +0 -1
index 8cc14c85fdf5..16a5d6ab627d 100644
@@ -7301,7 +7301,6 @@ S:	Maintained
 P:	Documentation/doc-guide/maintainer-profile.rst
 T:	git git://git.lwn.net/linux.git docs-next
 F:	Documentation/
-F:	scripts/check-variable-fonts.py
 F:	scripts/checktransupdate.py
 F:	scripts/documentation-file-ref-check
 F:	scripts/get_abi.py
scripts/check-variable-fonts.py deleted +0 -165

165 lines not on this page · raw message

tools/docs/check-variable-fonts.py new file +23 -0
new file mode 100755
index 000000000000..79b28f0f7d85
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) Akira Yokosawa, 2024
+#
+# Ported to Python by (c) Mauro Carvalho Chehab, 2025
+#
+# pylint: disable=C0103
+
+"""
+Detect problematic Noto CJK variable fonts.
+
+or more details, see lib/latex_fonts.py.
+"""
+
+import sys
+
+from lib.latex_fonts import LatexFontChecker
+
+msg = LatexFontChecker().check()
+if msg:
+    print(msg)
+
+sys.exit(1)
tools/docs/lib/latex_fonts.py new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
2.50.1
#3 lore raw

PATCH 3/3 tools/docs: sphinx-build-wrapper: warn about broken PDF fonts

In reply to Mauro Carvalho Chehab

Depending on the latex install environment, translations can be broken because of CJK variable fonts. Add a warning in the end.

---
 tools/docs/sphinx-build-wrapper | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/docs/sphinx-build-wrapper +7 -2
index c47f723391b9..d40fc25071c6 100755
@@ -54,10 +54,11 @@ import subprocess
 import sys
 
 from concurrent import futures
-
-from lib.python_version import PythonVersion
 from glob import glob
 
+from lib.python_version import PythonVersion
+from lib.latex_fonts import LatexFontChecker
+
 LIB_DIR = "../../scripts/lib"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
@@ -476,6 +477,10 @@ class SphinxBuilder:
         print()
 
         if build_failed:
+            msg = LatexFontChecker().check()
+            if msg:
+                print(msg)
+
             sys.exit("PDF build failed: not all PDF files were created.")
         else:
             print("All PDF files were built.")
Signature · 1 line
2.50.1