diff --git a/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift b/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift index 21fc7aa5f..a7d918453 100644 --- a/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift +++ b/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift @@ -125,11 +125,7 @@ struct RenderNodeVariantView: NavigatorIndexableRenderNodeRepresentation { extension NavigatorIndexableRenderMetadataRepresentation { var isBeta: Bool { - guard let platforms, !platforms.isEmpty else { - return false - } - - return platforms.allSatisfy { $0.isBeta == true } + return platforms?.isBeta ?? false } } diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index e4a737fa7..88c381615 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -590,11 +590,7 @@ extension OutOfProcessReferenceResolver { /// A value that indicates whether this symbol is under development and likely to change. var isBeta: Bool { - guard let platforms, !platforms.isEmpty else { - return false - } - - return platforms.allSatisfy { $0.isBeta == true } + return platforms?.isBeta ?? false } /// Creates a new resolved information value with all its values. diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift index 0d145a597..f4db774fb 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/ExternalPathHierarchyResolver.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2024 Apple Inc. and the Swift project authors + Copyright (c) 2023-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 @@ -184,11 +184,7 @@ private extension Sequence { private extension LinkDestinationSummary { /// A value that indicates whether this symbol is under development and likely to change. var isBeta: Bool { - guard let platforms, !platforms.isEmpty else { - return false - } - - return platforms.allSatisfy { $0.isBeta == true } + return platforms?.isBeta ?? false } /// Create a topic render render reference for this link summary and its content variants. diff --git a/Sources/SwiftDocC/Model/Rendering/Symbol/AvailabilityRenderMetadataItem.swift b/Sources/SwiftDocC/Model/Rendering/Symbol/AvailabilityRenderMetadataItem.swift index 8d8a137fa..a185ff8a3 100644 --- a/Sources/SwiftDocC/Model/Rendering/Symbol/AvailabilityRenderMetadataItem.swift +++ b/Sources/SwiftDocC/Model/Rendering/Symbol/AvailabilityRenderMetadataItem.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + Copyright (c) 2021-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 @@ -163,3 +163,27 @@ public struct AvailabilityRenderItem: Codable, Hashable, Equatable { self.isBeta = isBeta } } + +extension Array where Array.Element == AvailabilityRenderItem { + /// Determines whether all platforms in the array are in beta. + /// + /// This property returns `true` if every availability item in the array has its `isBeta` property set to `true`, + /// indicating that the symbol is introduced in a beta version across all platforms. If the array is empty, + /// this property returns `false`, as an item with no platform availability information is not considered + /// to be in beta. + /// + /// This computed property centralizes the beta determination logic to avoid code duplication across multiple + /// components that need to check whether a symbol is in beta based on its platform availability. + /// `NavigatorIndexableRenderMetadataRepresentation`, `OutOfProcessReferenceResolver.ResolvedInformation` and `LinkDestinationSummary` all store an array of ``AvailabilityRenderItem`` and need to determine beta status based on platform availability, + /// so it is convenient to de-duplicate the shared logic here. + /// + /// - Returns: `true` if all platforms in the array are in beta; `false` if the array is empty or if any + /// platform is not in beta. + var isBeta: Bool { + guard !self.isEmpty else { + return false + } + + return self.allSatisfy { $0.isBeta == true } + } +}