DiscardEmptySections#

Remove empty sections.

Transformer configuration

DiscardEmptySections is included in the default transformers, but it can be also run separately with:

robotidy --transform DiscardEmptySections src

You can also disable DiscardEmptySections:

robotidy --configure DiscardEmptySections:enabled=False src
*** Settings ***


*** Test Cases ***
Test
    [Documentation]  doc
    [Tags]  sometag
    Pass
    Keyword
    One More


*** Keywords ***
# This section is not considered empty.


*** Variables ***

*** Comments ***
robocop: disable=all
*** Test Cases ***
Test
    [Documentation]  doc
    [Tags]  sometag
    Pass
    Keyword
    One More


*** Keywords ***
# This section is not considered empty.


*** Comments ***
robocop: disable=all

Remove sections only with comments#

Sections are considered empty if there are only empty lines inside. You can remove sections with only comments by setting allow_only_comments parameter to False. *** Comments *** section with only comments is always considered as non-empty:

robotidy --configure DiscardEmptySection:allow_only_comments=True
*** Test Cases ***
Test
    [Documentation]  doc
    [Tags]  sometag
    Pass
    Keyword
    One More

*** Keywords ***
# This section is considered to be empty.

*** Comments ***
# robocop: disable=all
*** Test Cases ***
Test
    [Documentation]  doc
    [Tags]  sometag
    Pass
    Keyword
    One More

*** Comments ***
# robocop: disable=all

Skip formatting#

It is possible to use the following arguments to skip formatting of the code:

It is also possible to use disablers (Disablers) but skip option makes it easier to skip all instances of given type of the code.