feat: Working on documentation
All checks were successful
CI / Run tests. (push) Successful in 58s

This commit is contained in:
2024-12-09 09:35:17 -05:00
parent 78a632c3e5
commit 875b1980e0
9 changed files with 100 additions and 8 deletions

View File

@@ -2,6 +2,23 @@
///
/// This allows you to group content together, which can optionally be
/// styled.
///
/// ### Example:
///
/// ```swift
/// let group = Group {
/// "My headline."
/// "\n"
/// "Some content".color(.green)
/// "\n"
/// "Foo Bar".italic()
/// }
///
/// print(group.render())
/// ```
///
/// ![Group example](group.png)
///
public struct Group<Content: TextNode>: TextNode {
@usableFromInline

View File

@@ -59,7 +59,7 @@ public extension HStack {
/// Style a ``HStack`` by creating a type that conforms to ``HStackStyle`` and use the
/// style by calling the ``HStack/style(_:)`` method on your instance.
///
public protocol HStackStyle: TextModifier where Content == StackConfiguration {}
public protocol HStackStyle: TextModifier where Content == _StackConfiguration {}
public extension HStackStyle where Self == HStackSeparatorStyle {
/// Apply the given separator on a ``HStack``.
@@ -88,7 +88,7 @@ public struct HStackSeparatorStyle: HStackStyle {
}
@inlinable
public func render(content: StackConfiguration) -> some TextNode {
public func render(content: _StackConfiguration) -> some TextNode {
AnySeparatableStackNode(content: content, separator: separator)
}
}

View File

@@ -1,10 +1,14 @@
// swiftlint:disable type_name
/// Represents the content of an ``HStack`` or a ``VStack``.
///
///
public struct StackConfiguration {
/// 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.
///
@@ -18,7 +22,7 @@ struct AnySeparatableStackNode<Separator: TextNode>: TextNode {
let separator: Separator
@usableFromInline
init(content: StackConfiguration, separator: Separator) {
init(content: _StackConfiguration, separator: Separator) {
self.content = content.content
self.separator = separator
}

View File

@@ -62,7 +62,7 @@ public extension VStack {
/// Style a ``VStack`` by creating a type that conforms to ``VStackStyle`` and use the
/// style by calling the ``VStack/style(_:)`` method on your instance.
///
public protocol VStackStyle: TextModifier where Content == StackConfiguration {}
public protocol VStackStyle: TextModifier where Content == _StackConfiguration {}
public extension VStackStyle where Self == VStackSeparatorStyle {
@@ -92,7 +92,7 @@ public struct VStackSeparatorStyle: VStackStyle {
}
@inlinable
public func render(content: StackConfiguration) -> some TextNode {
public func render(content: _StackConfiguration) -> some TextNode {
AnySeparatableStackNode(content: content, separator: separator)
}
}