Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
e786fab2 99ec67a9

+17 -6
+17 -6
tools/lib/python/kdoc/kdoc_yaml_file.py
··· 25 25 self.config = config 26 26 self.test_file = os.path.expanduser(yaml_file) 27 27 self.yaml_content = yaml_content 28 + self.test_names = set() 28 29 29 30 self.tests = [] 30 31 ··· 103 102 if not symbols: 104 103 return 105 104 106 - base_name = "test_" + fname.replace(".", "_").replace("/", "_") 107 105 expected_dict = {} 108 106 start_line=1 109 107 110 - for i in range(0, len(symbols)): 111 - arg = symbols[i] 112 - 108 + for arg in symbols: 113 109 source = arg.get("source", "") 114 110 115 111 if arg and "KdocItem" in self.yaml_content: ··· 118 120 119 121 expected_dict["kdoc_item"] = msg 120 122 123 + base_name = arg.name 124 + if not base_name: 125 + base_name = fname 126 + base_name = base_name.lower().replace(".", "_").replace("/", "_") 127 + 128 + 129 + # Don't add duplicated names 130 + i = 0 131 + name = base_name 132 + while name in self.test_names: 133 + i += 1 134 + name = f"{base_name}_{i:03d}" 135 + 136 + self.test_names.add(name) 137 + 121 138 for out_style in self.out_style: 122 139 if isinstance(out_style, ManFormat): 123 140 key = "man" ··· 140 127 key = "rst" 141 128 142 129 expected_dict[key]= out_style.output_symbols(fname, [arg]).strip() 143 - 144 - name = f"{base_name}_{i:03d}" 145 130 146 131 test = { 147 132 "name": name,