summaryrefslogtreecommitdiff
path: root/tools/lib/python/abi/abi_parser.py
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-02-09 20:53:18 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-02-09 20:53:18 -0800
commit72c395024dac5e215136cbff793455f065603b06 (patch)
tree4c7bb2eaab08e2e827607effdedcb42f808e496c /tools/lib/python/abi/abi_parser.py
parent0c61526621ec1916527d6f6226d8a466340cca22 (diff)
parent0a83293322fde69f1fb4722bd3c79c2d52eef436 (diff)
Merge tag 'docs-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/docs/linux
Pull documentation updates from Jonathan Corbet: "A slightly calmer cycle for docs this time around, though there is still a fair amount going on, including: - Some signs of life on the long-moribund Japanese translation - Documentation on policies around the use of generative tools for patch submissions, and a separate document intended for consumption by generative tools - The completion of the move of the documentation tools to tools/docs. For now we're leaving a /scripts/kernel-doc symlink behind to avoid breaking scripts - Ongoing build-system work includes the incorporation of documentation in Python code, better support for documenting variables, and lots of improvements and fixes - Automatic linking of man-page references -- cat(1), for example -- to the online pages in the HTML build ...and the usual array of typo fixes and such" * tag 'docs-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/docs/linux: (107 commits) doc: development-process: add notice on testing tools: sphinx-build-wrapper: improve its help message docs: sphinx-build-wrapper: allow -v override -q docs: kdoc: Fix pdfdocs build for tools docs: ja_JP: process: translate 'Obtain a current source tree' docs: fix 're-use' -> 'reuse' in documentation docs: ioctl-number: fix a typo in ioctl-number.rst docs: filesystems: ensure proc pid substitutable is complete docs: automarkup.py: Skip common English words as C identifiers Documentation: use a source-read extension for the index link boilerplate docs: parse_features: make documentation more consistent docs: add parse_features module documentation docs: jobserver: do some documentation improvements docs: add jobserver module documentation docs: kabi: helpers: add documentation for each "enum" value docs: kabi: helpers: add helper for debug bits 7 and 8 docs: kabi: system_symbols: end docstring phrases with a dot docs: python: abi_regex: do some improvements at documentation docs: python: abi_parser: do some improvements at documentation docs: add kabi modules documentation ...
Diffstat (limited to 'tools/lib/python/abi/abi_parser.py')
-rw-r--r--tools/lib/python/abi/abi_parser.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/tools/lib/python/abi/abi_parser.py b/tools/lib/python/abi/abi_parser.py
index 9b8db70067ef..d7bb20ef3acc 100644
--- a/tools/lib/python/abi/abi_parser.py
+++ b/tools/lib/python/abi/abi_parser.py
@@ -21,14 +21,17 @@ from abi.helpers import AbiDebug, ABI_DIR
class AbiParser:
- """Main class to parse ABI files"""
+ """Main class to parse ABI files."""
+ #: Valid tags at Documentation/ABI.
TAGS = r"(what|where|date|kernelversion|contact|description|users)"
+
+ #: ABI elements that will auto-generate cross-references.
XREF = r"(?:^|\s|\()(\/(?:sys|config|proc|dev|kvd)\/[^,.:;\)\s]+)(?:[,.:;\)\s]|\Z)"
def __init__(self, directory, logger=None,
enable_lineno=False, show_warnings=True, debug=0):
- """Stores arguments for the class and initialize class vars"""
+ """Stores arguments for the class and initialize class vars."""
self.directory = directory
self.enable_lineno = enable_lineno
@@ -65,7 +68,7 @@ class AbiParser:
self.re_xref_node = re.compile(self.XREF)
def warn(self, fdata, msg, extra=None):
- """Displays a parse error if warning is enabled"""
+ """Displays a parse error if warning is enabled."""
if not self.show_warnings:
return
@@ -77,7 +80,7 @@ class AbiParser:
self.log.warning(msg)
def add_symbol(self, what, fname, ln=None, xref=None):
- """Create a reference table describing where each 'what' is located"""
+ """Create a reference table describing where each 'what' is located."""
if what not in self.what_symbols:
self.what_symbols[what] = {"file": {}}
@@ -92,7 +95,7 @@ class AbiParser:
self.what_symbols[what]["xref"] = xref
def _parse_line(self, fdata, line):
- """Parse a single line of an ABI file"""
+ """Parse a single line of an ABI file."""
new_what = False
new_tag = False
@@ -264,7 +267,7 @@ class AbiParser:
self.warn(fdata, "Unexpected content", line)
def parse_readme(self, nametag, fname):
- """Parse ABI README file"""
+ """Parse ABI README file."""
nametag["what"] = ["Introduction"]
nametag["path"] = "README"
@@ -282,7 +285,7 @@ class AbiParser:
nametag["description"] += line
def parse_file(self, fname, path, basename):
- """Parse a single file"""
+ """Parse a single file."""
ref = f"abi_file_{path}_{basename}"
ref = self.re_unprintable.sub("_", ref).strip("_")
@@ -348,7 +351,7 @@ class AbiParser:
self.add_symbol(what=w, fname=fname, xref=fdata.key)
def _parse_abi(self, root=None):
- """Internal function to parse documentation ABI recursively"""
+ """Internal function to parse documentation ABI recursively."""
if not root:
root = self.directory
@@ -377,7 +380,7 @@ class AbiParser:
self.parse_file(name, path, basename)
def parse_abi(self, root=None):
- """Parse documentation ABI"""
+ """Parse documentation ABI."""
self._parse_abi(root)
@@ -385,7 +388,7 @@ class AbiParser:
self.log.debug(pformat(self.data))
def desc_txt(self, desc):
- """Print description as found inside ABI files"""
+ """Print description as found inside ABI files."""
desc = desc.strip(" \t\n")
@@ -393,7 +396,7 @@ class AbiParser:
def xref(self, fname):
"""
- Converts a Documentation/ABI + basename into a ReST cross-reference
+ Converts a Documentation/ABI + basename into a ReST cross-reference.
"""
xref = self.file_refs.get(fname)
@@ -403,7 +406,7 @@ class AbiParser:
return xref
def desc_rst(self, desc):
- """Enrich ReST output by creating cross-references"""
+ """Enrich ReST output by creating cross-references."""
# Remove title markups from the description
# Having titles inside ABI files will only work if extra
@@ -459,7 +462,7 @@ class AbiParser:
def doc(self, output_in_txt=False, show_symbols=True, show_file=True,
filter_path=None):
- """Print ABI at stdout"""
+ """Print ABI at stdout."""
part = None
for key, v in sorted(self.data.items(),
@@ -549,7 +552,7 @@ class AbiParser:
yield (msg, file_ref[0][0], ln)
def check_issues(self):
- """Warn about duplicated ABI entries"""
+ """Warn about duplicated ABI entries."""
for what, v in self.what_symbols.items():
files = v.get("file")
@@ -575,7 +578,7 @@ class AbiParser:
self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f))
def search_symbols(self, expr):
- """ Searches for ABI symbols """
+ """ Searches for ABI symbols."""
regex = re.compile(expr, re.I)