diff options
| author | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2026-03-23 10:10:51 +0100 |
|---|---|---|
| committer | Jonathan Corbet <corbet@lwn.net> | 2026-03-25 13:36:46 -0600 |
| commit | e786fab2cfcc9ab65adf35d2eab4ca94abe1955f (patch) | |
| tree | 704f4e96e15077d03dd2ccf4aa813fcc9862ea4a /tools/lib/python/kdoc | |
| parent | 99ec67a9984fdf38c7ed78695aeb1b99cfee5b50 (diff) | |
docs: kdoc_yaml_file: use a better name for the tests
Instead of always using a name with a number on it, use
the name of the object directly whenever possible.
When the name is already used, append a number prefix at
the end.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <d1c4cd94547d843af0debf9e317e006d55d705f1.1774256269.git.mchehab+huawei@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc')
| -rw-r--r-- | tools/lib/python/kdoc/kdoc_yaml_file.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tools/lib/python/kdoc/kdoc_yaml_file.py b/tools/lib/python/kdoc/kdoc_yaml_file.py index 1e2ae7c59d70..0be020d50df0 100644 --- a/tools/lib/python/kdoc/kdoc_yaml_file.py +++ b/tools/lib/python/kdoc/kdoc_yaml_file.py @@ -25,6 +25,7 @@ class KDocTestFile(): self.config = config self.test_file = os.path.expanduser(yaml_file) self.yaml_content = yaml_content + self.test_names = set() self.tests = [] @@ -102,13 +103,10 @@ class KDocTestFile(): if not symbols: return - base_name = "test_" + fname.replace(".", "_").replace("/", "_") expected_dict = {} start_line=1 - for i in range(0, len(symbols)): - arg = symbols[i] - + for arg in symbols: source = arg.get("source", "") if arg and "KdocItem" in self.yaml_content: @@ -120,6 +118,21 @@ class KDocTestFile(): expected_dict["kdoc_item"] = msg + base_name = arg.name + if not base_name: + base_name = fname + base_name = base_name.lower().replace(".", "_").replace("/", "_") + + + # Don't add duplicated names + i = 0 + name = base_name + while name in self.test_names: + i += 1 + name = f"{base_name}_{i:03d}" + + self.test_names.add(name) + for out_style in self.out_style: if isinstance(out_style, ManFormat): key = "man" @@ -128,8 +141,6 @@ class KDocTestFile(): expected_dict[key]= out_style.output_symbols(fname, [arg]).strip() - name = f"{base_name}_{i:03d}" - test = { "name": name, "description": f"{fname} line {arg.declaration_start_line}", |
