Skip to content

Commit d084299

Browse files
authored
Add section about include addParams to syntax guide (#5946) [ci skip]
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent c733b37 commit d084299

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

docs/module.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ As a best practice, parameters should be used in the entry workflow and passed t
107107
A module can define parameters using the same syntax as a Nextflow workflow script:
108108

109109
```nextflow
110-
params.foo = 'Hello'
111-
params.bar = 'world!'
110+
params.message = 'Hello'
111+
params.target = 'world!'
112112
113113
def sayHello() {
114-
println "$params.foo $params.bar"
114+
println "$params.message $params.target"
115115
}
116116
```
117117

118118
When including a module, the module will first use parameters from the including context. For example:
119119

120120
```nextflow
121-
params.foo = 'Hola'
122-
params.bar = 'Mundo'
121+
params.message = 'Hola'
122+
params.target = 'Mundo'
123123
124124
include { sayHello } from './some/module'
125125
@@ -145,10 +145,10 @@ It is best to define all pipeline parameters *before* any `include` statements.
145145
The `addParams` option can be used to pass parameters to the module without adding them to the including scope.
146146

147147
```nextflow
148-
params.foo = 'Hola'
149-
params.bar = 'Mundo'
148+
params.message = 'Hola'
149+
params.target = 'Mundo'
150150
151-
include { sayHello } from './some/module' addParams(foo: 'Ciao')
151+
include { sayHello } from './some/module' addParams(message: 'Ciao')
152152
153153
workflow {
154154
sayHello()
@@ -164,10 +164,10 @@ Ciao Mundo
164164
Alternatively, the `params` option can be used to pass parameters to module without adding them to the including scope, *and* without inheriting any parameters from the including scope.
165165

166166
```nextflow
167-
params.foo = 'Hola'
168-
params.bar = 'Mundo'
167+
params.message = 'Hola'
168+
params.target = 'Mundo'
169169
170-
include { sayHello } from './some/module' params(foo: 'Ciao')
170+
include { sayHello } from './some/module' params(message: 'Ciao')
171171
172172
workflow {
173173
sayHello()

docs/updating-syntax.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,47 @@ println "PWD = ${env('PWD')}"
236236

237237
The following patterns are still supported but have been restricted. That is, some syntax variants have been removed.
238238

239+
<h4>Include declarations</h4>
240+
241+
In Nextflow DSL2, include declarations can have an `addParams` or `params` clause as described in {ref}`module-params`:
242+
243+
```nextflow
244+
params.message = 'Hola'
245+
params.target = 'Mundo'
246+
247+
include { sayHello } from './some/module' addParams(message: 'Ciao')
248+
249+
workflow {
250+
sayHello()
251+
}
252+
```
253+
254+
In the strict syntax, these clauses are no longer supported. Params should be passed to workflows, processes, and functions as explicit inputs:
255+
256+
```nextflow
257+
include { sayHello } from './some/module'
258+
259+
params.message = 'Hola'
260+
params.target = 'Mundo'
261+
262+
workflow {
263+
sayHello('Ciao', params.target)
264+
}
265+
```
266+
267+
Where the `sayHello` workflow is defined as follows:
268+
269+
```nextflow
270+
workflow sayHello {
271+
take:
272+
message
273+
target
274+
275+
main:
276+
// ...
277+
}
278+
```
279+
239280
<h4>Variable declarations</h4>
240281

241282
In Groovy, variables can be declared in many different ways:

0 commit comments

Comments
 (0)