Closed gohierf closed 6 months ago
It is not just for [Documentation]
, I get the same error with a "configurable user timeout", where the timeout of a keyword is provided as an argument of this keyword.
Robotidy sets the [Timeout]
before the [Arguments]
entry, which results in both "variable not found" error and "argument not used" warning from RobotCode.
Configurable Timeout Before
[Documentation] Timeout entry before Arguments entry (enforced by Robotidy)
[Timeout] ${timeout}
[Arguments] ${arg} ${timeout}
Log ${arg}
Configurable Timeout After
[Documentation] Timeout entry after Arguments entry
[Arguments] ${arg} ${timeout}
[Timeout] ${timeout}
Log ${arg}
ok, after some investigation, this is a little bit tricky, arguments from keywords in documentation and tags are not resolved by robotframework, here are only global or suite variables allowed.
All other settings are resolved at runtime after parsing, need to think how to implement this.
in the meantime, do you know the robotidy OrderSettings setting, maybe that helps.
Regardless of the bug, I'm not sure if the default order of robotidy is a good order, I think the arguments should be at the top and then the documentation and all other things. In Python you also have to specify the name of the function and the parameters first and only then comes the documentation
Thanks for the tip, setting arguments
before any other keyword settings did fix my issue.
[tool.robotidy]
configure = [
"OrderSettings : keyword_before = arguments,documentation,tags,timeout"
]
I personally like documentation first, then arguments, but it may be personal preference :) I will think about it, but I will for sure update the default order for timeout to avoid such issues in the future (and put some explanation in the documentation why exactly I chose that order).
Describe the bug A "variable not found warning" is shown when referring to a keyword argument in the keyword's documentation.
To Reproduce It only appears if
[Arguments]
is defined after[Documentation]
(which is by default enforced by tidy).Expected behavior Even if the
[Arguments]
is defined after[Documentation]
, the variable should be shown as "(argument) | ${regular argument}". Which is the case when[Arguments]
is defined before[Documentation]
.Screenshots/ Videos
Desktop (please complete the following information):