Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update syntax docs #5542

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions docs/reference/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
:::
Expand Down
90 changes: 57 additions & 33 deletions docs/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't said to keep slashy string (with interpolation) and deprecate dollar slash strings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither are supported. I am looking into slashy strings here but until I can get it to work, they are effectively not supported

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should consider a lack in the lang server, but i'd keep in the lang reference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dynamic slashy strings are not mentioned in the language reference. The effort to support them (nextflow-io/language-server#51) is purely exploratory. There is no guarantee that we can support it or that it would be wise to do so. Meanwhile, a regular dynamic string can be used by simply replacing \ with \\.

I will add it in the future if I feel confident that we can support it.

```

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:
Expand Down Expand Up @@ -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.
Expand Down