diff --git a/Sources/SwiftDocC/Model/Rendering/Content/RenderContentMetadata.swift b/Sources/SwiftDocC/Model/Rendering/Content/RenderContentMetadata.swift index 90da0dbd36..657276a0a1 100644 --- a/Sources/SwiftDocC/Model/Rendering/Content/RenderContentMetadata.swift +++ b/Sources/SwiftDocC/Model/Rendering/Content/RenderContentMetadata.swift @@ -20,6 +20,19 @@ public struct RenderContentMetadata: Equatable, Codable { public var abstract: [RenderInlineContent]? /// An optional identifier for the device frame that should wrap this element. public var deviceFrame: String? + + /// Creates a new metadata value for a content element. + /// - Parameters: + /// - anchor: The named anchor of the content element. + /// - title: The customized title for the content element. + /// - abstract: The customized abstract for the content element. + /// - deviceFrame: The identifier for the device frame that should wrap the content element. + public init(anchor: String? = nil, title: String? = nil, abstract: [RenderInlineContent]? = nil, deviceFrame: String? = nil) { + self.anchor = anchor + self.title = title + self.abstract = abstract + self.deviceFrame = deviceFrame + } } extension RenderContentMetadata { diff --git a/Tests/SwiftDocCTests/PublicAPI/PublicAPITests.swift b/Tests/SwiftDocCTests/PublicAPI/PublicAPITests.swift new file mode 100644 index 0000000000..0da80607c9 --- /dev/null +++ b/Tests/SwiftDocCTests/PublicAPI/PublicAPITests.swift @@ -0,0 +1,27 @@ +/* + This source file is part of the Swift.org open source project + + Copyright (c) 2025 Apple Inc. and the Swift project authors + Licensed under Apache License v2.0 with Runtime Library Exception + + See https://swift.org/LICENSE.txt for license information + See https://swift.org/CONTRIBUTORS.txt for Swift project authors +*/ + +// Import SwiftDocC without the @testable annotation, so we can test +// whether various API are actually public. +import SwiftDocC + +import XCTest + +class PublicAPITests: XCTestCase { + + func testPublicRenderContentMetadataInitializer() throws { + let _ = RenderContentMetadata( + anchor: "anchor", + title: "title", + abstract: [], + deviceFrame: "device frame" + ) + } +}