Skip to content

Commit f85f514

Browse files
Remove beta tag from unavailable symbols. (#1121) (#1122)
Symbols that are unconditionally unavailable in all the platforms should not be tagged as beta. Before this fix the `isBeta` logic was returning true for symbols that were unavailable in all the platforms. Now is filtering out these platforms before assesing if it's beta or not. rdar://140415995
1 parent cfaf3ca commit f85f514

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,12 @@ public class DocumentationContentRenderer {
214214
guard let symbol = node.semantic as? Symbol,
215215
let currentPlatforms = documentationContext.configuration.externalMetadata.currentPlatforms,
216216
!currentPlatforms.isEmpty,
217-
let symbolAvailability = symbol.availability?.availability,
217+
let symbolAvailability = symbol.availability?.availability.filter({ !$0.isUnconditionallyUnavailable }), // symbol that's unconditionally unavailable in all the platforms can't be in beta.
218218
!symbolAvailability.isEmpty // A symbol without availability items can't be in beta.
219219
else { return false }
220220

221221
// Verify that if current platforms are in beta, they match the introduced version of the symbol
222222
for availability in symbolAvailability {
223-
// If not available on this platform, skip to next platform.
224-
guard !availability.isUnconditionallyUnavailable else {
225-
continue
226-
}
227223

228224
// If the symbol doesn't have an introduced version for one of those platforms, we don't consider it "in beta".
229225
guard let introduced = availability.introducedVersion else {

Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,19 @@ Document
20882088
// Verify task group link is not in beta because `iOS` does not have an introduced version
20892089
XCTAssertEqual((renderNode.references["doc://org.swift.docc.example/documentation/MyKit/MyClass"] as? TopicRenderReference)?.isBeta, false)
20902090
}
2091+
2092+
// Set all platforms as unconditionally unavailable and test that the symbol is not marked as beta.
2093+
do {
2094+
let (bundle, context, reference) = try makeTestBundle(currentPlatforms: [
2095+
"iOS": PlatformVersion(VersionTriplet(100, 0, 0), beta: true)
2096+
], referencePath: "/documentation/MyKit/MyClass")
2097+
let node = try context.entity(with: reference)
2098+
(node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: [.init(domain: SymbolGraph.Symbol.Availability.Domain(rawValue: "iOS"), introducedVersion: nil, deprecatedVersion: nil, obsoletedVersion: nil, message: nil, renamed: nil, isUnconditionallyDeprecated: false, isUnconditionallyUnavailable: true, willEventuallyBeDeprecated: false)])
2099+
let documentationContentRendered = DocumentationContentRenderer(documentationContext: context, bundle: bundle)
2100+
let isBeta = documentationContentRendered.isBeta(node)
2101+
// Verify that the symbol is not beta since it's unavailable in all the platforms.
2102+
XCTAssertFalse(isBeta)
2103+
}
20912104
}
20922105

20932106
func testRendersDeprecatedViolator() throws {

0 commit comments

Comments
 (0)