feat: Working on node builder

This commit is contained in:
2024-12-01 15:25:42 -05:00
parent ff49b12198
commit 96a1fac07b
11 changed files with 357 additions and 21 deletions

26
Sources/CliDoc/Node.swift Normal file
View File

@@ -0,0 +1,26 @@
// swiftlint:disable type_name
public protocol Node: NodeRepresentable {
associatedtype _Body: NodeRepresentable
typealias Body = _Body
@NodeBuilder
var body: Body { get }
}
// swiftlint:enable type_name
public extension Node {
@inlinable
func render() -> String {
body.render()
}
}
public struct Foo: Node {
public init() {}
public var body: some NodeRepresentable {
LabeledContent("Foo") { "Bar" }
}
}