Files
swift-cli-doc/Sources/CliDocCore/Nodes/StackConfiguration.swift
Michael Housh 875b1980e0
All checks were successful
CI / Run tests. (push) Successful in 58s
feat: Working on documentation
2024-12-09 09:35:17 -05:00

37 lines
921 B
Swift

// swiftlint:disable type_name
/// Represents the content of an ``HStack`` or a ``VStack``.
///
/// This is an internal convenience type, but needs to remain public
/// for protcol conformances to work properly.
public struct _StackConfiguration {
public let content: [any TextNode]
}
// swiftlint:enable type_name
/// A helper type that removes empty text nodes, and applies a separtor between
/// the array of text nodes.
///
@usableFromInline
struct AnySeparatableStackNode<Separator: TextNode>: TextNode {
@usableFromInline
let content: [any TextNode]
@usableFromInline
let separator: Separator
@usableFromInline
init(content: _StackConfiguration, separator: Separator) {
self.content = content.content
self.separator = separator
}
@usableFromInline
var body: some TextNode {
content.removingEmptys()
.map { $0.render() }
.joined(separator: separator.render())
}
}