mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 02/14] docs: conf.py: better handle latex documents
Date: Thu, 21 Aug 2025 10:16:38 +0200	[thread overview]
Message-ID: <de23b35a770210950c609deaa32b98cb3673a53a.1755763127.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1755763127.git.mchehab+huawei@kernel.org>

The original logic assumed that app.srcdir is identical to the
current working dir. This is the case for a normal build, but,
when SPHINXDIRS="some dir" is used, this is not the case anymore.

Adjust the logic to fill the LaTeX documents considering
app.srcdir, in a way that it will work properly on all cases.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 Documentation/conf.py | 54 +++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 28 deletions(-)

diff --git a/Documentation/conf.py b/Documentation/conf.py
index f9828f3862f9..2c1be59fd54b 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -51,11 +51,13 @@ else:
     dyn_exclude_patterns.append("devicetree/bindings/**.yaml")
     dyn_exclude_patterns.append("core-api/kho/bindings/**.yaml")
 
-# Properly handle include/exclude patterns
-# ----------------------------------------
+# Properly handle directory patterns and LaTeX docs
+# -------------------------------------------------
 
-def update_patterns(app, config):
+def config_init(app, config):
     """
+    Initialize path-dependent variabled
+
     On Sphinx, all directories are relative to what it is passed as
     SOURCEDIR parameter for sphinx-build. Due to that, all patterns
     that have directory names on it need to be dynamically set, after
@@ -86,6 +88,25 @@ def update_patterns(app, config):
 
         config.exclude_patterns.append(rel_path)
 
+    # LaTeX and PDF output require a list of documents with are dependent
+    # of the app.srcdir. Add them here
+
+    for fn in os.listdir(app.srcdir):
+        doc = os.path.join(fn, "index")
+        if not os.path.exists(os.path.join(app.srcdir, doc + ".rst")):
+            continue
+
+        has = False
+        for l in latex_documents:
+            if l[0] == doc:
+                has = True
+                break
+
+        if not has:
+            latex_documents.append((doc, fn + ".tex",
+                                    "Linux %s Documentation" % fn.capitalize(),
+                                    "The kernel development community",
+                                    "manual"))
 
 # helper
 # ------
@@ -456,32 +477,9 @@ latex_elements["preamble"] += """
         \\input{kerneldoc-preamble.sty}
 """
 
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title,
-#  author, documentclass [howto, manual, or own class]).
-# Sorted in alphabetical order
+# This will be filled up by config-inited event
 latex_documents = []
 
-# Add all other index files from Documentation/ subdirectories
-for fn in os.listdir("."):
-    doc = os.path.join(fn, "index")
-    if os.path.exists(doc + ".rst"):
-        has = False
-        for l in latex_documents:
-            if l[0] == doc:
-                has = True
-                break
-        if not has:
-            latex_documents.append(
-                (
-                    doc,
-                    fn + ".tex",
-                    "Linux %s Documentation" % fn.capitalize(),
-                    "The kernel development community",
-                    "manual",
-                )
-            )
-
 # The name of an image file (relative to this directory) to place at the top of
 # the title page.
 # latex_logo = None
@@ -577,4 +575,4 @@ loadConfig(globals())
 def setup(app):
     """Patterns need to be updated at init time on older Sphinx versions"""
 
-    app.connect('config-inited', update_patterns)
+    app.connect('config-inited', config_init)
-- 
2.50.1


  parent reply	other threads:[~2025-08-21  8:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-21  8:16 [PATCH v2 00/14] Fix PDF doc builds on major distros Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 01/14] docs: Makefile: Fix LaTeX paper size settings Mauro Carvalho Chehab
2025-08-21  8:16 ` Mauro Carvalho Chehab [this message]
2025-08-21  8:16 ` [PATCH v2 03/14] docs: conf.py: fix doc name with SPHINXDIRS Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 04/14] docs: conf.py: rename some vars at latex_documents logic Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 05/14] docs: conf.py: use dedent and r-strings for LaTeX macros Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 06/14] docs: conf.py: fix some troubles for LaTeX output Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 07/14] docs: conf.py: extra cleanups and fixes Mauro Carvalho Chehab
2025-08-22 12:01   ` Akira Yokosawa
2025-08-22 13:27     ` Mauro Carvalho Chehab
2025-08-22 22:34       ` Jonathan Corbet
2025-08-25 12:07         ` Mauro Carvalho Chehab
2025-08-25 12:15           ` Jonathan Corbet
2025-08-25 17:11             ` Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 08/14] scripts: sphinx-pre-install: fix PDF build issues on Ubuntu Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 09/14] scripts: sphinx-pre-install: add missing gentoo pdf dependencies Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 10/14] scripts: sphinx-pre-install: fix PDF dependencies for openSuse Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 11/14] scripts: sphinx-pre-install: fix dependencies for OpenMandriva Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 12/14] scripts: sphinx-pre-install: fix pdf dependencies for Mageia 9 Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 13/14] scripts: sphinx-pre-install: fix PDF dependencies for gentoo Mauro Carvalho Chehab
2025-08-21  8:16 ` [PATCH v2 14/14] scripts/sphinx-pre-install: fix Archlinux PDF dependencies Mauro Carvalho Chehab
2025-08-21 19:22 ` [PATCH v2 00/14] Fix PDF doc builds on major distros Jonathan Corbet
2025-08-21 19:43   ` 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=de23b35a770210950c609deaa32b98cb3673a53a.1755763127.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®