Skip to content

Commit 9aabe36

Browse files
authored
Make CodableContentSection.section property public (#1344)
* Make CodableContentSection.section public This allows other applications linking to Swift DocC to access this property. * Modernize how section property initializes its stored property using an init accessor
1 parent 758f91e commit 9aabe36

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import Foundation
1515
/// This allows decoding a ``RenderSection`` into its appropriate concrete type, based on the section's
1616
/// ``RenderSection/kind``.
1717
public struct CodableContentSection: Codable, Equatable {
18-
var section: any RenderSection {
18+
public var section: any RenderSection {
19+
@storageRestrictions(initializes: typeErasedSection)
20+
init(initialValue) {
21+
typeErasedSection = AnyRenderSection(initialValue)
22+
}
1923
get {
2024
typeErasedSection.value
2125
}
@@ -27,15 +31,13 @@ public struct CodableContentSection: Codable, Equatable {
2731

2832
/// Creates a codable content section from the given section.
2933
public init(_ section: any RenderSection) {
30-
self.typeErasedSection = AnyRenderSection(section)
3134
self.section = section
3235
}
3336

3437
public init(from decoder: any Decoder) throws {
3538
let container = try decoder.container(keyedBy: CodingKeys.self)
3639
let kind = try container.decode(RenderSectionKind.self, forKey: .kind)
3740

38-
self.typeErasedSection = AnyRenderSection(ContentRenderSection(kind: .content, content: []))
3941
switch kind {
4042
case .discussion:
4143
section = try ContentRenderSection(from: decoder)

0 commit comments

Comments
 (0)