@@ -23,7 +23,9 @@ import nextflow.script.ast.ProcessNode
2323import nextflow.script.ast.WorkflowNode
2424import nextflow.script.dsl.FeatureFlagDsl
2525import nextflow.script.dsl.ProcessDsl
26- import nextflow.script.types.Channel
26+ import nextflow.script.dsl.ScriptDsl
27+ import nextflow.script.namespaces.ChannelNamespace
28+ import nextflow.script.types.shim.Iterable
2729import org.codehaus.groovy.ast.ClassHelper
2830import org.codehaus.groovy.ast.ClassNode
2931import org.codehaus.groovy.ast.Parameter
@@ -40,6 +42,7 @@ class ASTNodeStringUtilsTest extends Specification {
4042 when :
4143 def classNode = Mock (ClassNode ) {
4244 isEnum() >> false
45+ isResolved() >> true
4346 getNameWithoutPackage() >> ' Channel'
4447 }
4548 then :
@@ -48,6 +51,7 @@ class ASTNodeStringUtilsTest extends Specification {
4851 when :
4952 def enumNode = Mock (ClassNode ) {
5053 isEnum() >> true
54+ isResolved() >> true
5155 getNameWithoutPackage() >> ' SequenceTypes'
5256 getGroovydoc() >> Mock (Groovydoc ) {
5357 isPresent() >> true
@@ -160,16 +164,36 @@ class ASTNodeStringUtilsTest extends Specification {
160164
161165 def ' should get the label and docs for a built-in function' () {
162166 when :
163- def node = new ClassNode (Channel . class). getDeclaredMethods(' of ' ). first()
167+ def node = new ClassNode (ScriptDsl . class). getDeclaredMethods(' env ' ). first()
164168 then :
165- ASTNodeStringUtils . getLabel(node) == ' Channel.of(arg0...: E) -> Channel<E>'
169+ ASTNodeStringUtils . getLabel(node) == ' env(arg0: String) -> String'
170+ ASTNodeStringUtils . getDocumentation(node) == '''
171+ Get the value of an environment variable from the launch environment.
172+ ''' . stripIndent(true ). trim()
173+ }
174+
175+ def ' should get the label and docs for a namespace function' () {
176+ when :
177+ def node = new ClassNode (ChannelNamespace . class). getDeclaredMethods(' of' ). first()
178+ then :
179+ ASTNodeStringUtils . getLabel(node) == ' of(arg0...: E) -> Channel<E>'
166180 ASTNodeStringUtils . getDocumentation(node) == '''
167181 Create a channel that emits each argument.
168182
169183 [Read more](https://nextflow.io/docs/latest/reference/channel.html#of)
170184 ''' . stripIndent(true ). trim()
171185 }
172186
187+ def ' should get the label and docs for a method' () {
188+ when :
189+ def node = new ClassNode (Iterable . class). getDeclaredMethods(' collect' ). first()
190+ then :
191+ ASTNodeStringUtils . getLabel(node) == ' Iterable collect(arg0: (E) -> R) -> Iterable<R>'
192+ ASTNodeStringUtils . getDocumentation(node) == '''
193+ Returns a new iterable with each element transformed by the given closure.
194+ ''' . stripIndent(true ). trim()
195+ }
196+
173197 def ' should get the label and docs for a process directive' () {
174198 when :
175199 def node = new ClassNode (ProcessDsl.DirectiveDsl . class). getDeclaredMethods(' executor' ). first()
0 commit comments