@@ -20,8 +20,11 @@ class DocumentationStyleBear(DocBaseClass, LocalBear):
2020 CAN_DETECT = {'Documentation' }
2121 CAN_FIX = {'Documentation' }
2222
23- def process_documentation (self , parsed , allow_missing_func_desc : str = False ,
24- indent_size : int = 4 ):
23+ def process_documentation (self ,
24+ parsed ,
25+ allow_missing_func_desc : str = False ,
26+ indent_size : int = 4 ,
27+ expand_one_liners : str = False ):
2528 """
2629 This fixes the parsed documentation comment.
2730
@@ -32,6 +35,8 @@ def process_documentation(self, parsed, allow_missing_func_desc: str=False,
3235 descriptions, allowing functions to start with params.
3336 :param indent_size:
3437 Number of spaces per indentation level.
38+ :param expand_one_liners:
39+ When set ``True`` this will expand one liner docstrings.
3540 :return:
3641 A tuple of fixed parsed documentation comment and warning_desc.
3742 """
@@ -54,9 +59,13 @@ def process_documentation(self, parsed, allow_missing_func_desc: str=False,
5459 # one empty line shall follow main description (except it's empty
5560 # or no annotations follow).
5661 if main_description .desc .strip () != '' :
57- main_description = main_description ._replace (
58- desc = '\n ' + main_description .desc .strip () + '\n ' *
59- (1 if len (parsed ) == 1 else 2 ))
62+ if not expand_one_liners and len (parsed ) == 1 :
63+ main_description = main_description ._replace (
64+ desc = main_description .desc .strip ())
65+ else :
66+ main_description = main_description ._replace (
67+ desc = '\n ' + main_description .desc .strip () + '\n ' *
68+ (1 if len (parsed ) == 1 else 2 ))
6069
6170 new_metadata = [main_description ]
6271 for m in metadata :
@@ -87,7 +96,7 @@ def process_documentation(self, parsed, allow_missing_func_desc: str=False,
8796
8897 def run (self , filename , file , language : str ,
8998 docstyle : str = 'default' , allow_missing_func_desc : str = False ,
90- indent_size : int = 4 ):
99+ indent_size : int = 4 , expand_one_liners : str = False ):
91100 """
92101 Checks for certain in-code documentation styles.
93102
@@ -110,13 +119,16 @@ def run(self, filename, file, language: str,
110119 functions with missing descriptions, allowing
111120 functions to start with params.
112121 :param indent_size: Number of spaces per indentation level.
122+ :param expand_one_liners: When set ``True`` this will expand one liner
123+ docstrings.
113124 """
114125
115126 for doc_comment in self .extract (file , language , docstyle ):
116127 parsed = doc_comment .parse ()
117128
118129 (new_metadata , warning_desc ) = self .process_documentation (
119- parsed , allow_missing_func_desc , indent_size )
130+ parsed , allow_missing_func_desc , indent_size ,
131+ expand_one_liners )
120132
121133 new_comment = DocumentationComment .from_metadata (
122134 new_metadata , doc_comment .docstyle_definition ,
0 commit comments