AlignSettingsSection

Align statements in *** Settings *** section to columns.

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

robotidy --transform AlignSettingsSection src
*** Settings ***
Library      SeleniumLibrary
Library   Mylibrary.py
Variables  variables.py
Test Timeout  1 min
    # this should be left aligned

Align up to columns

You can configure how many columns should be aligned to the longest token in given column. The remaining columns will use fixed length separator length --spacecount. By default only first two columns are aligned.

Example of how AlignSettingsSection transformer behaves with default configuration and multiple columns:

*** Settings ***
Library    CustomLibrary   WITH NAME  name
Library    ArgsedLibrary   ${1}  ${2}  ${3}

Documentation     Example using the space separated format.
...  and this documentation is multiline
...  where this line should go I wonder?

You can configure it to align three columns:

robotidy --configure AlignSettingsSection:up_to_column=3 src
*** Settings ***
Library    CustomLibrary   WITH NAME  name
Library    ArgsedLibrary   ${1}  ${2}  ${3}

Documentation     Example using the space separated format.
...  and this documentation is multiline
...  where this line should go I wonder?

To align all columns set up_to_column to 0.

Extra indent for keyword arguments

Arguments inside keywords in Suite Setup, Suite Teardown, Test Setup and Test Teardown are indented by additional argument_indent (default 4) spaces. You can configure the indent or disable it by setting argument_indent to 0.

*** Settings ***
Suite Setup         Start Session
...                     host=${IPADDRESS}
...                     user=${USERNAME}
...                     password=${PASSWORD}
Suite Teardown      Close Session

Fixed width of column

It’s possible to set fixed minimal width of column. To configure it use min_width parameter:

robotidy --configure AlignSettingsSection:min_width=30 src

This configuration respects up_to_column parameter but ignores argument_indent.

*** Settings ***
Library    CustomLibrary   WITH NAME  name
Library    ArgsedLibrary   ${1}  ${2}  ${3}

Documentation     Example using the space separated format.
...  and this documentation is multiline
...  where this line should go I wonder?

Select lines to transform

AlignSettingsSection does also support global formatting params startline and endline:

robotidy --startline 2 --endline 3 --configure AlignSettingsSection:up_to_column=3 src
*** Settings ***
Metadata  Version  2.0  # this should be not aligned
Metadata      More Info  For more information about *Robot Framework* see http://robotframework.org
Metadata     Executed At  {HOST}