[PATCH v2 08/12] scripts: netlink_yml_parser.py: improve index.rst generation

Mauro Carvalho Chehab <[email protected]>
Newsgroups dev.linux.lists.lkmm,dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <ea083e487f1b0fcc95f117d269cba8b70e12c566.1749723671.git.mchehab+huawei@kernel.org>
Handle both .yaml and .rst extensions. This way, one can generate
an index file inside the sources with:

	tools/net/ynl/pyynl/ynl_gen_rst.py -x  -v -o Documentation/netlink/specs/index.rst

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
---
 scripts/lib/netlink_yml_parser.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/netlink_yml_parser.py b/scripts/lib/netlink_yml_parser.py
index 65981b86875f..3ba28a9a4338 100755
--- a/scripts/lib/netlink_yml_parser.py
+++ b/scripts/lib/netlink_yml_parser.py
@@ -372,15 +372,20 @@ class NetlinkYamlParser:
         lines.append(self.fmt.rst_toctree(1))
 
         index_fname = os.path.basename(output)
-        base, ext = os.path.splitext(index_fname)
 
         if not index_dir:
             index_dir = os.path.dirname(output)
 
-        logging.debug(f"Looking for {ext} files in %s", index_dir)
+        exts = [ ".yaml", ".rst" ]
+
+        logging.debug(f"Looking for files in %s", index_dir)
         for filename in sorted(os.listdir(index_dir)):
-            if not filename.endswith(ext) or filename == index_fname:
+            if filename == index_fname:
                 continue
+
+            for ext in exts:
+                if not filename.endswith(ext):
+                    continue
             base, ext = os.path.splitext(filename)
             lines.append(f"   {base}\n")
 
-- 
2.49.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.