Skip to content

Commit 308d5a5

Browse files
authored
Update syntax docs (#5542)
Signed-off-by: Ben Sherman <[email protected]>
1 parent 9248c04 commit 308d5a5

File tree

2 files changed

+57
-43
lines changed

2 files changed

+57
-43
lines changed

docs/reference/syntax.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -622,16 +622,6 @@ A *slashy string* is enclosed by slashes instead of quotes:
622622
/no escape!/
623623
```
624624

625-
Slashy strings can also span multiple lines:
626-
627-
```nextflow
628-
/
629-
Patterns in the code,
630-
Symbols dance to match and find,
631-
Logic unconfined.
632-
/
633-
```
634-
635625
:::{note}
636626
A slashy string cannot be empty because it would become a line comment.
637627
:::

docs/vscode.md

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -230,38 +230,6 @@ if (aligner == 'bowtie2') {
230230
}
231231
```
232232

233-
**Slashy dollar strings**
234-
235-
Groovy supports a wide variety of strings, including multi-line strings, dynamic strings, slashy strings, multi-line dynamic slashy strings, and more.
236-
237-
The Nextflow language specification supports single- and double-quoted strings, multi-line strings, and slashy strings. Dynamic slashy strings are not supported:
238-
239-
```groovy
240-
def logo = /--cl-config 'custom_logo: "${multiqc_logo}"'/
241-
```
242-
243-
Use a double-quoted string instead:
244-
245-
```nextflow
246-
def logo = "--cl-config 'custom_logo: \"${multiqc_logo}\"'"
247-
```
248-
249-
Slashy dollar strings are not supported:
250-
251-
```groovy
252-
$/
253-
echo "Hello world!"
254-
/$
255-
```
256-
257-
Use a multi-line string instead:
258-
259-
```nextflow
260-
"""
261-
echo "Hello world!"
262-
"""
263-
```
264-
265233
**Implicit environment variables**
266234

267235
In Nextflow DSL1 and DSL2, you can reference environment variables directly in strings:
@@ -334,6 +302,62 @@ To ease the migration of existing scripts, the language server only reports warn
334302
Type annotations and static type checking will be addressed in a future version of the Nextflow language specification.
335303
:::
336304

305+
**Strings**
306+
307+
Groovy supports a wide variety of strings, including multi-line strings, dynamic strings, slashy strings, multi-line dynamic slashy strings, and more.
308+
309+
The Nextflow language specification supports single- and double-quoted strings, multi-line strings, and slashy strings.
310+
311+
Slashy strings cannot be interpolated:
312+
313+
```nextflow
314+
def id = 'SRA001'
315+
assert 'SRA001.fastq' ~= /${id}\.f(?:ast)?q/
316+
```
317+
318+
Use a double-quoted string instead:
319+
320+
```nextflow
321+
def id = 'SRA001'
322+
assert 'SRA001.fastq' ~= "${id}\\.f(?:ast)?q"
323+
```
324+
325+
Slashy strings cannot span multiple lines:
326+
327+
```groovy
328+
/
329+
Patterns in the code,
330+
Symbols dance to match and find,
331+
Logic unconfined.
332+
/
333+
```
334+
335+
Use a multi-line string instead:
336+
337+
```nextflow
338+
"""
339+
Patterns in the code,
340+
Symbols dance to match and find,
341+
Logic unconfined.
342+
"""
343+
```
344+
345+
Dollar slashy strings are not supported:
346+
347+
```groovy
348+
$/
349+
echo "Hello world!"
350+
/$
351+
```
352+
353+
Use a multi-line string instead:
354+
355+
```nextflow
356+
"""
357+
echo "Hello world!"
358+
"""
359+
```
360+
337361
**Process env inputs/outputs**
338362

339363
In Nextflow DSL1 and DSL2, the name of a process `env` input/output can be specified with or without quotes:
@@ -481,7 +505,7 @@ includeConfig ({
481505
return 'large.config'
482506
else
483507
return '/dev/null'
484-
})()
508+
}())
485509
```
486510

487511
The include source is a closure that is immediately invoked. It includes a different config file based on the return value of the closure. Including `/dev/null` is equivalent to including nothing.

0 commit comments

Comments
 (0)