Skip to content

Commit 413fe13

Browse files
authored
Merge pull request #546 from fwcd/fix-node-documentation
Fix documentation for syntax collections in `SwiftSyntaxBuilderGeneration`
2 parents a7dbca2 + a4e5a8a commit 413fe13

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Sources/SwiftSyntaxBuilderGeneration/SyntaxBuildableNode.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ extension Node {
2424
}
2525

2626
/// If documentation exists for this node, return it as a single-line string.
27-
/// Otherwise return an empty string.
27+
/// Otherwise return an empty string or a description of collection if this
28+
/// node is a syntax collection.
2829
var documentation: String {
29-
guard let description = description,
30-
!description.isEmpty else {
31-
return ""
32-
}
33-
if isSyntaxCollection {
34-
return "`\(syntaxKind)` represents a collection of `\(description)`"
30+
let description = self.description ?? ""
31+
if description.isEmpty && isSyntaxCollection {
32+
return "`\(syntaxKind)` represents a collection of `\(collectionElementType.buildableBaseName)`"
3533
} else {
3634
return flattened(indentedDocumentation: description)
3735
}

0 commit comments

Comments
 (0)