Skip to content

Commit a566ba5

Browse files
mchehabJonathan Corbet
authored andcommitted
scripts/lib/kdoc/kdoc_files.py: allow filtering output per fname
For kerneldoc Sphinx extension, it is useful to display parsed results only from a single file. Change the logic at KernelFiles.msg() to allow such usage. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/9f5c0ff2568f34532ca99465fb378241d831d39f.1744106242.git.mchehab+huawei@kernel.org
1 parent fc86294 commit a566ba5

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

scripts/lib/kdoc/kdoc_files.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def parse_file(self, fname):
9595
doc = KernelDoc(self.config, fname)
9696
doc.run()
9797

98-
return doc
98+
return doc.entries
9999

100100
def process_export_file(self, fname):
101101
"""
@@ -173,7 +173,7 @@ def __init__(self, verbose=False, out_style=None,
173173
# Initialize internal variables
174174

175175
self.config.errors = 0
176-
self.results = []
176+
self.results = {}
177177

178178
self.files = set()
179179
self.export_files = set()
@@ -189,13 +189,9 @@ def parse(self, file_list, export_file=None):
189189
# avoid reporting errors multiple times
190190

191191
for fname in glob.parse_files(file_list, self.file_not_found_cb):
192-
if fname in self.files:
193-
continue
194-
195-
res = self.parse_file(fname)
196-
197-
self.results.append((res.fname, res.entries))
198-
self.files.add(fname)
192+
if fname not in self.files:
193+
self.results[fname] = self.parse_file(fname)
194+
self.files.add(fname)
199195

200196
# If a list of export files was provided, parse EXPORT_SYMBOL*
201197
# from files that weren't fully parsed
@@ -226,7 +222,8 @@ def out_msg(self, fname, name, arg):
226222
return self.out_style.msg(fname, name, arg)
227223

228224
def msg(self, enable_lineno=False, export=False, internal=False,
229-
symbol=None, nosymbol=None, no_doc_sections=False):
225+
symbol=None, nosymbol=None, no_doc_sections=False,
226+
filenames=None):
230227
"""
231228
Interacts over the kernel-doc results and output messages,
232229
returning kernel-doc markups on each interaction
@@ -248,9 +245,12 @@ def msg(self, enable_lineno=False, export=False, internal=False,
248245
function_table, enable_lineno,
249246
no_doc_sections)
250247

251-
for fname, arg_tuple in self.results:
248+
if not filenames:
249+
filenames = sorted(self.results.keys())
250+
251+
for fname in filenames:
252252
msg = ""
253-
for name, arg in arg_tuple:
253+
for name, arg in self.results[fname]:
254254
msg += self.out_msg(fname, name, arg)
255255

256256
if msg is None:

0 commit comments

Comments
 (0)