Files
swift-cli-doc/Sources/CliDocCore/Nodes/StackConfiguration.swift
Michael Housh 78a632c3e5
All checks were successful
CI / Run tests. (push) Successful in 52s
feat: Adds more documentation and examples.
2024-12-08 18:27:31 -05:00

33 lines
745 B
Swift

/// Represents the content of an ``HStack`` or a ``VStack``.
///
///
public struct StackConfiguration {
public let content: [any TextNode]
}
/// 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())
}
}