]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scripts/get_abi.pl: add support to parse ABI README file
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 10 Feb 2025 10:18:08 +0000 (11:18 +0100)
committerJonathan Corbet <corbet@lwn.net>
Mon, 10 Feb 2025 18:19:57 +0000 (11:19 -0700)
The Documentation/ABI/README file is currently outside the
documentation tree. Yet, it may still provide some useful
information. Add it to the documentation parsing.

As a plus, this avoids a warning when detecting missing
cross-references.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/f1285dedfe4d0eb0f0af34f6a68bee6fde36dd7d.1739182025.git.mchehab+huawei@kernel.org
scripts/lib/abi/abi_parser.py

index b20d5c9d920e0147dbacf50b40b76d6a1fffe8c2..6fac461d794ce45c1a3bcf938ae1deb8f619795e 100644 (file)
@@ -263,6 +263,16 @@ class AbiParser:
         if content:
             self.warn(fdata, "Unexpected content", line)
 
+    def parse_readme(self, nametag, fname):
+        """Parse ABI README file"""
+
+        with open(fname, "r", encoding="utf8", errors="backslashreplace") as fp:
+            nametag["description"] = "```\n"
+            for line in fp:
+                nametag["description"] += "  " + line
+
+            nametag["description"] += "```\n"
+
     def parse_file(self, fname, path, basename):
         """Parse a single file"""
 
@@ -309,6 +319,10 @@ class AbiParser:
         if self.debug & AbiDebug.WHAT_OPEN:
             self.log.debug("Opening file %s", fname)
 
+        if basename == "README":
+            self.parse_readme(fdata.nametag, fname)
+            return
+
         with open(fname, "r", encoding="utf8", errors="backslashreplace") as fp:
             for line in fp:
                 fdata.ln += 1
@@ -344,9 +358,6 @@ class AbiParser:
 
                 basename = os.path.basename(name)
 
-                if basename == "README":
-                    continue
-
                 if basename.startswith("."):
                     continue
 
@@ -448,8 +459,12 @@ class AbiParser:
                     continue
 
             if filter_path:
-                if v.get("path") != filter_path:
-                    continue
+                if filter_path == "README":
+                    if not names[0].endswith("README"):
+                        continue
+                else:
+                    if v.get("path") != filter_path:
+                        continue
 
             msg = ""