[RFC v2 22/38] scripts/get_abi.pl: add support to parse ABI README file

From: Mauro Carvalho Chehab
Date: Mon Jan 27 2025 - 19:11:08 EST


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@xxxxxxxxxx>
---
scripts/get_abi.py | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/scripts/get_abi.py b/scripts/get_abi.py
index 6d7fa8fbca34..3cde278b8e4c 100755
--- a/scripts/get_abi.py
+++ b/scripts/get_abi.py
@@ -276,6 +276,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"""

@@ -322,6 +332,10 @@ class AbiParser:
if self.debug & DEBUG_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
@@ -357,9 +371,6 @@ class AbiParser:

basename = os.path.basename(name)

- if basename == "README":
- continue
-
if basename.startswith("."):
continue

@@ -462,8 +473,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 = ""

--
2.48.1