From: Akira Yokosawa <akiyks@gmail.com>
To: mchehab+huawei@kernel.org
Cc: alex.gaynor@gmail.com, aliceryhl@google.com,
bjorn3_gh@protonmail.com, boqun.feng@gmail.com, corbet@lwn.net,
gary@garyguo.net, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
tmgross@umich.edu, Akira Yokosawa <akiyks@gmail.com>
Subject: Re: [PATCH 04/11] scripts: sphinx-build-wrapper: add a wrapper for sphinx-build
Date: Sat, 16 Aug 2025 10:16:01 +0900 [thread overview]
Message-ID: <9b3b0430-066f-486e-89cc-00e6f1f3b096@gmail.com> (raw)
In-Reply-To: <88a95c7f6996cafb247d6706060173b17a46d570.1755258303.git.mchehab+huawei@kernel.org>
Hi Mauro,
On Fri, 15 Aug 2025 13:50:32 +0200, Mauro Carvalho Chehab wrote:
> There are too much magic inside docs Makefile to properly run
> sphinx-build. Create an ancillary script that contains all
> kernel-related sphinx-build call logic currently at Makefile.
>
> Such script is designed to work both as an standalone command
> and as part of a Makefile. As such, it properly handles POSIX
> jobserver used by GNU make.
>
> It should be noticed that, when running the script alone,
> it will only take care of sphinx-build and cleandocs target.
> As such:
>
> - it won't run "make rustdoc";
> - no extra checks.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
> .pylintrc | 2 +-
> scripts/sphinx-build-wrapper | 627 +++++++++++++++++++++++++++++++++++
> 2 files changed, 628 insertions(+), 1 deletion(-)
> create mode 100755 scripts/sphinx-build-wrapper
>
[...]
> diff --git a/scripts/sphinx-build-wrapper b/scripts/sphinx-build-wrapper
> new file mode 100755
> index 000000000000..5c728956b53c
> --- /dev/null
> +++ b/scripts/sphinx-build-wrapper
> @@ -0,0 +1,627 @@
[...]
> + def handle_pdf(self, output_dirs):
> + """
> + Extra steps for PDF output.
> +
> + As PDF is handled via a LaTeX output, after building the .tex file,
> + a new build is needed to create the PDF output from the latex
> + directory.
> + """
> + builds = {}
> + max_len = 0
> +
> + for from_dir in output_dirs:
> + pdf_dir = os.path.join(from_dir, "../pdf")
> + os.makedirs(pdf_dir, exist_ok=True)
> +
> + if self.latexmk_cmd:
> + latex_cmd = [self.latexmk_cmd, f"-{self.pdflatex}"]
> + else:
> + latex_cmd = [self.pdflatex]
> +
> + latex_cmd.extend(shlex.split(self.latexopts))
> +
> + tex_suffix = ".tex"
> +
> + # Process each .tex file
> + has_tex = False
> + build_failed = False
> + with os.scandir(from_dir) as it:
> + for entry in it:
> + if not entry.name.endswith(tex_suffix):
> + continue
> +
> + name = entry.name[:-len(tex_suffix)]
> + has_tex = True
> +
> + try:
> + subprocess.run(latex_cmd + [entry.path],
> + cwd=from_dir, check=True)
So, runs of latexmk (or xelatex) would be serialized, wouldn't they?
That would be a *huge* performance regression when I say:
"make -j10 -O pdfdocs"
Current Makefile delegates .tex --> .pdf part of pdfdocs to sub make
of .../output/Makefile, which is generated on-the-fly by Sphinx's
latex builder. That "-j10 -O" flag is passed to the sub make.
Another issue is that you are not deny-listing variable Noto CJK
fonts for latexmk/xelatex. So this version of wrapper won't be able
to build translations.pdf if you have such variable fonts installed.
That failuer is not caught by your ad-hoc logic below.
> + except subprocess.CalledProcessError:
> + # LaTeX PDF error code is almost useless: it returns
> + # error codes even when build succeeds but has warnings.
> + pass
> +
> + # Instead of checking errors, let's do the next best thing:
> + # check if the PDF file was actually created.
I've seen cases where a corrupt .pdf file is left after premature crashes
of xdvipdfmx. So, checking .pdf is not good enough for determining
success/failure.
One way to see if a .pdf file is properly formatted would be to run
"pdffonts" against the resulting .pdf.
For example, if I run "pdffonts translations.pdf" against the corrupted
one, I get:
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table
, with the exit code of 1.
Against a successfully built translations.pdf, I get something like:
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
JPRCQB+DejaVuSans-Bold CID TrueType Identity-H yes yes yes 4 0
QFNXFP+DejaVuSerif-Bold CID TrueType Identity-H yes yes yes 13 0
NMFBZR+NotoSerifCJKjp-Bold-Identity-H CID Type 0C Identity-H yes yes yes 15 0
WYMCYC+NotoSansCJKjp-Black-Identity-H CID Type 0C Identity-H yes yes yes 32 0
[...]
So I have to say this version of your wrapper does not look quite
ready to replace what you call "too much magic inside docs Makefile".
Regards,
Akira
next prev parent reply other threads:[~2025-08-16 1:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 11:50 [PATCH 00/11] Split sphinx call logic from docs Makefile Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 01/11] scripts/jobserver-exec: move the code to a class Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 02/11] scripts/jobserver-exec: move its class to the lib directory Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 03/11] scripts/jobserver-exec: add a help message Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 04/11] scripts: sphinx-build-wrapper: add a wrapper for sphinx-build Mauro Carvalho Chehab
2025-08-16 1:16 ` Akira Yokosawa [this message]
2025-08-16 11:06 ` Mauro Carvalho Chehab
2025-08-21 19:36 ` Jonathan Corbet
2025-08-21 19:43 ` Mauro Carvalho Chehab
2025-08-21 20:18 ` Jonathan Corbet
2025-08-21 20:11 ` Jonathan Corbet
2025-08-22 2:06 ` Mauro Carvalho Chehab
2025-08-22 13:55 ` Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 05/11] docs: Makefile: cleanup the logic by using sphinx-build-wrapper Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 06/11] docs: parallel-wrapper.sh: remove script Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 07/11] docs: Makefile: document latex/PDF PAPER= parameter Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 08/11] scripts/sphinx-build-wrapper: restore SPHINXOPTS parsing Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 09/11] scripts: sphinx-build-wrapper: add an argument for LaTeX interactive mode Mauro Carvalho Chehab
2025-08-15 11:50 ` [PATCH 10/11] scripts: sphinx-*: prevent sphinx-build crashes Mauro Carvalho Chehab
2025-08-21 19:41 ` Jonathan Corbet
2025-08-15 11:50 ` [PATCH 11/11] docs: Makefile: cleanup the logic by using sphinx-build-wrapper Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b3b0430-066f-486e-89cc-00e6f1f3b096@gmail.com \
--to=akiyks@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=gary@garyguo.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®