diff --git a/docs/reference/syntax.md b/docs/reference/syntax.md index e454756646..06d7824527 100644 --- a/docs/reference/syntax.md +++ b/docs/reference/syntax.md @@ -622,16 +622,6 @@ A *slashy string* is enclosed by slashes instead of quotes: /no escape!/ ``` -Slashy strings can also span multiple lines: - -```nextflow -/ -Patterns in the code, -Symbols dance to match and find, -Logic unconfined. -/ -``` - :::{note} A slashy string cannot be empty because it would become a line comment. ::: diff --git a/docs/vscode.md b/docs/vscode.md index eb0d6d40eb..11c847ae29 100644 --- a/docs/vscode.md +++ b/docs/vscode.md @@ -230,38 +230,6 @@ if (aligner == 'bowtie2') { } ``` -**Slashy dollar strings** - -Groovy supports a wide variety of strings, including multi-line strings, dynamic strings, slashy strings, multi-line dynamic slashy strings, and more. - -The Nextflow language specification supports single- and double-quoted strings, multi-line strings, and slashy strings. Dynamic slashy strings are not supported: - -```groovy -def logo = /--cl-config 'custom_logo: "${multiqc_logo}"'/ -``` - -Use a double-quoted string instead: - -```nextflow -def logo = "--cl-config 'custom_logo: \"${multiqc_logo}\"'" -``` - -Slashy dollar strings are not supported: - -```groovy -$/ -echo "Hello world!" -/$ -``` - -Use a multi-line string instead: - -```nextflow -""" -echo "Hello world!" -""" -``` - **Implicit environment variables** 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 Type annotations and static type checking will be addressed in a future version of the Nextflow language specification. ::: +**Strings** + +Groovy supports a wide variety of strings, including multi-line strings, dynamic strings, slashy strings, multi-line dynamic slashy strings, and more. + +The Nextflow language specification supports single- and double-quoted strings, multi-line strings, and slashy strings. + +Slashy strings cannot be interpolated: + +```nextflow +def id = 'SRA001' +assert 'SRA001.fastq' ~= /${id}\.f(?:ast)?q/ +``` + +Use a double-quoted string instead: + +```nextflow +def id = 'SRA001' +assert 'SRA001.fastq' ~= "${id}\\.f(?:ast)?q" +``` + +Slashy strings cannot span multiple lines: + +```groovy +/ +Patterns in the code, +Symbols dance to match and find, +Logic unconfined. +/ +``` + +Use a multi-line string instead: + +```nextflow +""" +Patterns in the code, +Symbols dance to match and find, +Logic unconfined. +""" +``` + +Dollar slashy strings are not supported: + +```groovy +$/ +echo "Hello world!" +/$ +``` + +Use a multi-line string instead: + +```nextflow +""" +echo "Hello world!" +""" +``` + **Process env inputs/outputs** 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 ({ return 'large.config' else return '/dev/null' -})() +}()) ``` 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.