Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove beta tag from unavailable symbols. #1121

Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -214,16 +214,12 @@ public class DocumentationContentRenderer {
guard let symbol = node.semantic as? Symbol,
let currentPlatforms = documentationContext.configuration.externalMetadata.currentPlatforms,
!currentPlatforms.isEmpty,
let symbolAvailability = symbol.availability?.availability,
let symbolAvailability = symbol.availability?.availability.filter({ !$0.isUnconditionallyUnavailable }), // symbol that's unconditionally unavailable in all the platforms can't be in beta.
!symbolAvailability.isEmpty // A symbol without availability items can't be in beta.
else { return false }

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

// If the symbol doesn't have an introduced version for one of those platforms, we don't consider it "in beta".
guard let introduced = availability.introducedVersion else {
Expand Down
13 changes: 13 additions & 0 deletions Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2101,6 +2101,19 @@ Document
// Verify task group link is not in beta because `iOS` does not have an introduced version
XCTAssertEqual((renderNode.references["doc://org.swift.docc.example/documentation/MyKit/MyClass"] as? TopicRenderReference)?.isBeta, false)
}

// Set all platforms as unconditionally unavailable and test that the symbol is not marked as beta.
do {
let (bundle, context, reference) = try makeTestBundle(currentPlatforms: [
"iOS": PlatformVersion(VersionTriplet(100, 0, 0), beta: true)
], referencePath: "/documentation/MyKit/MyClass")
let node = try context.entity(with: reference)
(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)])
let documentationContentRendered = DocumentationContentRenderer(documentationContext: context, bundle: bundle)
let isBeta = documentationContentRendered.isBeta(node)
// Verify that the symbol is not beta since it's unavailable in all the platforms.
XCTAssertFalse(isBeta)
}
}

func testRendersDeprecatedViolator() throws {
Expand Down