From nobody Fri Oct 10 14:04:18 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 3D07A8528E; 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=VhNbvn3X6Yw2K/I58h+e0LyE7VVBs82w872PvIdB4H9iRdCH2sptpp0W8NNJ5QBGk13BzUH4LPXrBAsS4Act/9+oIluK97NyAlZ7wamWWxegG8+qZNHkBviAkK3sJf9TFvlvcYBR6OzKJFfsKwXWZGuyxIwyy53jIY8/aUAt6ZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750147352; c=relaxed/simple; bh=zjfj2Tm7h9LKUnhgzAVTuVnT8YUaP6pYYIdRhxmKFAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VcGYxhPQVcRjb/AX3C2wQeWjHagu927qWb7bYheZNEI45GKboj64FDn5wxz6ULQ2qmqezSjNrnxflpFJ2K6+0cPJa1pMP4QTqVWn+cNog3UG4UqWum2CkbfuNJzH2gu4X7iR57dJ62cIfaaB5HFYTYRVyYaJcCm0T66V0yvU1WA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tf5PXJHb; 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="Tf5PXJHb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF1C8C4CEE3; 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=zjfj2Tm7h9LKUnhgzAVTuVnT8YUaP6pYYIdRhxmKFAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tf5PXJHbyqoDMJUjhFzgNd2QGPUruuk54hW8GfaiY4HU/qL1o+lPlFJ4ixNuynI+I LgDzId9V2N2/TBnov9FlC+ewqG+seIJu21fNhZQalb2Z+c38L5lWALHfK40MHkUrkz rjdD5mtoXusfnPP5ksGOkgtAOH8vtnQ7UX34RX34vdPdBjX4ZQXW+MtlLGjq2iUh94 ScnqiaNRn8Kw/zchQ1QNIbu4pnRHYxj6AYirHgpT+InZ9lflxBH1ksL5Xnge+LabWM y0CkkOO+WxmJxLa+mla504XWl2rQtvPJZXMQ7ITvVL3uIEG7xsquNK4YdcDPpqywRV SpN7aT8dbEagg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uRRH4-00000001vd6-01hy; Tue, 17 Jun 2025 10:02:30 +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" , Jakub Kicinski , Simon Horman , 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 05/15] tools: ynl_gen_rst.py: make the index parser more generic Date: Tue, 17 Jun 2025 10:02:02 +0200 Message-ID: <1cd8b28bfe159677b8a8b1228b04ba2919c8aee8.1750146719.git.mchehab+huawei@kernel.org> 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" It is not a good practice to store build-generated files inside $(srctree), as one may be using O=3D and even have the Kernel on a read-only directory. Change the YAML generation for netlink files to allow it to parse data based on the source or on the object tree. Signed-off-by: Mauro Carvalho Chehab --- tools/net/ynl/pyynl/ynl_gen_rst.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/net/ynl/pyynl/ynl_gen_rst.py b/tools/net/ynl/pyynl/ynl_g= en_rst.py index 7bfb8ceeeefc..b1e5acafb998 100755 --- a/tools/net/ynl/pyynl/ynl_gen_rst.py +++ b/tools/net/ynl/pyynl/ynl_gen_rst.py @@ -365,6 +365,7 @@ def parse_arguments() -> argparse.Namespace: =20 parser.add_argument("-v", "--verbose", action=3D"store_true") parser.add_argument("-o", "--output", help=3D"Output file name") + parser.add_argument("-d", "--input_dir", help=3D"YAML input directory") =20 # Index and input are mutually exclusive group =3D parser.add_mutually_exclusive_group() @@ -405,11 +406,14 @@ def write_to_rstfile(content: str, filename: str) -> = None: """Write the generated content into an RST file""" logging.debug("Saving RST file to %s", filename) =20 + dir =3D os.path.dirname(filename) + os.makedirs(dir, exist_ok=3DTrue) + with open(filename, "w", encoding=3D"utf-8") as rst_file: rst_file.write(content) =20 =20 -def generate_main_index_rst(output: str) -> None: +def generate_main_index_rst(output: str, index_dir: str) -> None: """Generate the `networking_spec/index` content and write to the file"= "" lines =3D [] =20 @@ -418,12 +422,18 @@ def generate_main_index_rst(output: str) -> None: lines.append(rst_title("Netlink Family Specifications")) lines.append(rst_toctree(1)) =20 - index_dir =3D os.path.dirname(output) - logging.debug("Looking for .rst files in %s", index_dir) + index_fname =3D os.path.basename(output) + base, ext =3D os.path.splitext(index_fname) + + if not index_dir: + index_dir =3D os.path.dirname(output) + + logging.debug(f"Looking for {ext} files in %s", index_dir) for filename in sorted(os.listdir(index_dir)): - if not filename.endswith(".rst") or filename =3D=3D "index.rst": + if not filename.endswith(ext) or filename =3D=3D index_fname: continue - lines.append(f" {filename.replace('.rst', '')}\n") + base, ext =3D os.path.splitext(filename) + lines.append(f" {base}\n") =20 logging.debug("Writing an index file at %s", output) write_to_rstfile("".join(lines), output) @@ -447,7 +457,7 @@ def main() -> None: =20 if args.index: # Generate the index RST file - generate_main_index_rst(args.output) + generate_main_index_rst(args.output, args.input_dir) =20 =20 if __name__ =3D=3D "__main__": --=20 2.49.0