@@ -21,12 +21,15 @@ class NormalizeSeparators(ModelTransformer):
2121 You can decide which sections should be transformed by configuring
2222 ``sections = comments,settings,variables,keywords,testcases`` param.
2323
24+ To not format documentation configure ``skip_documentation`` to ``True``.
25+
2426 Supports global formatting params: ``--startline`` and ``--endline``.
2527 """
2628
27- def __init__ (self , sections : str = None ):
29+ def __init__ (self , sections : str = None , skip_documentation : bool = False ):
2830 self .indent = 0
2931 self .sections = self .parse_sections (sections )
32+ self .skip_documentation = skip_documentation
3033 self .is_inline = False
3134
3235 def parse_sections (self , sections ):
@@ -129,12 +132,18 @@ def visit_If(self, node):
129132 self .is_inline = False
130133 return node
131134
135+ def visit_Documentation (self , doc ): # noqa
136+ if self .skip_documentation :
137+ has_pipes = doc .tokens [0 ].value .startswith ("|" )
138+ return self ._handle_spaces (doc , has_pipes , only_indent = True )
139+ return self .visit_Statement (doc )
140+
132141 @skip_if_disabled
133142 def visit_Statement (self , statement ): # noqa
134143 has_pipes = statement .tokens [0 ].value .startswith ("|" )
135144 return self ._handle_spaces (statement , has_pipes )
136145
137- def _handle_spaces (self , statement , has_pipes ):
146+ def _handle_spaces (self , statement , has_pipes , only_indent = False ):
138147 new_tokens = []
139148 for line in statement .lines :
140149 prev_sep = False
@@ -145,7 +154,7 @@ def _handle_spaces(self, statement, has_pipes):
145154 prev_sep = True
146155 if index == 0 :
147156 token .value = self .formatting_config .indent * self .indent
148- else :
157+ elif not only_indent :
149158 token .value = self .formatting_config .separator
150159 else :
151160 prev_sep = False
0 commit comments