From 2a9c6c5d33854092fe53556f45d6a9d3e7789725 Mon Sep 17 00:00:00 2001 From: Maya Epps Date: Mon, 10 Nov 2025 15:42:48 -0800 Subject: [PATCH 1/2] Make CodableContentSection.section public This allows other applications linking to Swift DocC to access this property. --- .../Model/Rendering/RenderNode/CodableContentSection.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift b/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift index 6358e9b309..4bfff66b95 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift @@ -15,7 +15,7 @@ import Foundation /// This allows decoding a ``RenderSection`` into its appropriate concrete type, based on the section's /// ``RenderSection/kind``. public struct CodableContentSection: Codable, Equatable { - var section: any RenderSection { + public var section: any RenderSection { get { typeErasedSection.value } From 8d7fcf57e36c1bed2bf515033024d95e2ee95879 Mon Sep 17 00:00:00 2001 From: Maya Epps Date: Tue, 11 Nov 2025 17:38:45 -0800 Subject: [PATCH 2/2] Modernize how section property initializes its stored property using an init accessor --- .../Model/Rendering/RenderNode/CodableContentSection.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift b/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift index 4bfff66b95..44b11c4f57 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNode/CodableContentSection.swift @@ -16,6 +16,10 @@ import Foundation /// ``RenderSection/kind``. public struct CodableContentSection: Codable, Equatable { public var section: any RenderSection { + @storageRestrictions(initializes: typeErasedSection) + init(initialValue) { + typeErasedSection = AnyRenderSection(initialValue) + } get { typeErasedSection.value } @@ -27,7 +31,6 @@ public struct CodableContentSection: Codable, Equatable { /// Creates a codable content section from the given section. public init(_ section: any RenderSection) { - self.typeErasedSection = AnyRenderSection(section) self.section = section } @@ -35,7 +38,6 @@ public struct CodableContentSection: Codable, Equatable { let container = try decoder.container(keyedBy: CodingKeys.self) let kind = try container.decode(RenderSectionKind.self, forKey: .kind) - self.typeErasedSection = AnyRenderSection(ContentRenderSection(kind: .content, content: [])) switch kind { case .discussion: section = try ContentRenderSection(from: decoder)