Skip to content

Commit a9e276f

Browse files
Remove beta tag from unavailable symbols. (#1121)
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 389d1f8 commit a9e276f

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
@@ -2101,6 +2101,19 @@ Document
21012101
// Verify task group link is not in beta because `iOS` does not have an introduced version
21022102
XCTAssertEqual((renderNode.references["doc://org.swift.docc.example/documentation/MyKit/MyClass"] as? TopicRenderReference)?.isBeta, false)
21032103
}
2104+
2105+
// Set all platforms as unconditionally unavailable and test that the symbol is not marked as beta.
2106+
do {
2107+
let (bundle, context, reference) = try makeTestBundle(currentPlatforms: [
2108+
"iOS": PlatformVersion(VersionTriplet(100, 0, 0), beta: true)
2109+
], referencePath: "/documentation/MyKit/MyClass")
2110+
let node = try context.entity(with: reference)
2111+
(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)])
2112+
let documentationContentRendered = DocumentationContentRenderer(documentationContext: context, bundle: bundle)
2113+
let isBeta = documentationContentRendered.isBeta(node)
2114+
// Verify that the symbol is not beta since it's unavailable in all the platforms.
2115+
XCTAssertFalse(isBeta)
2116+
}
21042117
}
21052118

21062119
func testRendersDeprecatedViolator() throws {

0 commit comments

Comments
 (0)