From nobody Fri Oct 10 13:35:28 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 634C81EC014; Sat, 14 Jun 2025 08:56:18 +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=1749891378; cv=none; b=dJx0bPIhCzSSKqVD6iRHjQT0mg5uJhpesRToZ+w+meTp2cK+z+7v+WemthGbcIOykSCozQRAxCN/tnHBkzUBRRg1HQajk9b5J8hjDR8IBmim32U6Bv/zZFpZz8d0ImuuhvZuCxYfH3b/UohifOqroOEXsI+sFfr+M+l2sCzQ0Bo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749891378; c=relaxed/simple; bh=zjfj2Tm7h9LKUnhgzAVTuVnT8YUaP6pYYIdRhxmKFAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BJ5qaE24Q7sWn/t0PU3RvwbKi8wSAoxK8DnbS3/jBqB5t5VueTnYXmOsohw8heAc8Wi5wlGl6RLbUNscU881NvV+Jqy3CmmzlUyjEzPQapYuYkfTHXOU/KmS8mCIzo2moNsdWobLAHJcmSOmYtBAO33wX3acpervgWLCK49eZy8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XN8xx+lC; 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="XN8xx+lC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E578EC4CEF1; Sat, 14 Jun 2025 08:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749891378; bh=zjfj2Tm7h9LKUnhgzAVTuVnT8YUaP6pYYIdRhxmKFAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XN8xx+lChxGcgbZ/ztz2429Ca+3Vh91S/41P+iBhSYgUXxOCXNENr5YO36mz5p5Qr 5BWkw16tgrbiIUcPp7S13/Gl77VY9kk2ygbQN63bxhZFLidlPN/Oowf0EDBjQvaUvx +DOsNDt2bvoKH9r3H9OC9ng+uu6wNAzKctC2Lxp3xfWKlY27zGLQUUQtoErQSFTb4U Zqh9IQjyxvtwmnkya21jQ4Ic47BZLEiUNVkrVD+MPiRs3LrVclJlIdMLloniEKL7F0 i2qTV7k2UGBFK8PYLuWc3kN6SGblRv/qIHNWsRE08Cdqy8W7G/0GNwLlytCSyJkbdI 0TQD+6uNa2hOw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uQMgS-000000064at-0Rls; Sat, 14 Jun 2025 10:56:16 +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 v4 04/14] tools: ynl_gen_rst.py: make the index parser more generic Date: Sat, 14 Jun 2025 10:55:58 +0200 Message-ID: <3fb42a4aa79631d69041f6750dc0d55dd3067162.1749891128.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