From nobody Fri Oct 10 14:04:19 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D033BE65; Tue, 17 Jun 2025 08:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750147352; cv=none; b=K0P76FyplsKOQNZGO+7MeNuYgwqATt1KAiHGlbWnBU8hr70WLdKtSY6GMGKJZQr2lqmuuk4bKJW32oPRrKgj1gbUOuY95ckEY5VlGiDxXsdmEbgaEdQtGvI7jVS38ZxR+H3QYHO+t3b3CXCQtrCvN+q4SFFZ16jiHFsrSx3ArPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750147352; c=relaxed/simple; bh=TQlUV26hUMBvQLESC8JIjjk9jVydpjRjIcMxZ7u1zZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VuCkY209uh0QGfONN5tg2+023STnHU32wriIwPYRRIRXoOILyYs4AHZg/lYFtpdeBVE0y+VY2yho+6fZkgvwCaDPBedgpMXRuBURDKSFPc1keZRcQtiYG1kzdwdhAe5sZF/CQyI8X3vCkYPcsV8FWovsc9lTt9ehQuUUBZ+Hyxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t5vr77Nm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t5vr77Nm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC6D0C4CEEE; Tue, 17 Jun 2025 08:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750147351; bh=TQlUV26hUMBvQLESC8JIjjk9jVydpjRjIcMxZ7u1zZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5vr77Nm3T85lDkDCkTWO06PqpqrIayAe2sYq08oix+8bAeLj3xlY80wifnqiSFU9 qQwrTt4hZWLAnCrcX7JpUMQ+hADJOyEO9/fvErp2iinJaE4bO0HqbcHO5GzB7urHkE SyrleLbLpOXNxo+d23Y+d1RQMG42HS5kKA44I6G3agFivmQCEJ8dXjNFezStacqseK aSxd6wwDm1cXVtJ54cYElwpsc1YPwwjZO3lsWdsF3pLiJICbegvlV4gDFjg+KPf8F1 PQUFVD95zqZ4HCupLUP7IuWGq3QkY4vOlNw01toHzQ9YSUQ6p/r1EUQFJb86aYqbCf Omkib/K37qkHg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uRRH3-00000001vcq-3jNb; Tue, 17 Jun 2025 10:02:29 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Breno Leitao" , "David S. Miller" , "Donald Hunter" , "Eric Dumazet" , "Ignacio Encinas Rubio" , "Jan Stancek" , "Marco Elver" , "Mauro Carvalho Chehab" , "Paolo Abeni" , "Ruben Wauters" , "Shuah Khan" , joel@joelfernandes.org, linux-kernel-mentees@lists.linux.dev, linux-kernel@vger.kernel.org, lkmm@lists.linux.dev, netdev@vger.kernel.org, peterz@infradead.org, stern@rowland.harvard.edu Subject: [PATCH v5 01/15] docs: conf.py: properly handle include and exclude patterns Date: Tue, 17 Jun 2025 10:01:58 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" When one does: make SPHINXDIRS=3D"foo" htmldocs All patterns would be relative to Documentation/foo, which causes the include/exclude patterns like: include_patterns =3D [ ... f'foo/*.{ext}', ] to break. This is not what it is expected. Address it by adding a logic to dynamically adjust the pattern when SPHINXDIRS is used. That allows adding parsers for other file types. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Donald Hunter --- Documentation/conf.py | 52 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/Documentation/conf.py b/Documentation/conf.py index 12de52a2b17e..e887c1b786a4 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -17,6 +17,54 @@ import os import sphinx import shutil =20 +# Location of Documentation/ directory +doctree =3D os.path.abspath('.') + +# List of patterns that don't contain directory names, in glob format. +include_patterns =3D ['**.rst'] +exclude_patterns =3D [] + +# List of patterns that contain directory names in glob format. +dyn_include_patterns =3D [] +dyn_exclude_patterns =3D ['output'] + +# Properly handle include/exclude patterns +# ---------------------------------------- + +def setup(app): + """ + 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 + converting them to a relative patch. + + As Sphinx doesn't include any patterns outside SOURCEDIR, we should + exclude relative patterns that start with "../". + """ + + sourcedir =3D app.srcdir # full path to the source directory + builddir =3D os.environ.get("BUILDDIR") + + # setup include_patterns dynamically + for p in dyn_include_patterns: + full =3D os.path.join(doctree, p) + + rel_path =3D os.path.relpath(full, start =3D app.srcdir) + if rel_path.startswith("../"): + continue + + app.config.include_patterns.append(rel_path) + + # setup exclude_patterns dynamically + for p in dyn_exclude_patterns: + full =3D os.path.join(doctree, p) + + rel_path =3D os.path.relpath(full, start =3D app.srcdir) + if rel_path.startswith("../"): + continue + + app.config.exclude_patterns.append(rel_path) + # helper # ------ =20 @@ -219,10 +267,6 @@ language =3D 'en' # Else, today_fmt is used as the format for a strftime call. #today_fmt =3D '%B %d, %Y' =20 -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns =3D ['output'] - # The reST default role (used for this markup: `text`) to use for all # documents. #default_role =3D None --=20 2.49.0