55# pylint: disable=C0301,R0902,R0911,R0912,R0913,R0914,R0915,R0917
66
77"""
8- Implement output filters to print kernel-doc documentation.
8+ Classes to implement output filters to print kernel-doc documentation.
99
10- The implementation uses a virtual base class ( OutputFormat) which
10+ The implementation uses a virtual base class `` OutputFormat``. It
1111contains dispatches to virtual methods, and some code to filter
1212out output messages.
1313
1414The actual implementation is done on one separate class per each type
15- of output. Currently, there are output classes for ReST and man/troff.
15+ of output, e.g. ``RestFormat`` and ``ManFormat`` classes.
16+
17+ Currently, there are output classes for ReST and man/troff.
1618"""
1719
1820import os
@@ -54,16 +56,19 @@ class OutputFormat:
5456 """
5557
5658 # output mode.
57- OUTPUT_ALL = 0 # output all symbols and doc sections
58- OUTPUT_INCLUDE = 1 # output only specified symbols
59- OUTPUT_EXPORTED = 2 # output exported symbols
60- OUTPUT_INTERNAL = 3 # output non-exported symbols
59+ OUTPUT_ALL = 0 #: Output all symbols and doc sections.
60+ OUTPUT_INCLUDE = 1 #: Output only specified symbols.
61+ OUTPUT_EXPORTED = 2 #: Output exported symbols.
62+ OUTPUT_INTERNAL = 3 #: Output non-exported symbols.
6163
62- # Virtual member to be overridden at the inherited classes
64+ #: Highlights to be used in ReST format.
6365 highlights = []
6466
67+ #: Blank line character.
68+ blankline = ""
69+
6570 def __init__ (self ):
66- """Declare internal vars and set mode to OUTPUT_ALL"""
71+ """Declare internal vars and set mode to `` OUTPUT_ALL``. """
6772
6873 self .out_mode = self .OUTPUT_ALL
6974 self .enable_lineno = None
@@ -128,7 +133,7 @@ def out_warnings(self, args):
128133 self .config .warning (log_msg )
129134
130135 def check_doc (self , name , args ):
131- """Check if DOC should be output"""
136+ """Check if DOC should be output. """
132137
133138 if self .no_doc_sections :
134139 return False
@@ -177,7 +182,7 @@ def check_declaration(self, dtype, name, args):
177182
178183 def msg (self , fname , name , args ):
179184 """
180- Handles a single entry from kernel-doc parser
185+ Handles a single entry from kernel-doc parser.
181186 """
182187
183188 self .data = ""
@@ -220,30 +225,31 @@ def msg(self, fname, name, args):
220225 # Virtual methods to be overridden by inherited classes
221226 # At the base class, those do nothing.
222227 def set_symbols (self , symbols ):
223- """Get a list of all symbols from kernel_doc"""
228+ """Get a list of all symbols from kernel_doc. """
224229
225230 def out_doc (self , fname , name , args ):
226- """Outputs a DOC block"""
231+ """Outputs a DOC block. """
227232
228233 def out_function (self , fname , name , args ):
229- """Outputs a function"""
234+ """Outputs a function. """
230235
231236 def out_enum (self , fname , name , args ):
232- """Outputs an enum"""
237+ """Outputs an enum. """
233238
234239 def out_var (self , fname , name , args ):
235- """Outputs a variable"""
240+ """Outputs a variable. """
236241
237242 def out_typedef (self , fname , name , args ):
238- """Outputs a typedef"""
243+ """Outputs a typedef. """
239244
240245 def out_struct (self , fname , name , args ):
241- """Outputs a struct"""
246+ """Outputs a struct. """
242247
243248
244249class RestFormat (OutputFormat ):
245- """Consts and functions used by ReST output"""
250+ """Consts and functions used by ReST output. """
246251
252+ #: Highlights to be used in ReST format
247253 highlights = [
248254 (type_constant , r"``\1``" ),
249255 (type_constant2 , r"``\1``" ),
@@ -263,9 +269,13 @@ class RestFormat(OutputFormat):
263269 (type_fallback , r":c:type:`\1`" ),
264270 (type_param_ref , r"**\1\2**" )
265271 ]
272+
266273 blankline = "\n "
267274
275+ #: Sphinx literal block regex.
268276 sphinx_literal = KernRe (r'^[^.].*::$' , cache = False )
277+
278+ #: Sphinx code block regex.
269279 sphinx_cblock = KernRe (r'^\.\.\ +code-block::' , cache = False )
270280
271281 def __init__ (self ):
@@ -280,7 +290,7 @@ def __init__(self):
280290 self .lineprefix = ""
281291
282292 def print_lineno (self , ln ):
283- """Outputs a line number"""
293+ """Outputs a line number. """
284294
285295 if self .enable_lineno and ln is not None :
286296 ln += 1
@@ -289,7 +299,7 @@ def print_lineno(self, ln):
289299 def output_highlight (self , args ):
290300 """
291301 Outputs a C symbol that may require being converted to ReST using
292- the self.highlights variable
302+ the self.highlights variable.
293303 """
294304
295305 input_text = args
@@ -570,7 +580,7 @@ def out_struct(self, fname, name, args):
570580
571581
572582class ManFormat (OutputFormat ):
573- """Consts and functions used by man pages output"""
583+ """Consts and functions used by man pages output. """
574584
575585 highlights = (
576586 (type_constant , r"\1" ),
@@ -587,6 +597,7 @@ class ManFormat(OutputFormat):
587597 )
588598 blankline = ""
589599
600+ #: Allowed timestamp formats.
590601 date_formats = [
591602 "%a %b %d %H:%M:%S %Z %Y" ,
592603 "%a %b %d %H:%M:%S %Y" ,
@@ -653,7 +664,7 @@ def set_symbols(self, symbols):
653664 self .symbols = symbols
654665
655666 def out_tail (self , fname , name , args ):
656- """Adds a tail for all man pages"""
667+ """Adds a tail for all man pages. """
657668
658669 # SEE ALSO section
659670 self .data += f'.SH "SEE ALSO"' + "\n .PP\n "
@@ -689,7 +700,7 @@ def msg(self, fname, name, args):
689700 def output_highlight (self , block ):
690701 """
691702 Outputs a C symbol that may require being highlighted with
692- self.highlights variable using troff syntax
703+ self.highlights variable using troff syntax.
693704 """
694705
695706 contents = self .highlight_block (block )
@@ -720,7 +731,6 @@ def out_doc(self, fname, name, args):
720731 self .output_highlight (text )
721732
722733 def out_function (self , fname , name , args ):
723- """output function in man"""
724734
725735 out_name = self .arg_name (args , name )
726736
0 commit comments