22# SPDX-License-Identifier: GPL-2.0
33# Copyright(c) 2025: Mauro Carvalho Chehab <mchehab@kernel.org>.
44#
5- # pylint: disable=C0301,R0911,R0912,R0913,R0914,R0915,R0917
6-
7- # TODO: implement warning filtering
5+ # pylint: disable=C0301,R0902,R0911,R0912,R0913,R0914,R0915,R0917
86
97"""
108Implement output filters to print kernel-doc documentation.
5250
5351
5452class OutputFormat :
53+ """
54+ Base class for OutputFormat. If used as-is, it means that only
55+ warnings will be displayed.
56+ """
57+
5558 # output mode.
5659 OUTPUT_ALL = 0 # output all symbols and doc sections
5760 OUTPUT_INCLUDE = 1 # output only specified symbols
@@ -75,6 +78,10 @@ def __init__(self):
7578 self .data = ""
7679
7780 def set_config (self , config ):
81+ """
82+ Setup global config variables used by both parser and output.
83+ """
84+
7885 self .config = config
7986
8087 def set_filter (self , export , internal , symbol , nosymbol , function_table ,
@@ -117,6 +124,10 @@ def highlight_block(self, block):
117124 return block
118125
119126 def out_warnings (self , args ):
127+ """
128+ Output warnings for identifiers that will be displayed.
129+ """
130+
120131 warnings = args .get ('warnings' , [])
121132
122133 for warning , log_msg in warnings :
@@ -146,6 +157,11 @@ def check_doc(self, name, args):
146157 return False
147158
148159 def check_declaration (self , dtype , name , args ):
160+ """
161+ Checks if a declaration should be output or not based on the
162+ filtering criteria.
163+ """
164+
149165 if name in self .nosymbol :
150166 return False
151167
@@ -169,6 +185,10 @@ def check_declaration(self, dtype, name, args):
169185 return False
170186
171187 def msg (self , fname , name , args ):
188+ """
189+ Handles a single entry from kernel-doc parser
190+ """
191+
172192 self .data = ""
173193
174194 dtype = args .get ('type' , "" )
@@ -203,24 +223,25 @@ def msg(self, fname, name, args):
203223 return None
204224
205225 # Virtual methods to be overridden by inherited classes
226+ # At the base class, those do nothing.
206227 def out_doc (self , fname , name , args ):
207- pass
228+ """Outputs a DOC block"""
208229
209230 def out_function (self , fname , name , args ):
210- pass
231+ """Outputs a function"""
211232
212233 def out_enum (self , fname , name , args ):
213- pass
234+ """Outputs an enum"""
214235
215236 def out_typedef (self , fname , name , args ):
216- pass
237+ """Outputs a typedef"""
217238
218239 def out_struct (self , fname , name , args ):
219- pass
240+ """Outputs a struct"""
220241
221242
222243class RestFormat (OutputFormat ):
223- # """Consts and functions used by ReST output"""
244+ """Consts and functions used by ReST output"""
224245
225246 highlights = [
226247 (type_constant , r"``\1``" ),
@@ -265,6 +286,11 @@ def print_lineno(self, ln):
265286 self .data += f".. LINENO { ln } \n "
266287
267288 def output_highlight (self , args ):
289+ """
290+ Outputs a C symbol that may require being converted to ReST using
291+ the self.highlights variable
292+ """
293+
268294 input_text = args
269295 output = ""
270296 in_literal = False
@@ -579,6 +605,10 @@ def __init__(self):
579605 self .man_date = dt .strftime ("%B %Y" )
580606
581607 def output_highlight (self , block ):
608+ """
609+ Outputs a C symbol that may require being highlighted with
610+ self.highlights variable using troff syntax
611+ """
582612
583613 contents = self .highlight_block (block )
584614
@@ -601,7 +631,7 @@ def out_doc(self, fname, name, args):
601631 sections = args .get ('sections' , {})
602632
603633 if not self .check_doc (name , args ):
604- return
634+ return
605635
606636 self .data += f'.TH "{ module } " 9 "{ module } " "{ self .man_date } " "API Manual" LINUX' + "\n "
607637
0 commit comments