Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ 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?

/// Declare a public initializer, to allow clients linking to Swift DocC to
/// create RenderContentMetadata values.
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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
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 there
// is a public initializer for RenderContentMetadata.
import SwiftDocC
import XCTest

class RenderContentMetadataInitializerTests: XCTestCase {
func testMetadataPublicInitializer() throws {
let metadata = RenderContentMetadata(
anchor: "anchor",
title: "title",
abstract: [],
deviceFrame: "device frame"
)

XCTAssertNotNil(metadata)
XCTAssertEqual("anchor", metadata.anchor)
XCTAssertEqual("title", metadata.title)
XCTAssertEqual([], metadata.abstract)
XCTAssertEqual("device frame", metadata.deviceFrame)
}
}