Skip to content

Commit b0cd551

Browse files
committed
Enhance documentation of splitting long variables in Variables.
Fixes robotframework#3870.
1 parent 5c2b0f5 commit b0cd551

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

doc/userguide/src/CreatingTestData/TestDataSyntax.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,12 @@ as well `suite metadata`__. With them split values are automatically
486486
`joined together with the newline character`__ to ease creating multiline
487487
values.
488488

489+
The `...` syntax allows also splitting variables in the `Variable section`_.
490+
When long scalar variables (e.g. `${STRING}`) are split to multiple rows,
491+
the final value is got by concatenating the rows together. The separator is
492+
a space by default, but that can be changed by starting the value with
493+
`SEPARATOR=<sep>`.
494+
489495
Splitting lines is illustrated in the following two examples containing
490496
exactly same data without and with splitting.
491497

@@ -502,15 +508,17 @@ __ `Newlines in test data`_
502508
Default Tags default tag 1 default tag 2 default tag 3 default tag 4 default tag 5
503509

504510
*** Variable ***
511+
${STRING} This is a long string. It has multiple sentences. It does not have newlines.
512+
${MULTILINE} This is a long multiline string.\nThis is the second line.\nThis is the third and the last line.
505513
@{LIST} this list is quite long and items in it can also be long
514+
&{DICT} first=This value is pretty long. second=This value is even longer. It has two sentences.
506515

507516
*** Test Cases ***
508517
Example
509518
[Tags] you probably do not have this many tags in real life
510519
Do X first argument second argument third argument fourth argument fifth argument sixth argument
511520
${var} = Get X first argument passed to this keyword is pretty long second argument passed to this keyword is long too
512521

513-
514522
.. sourcecode:: robotframework
515523

516524
*** Settings ***
@@ -522,8 +530,17 @@ __ `Newlines in test data`_
522530
... default tag 4 default tag 5
523531

524532
*** Variable ***
533+
${STRING} This is a long string.
534+
... It has multiple sentences.
535+
... It does not have newlines.
536+
${MULTILINE} SEPARATOR=\n
537+
... This is a long multiline string.
538+
... This is the second line.
539+
... This is the third and the last line.
525540
@{LIST} this list is quite long and
526541
... items in it can also be long
542+
&{DICT} first=This value is pretty long.
543+
... second=This value is even longer. It has two sentences.
527544

528545
*** Test Cases ***
529546
Example

doc/userguide/src/CreatingTestData/Variables.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,19 @@ variables slightly more explicit.
510510
${NAME} = Robot Framework
511511
${VERSION} = 2.0
512512

513-
If a scalar variable has a long value, it can be split to multiple columns and
514-
rows__. By default cells are catenated together using a space, but this
515-
can be changed by having `SEPARATOR=<sep>` in the first cell.
513+
If a scalar variable has a long value, it can be `split into multiple rows`__
514+
by using the `...` syntax. By default rows are concatenated together using
515+
a space, but this can be changed by having `SEPARATOR=<sep>` as the first item.
516516

517517
.. sourcecode:: robotframework
518518

519519
*** Variables ***
520-
${EXAMPLE} This value is joined together with a space
521-
${MULTILINE} SEPARATOR=\n First line
522-
... Second line Third line
520+
${EXAMPLE} This value is joined
521+
... together with a space.
522+
${MULTILINE} SEPARATOR=\n
523+
... First line.
524+
... Second line.
525+
... Third line.
523526

524527
__ `Dividing data to several rows`_
525528

0 commit comments

Comments
 (0)