@@ -1913,19 +1913,24 @@ Document
19131913 }
19141914
19151915 func testRendersBetaViolators( ) throws {
1916- func makeTestBundle( currentPlatforms: [ String : PlatformVersion ] ? , file: StaticString = #file, line: UInt = #line) throws -> ( DocumentationBundle , DocumentationContext , ResolvedTopicReference ) {
1916+ func makeTestBundle( currentPlatforms: [ String : PlatformVersion ] ? , file: StaticString = #file, line: UInt = #line, referencePath : String ) throws -> ( DocumentationBundle , DocumentationContext , ResolvedTopicReference ) {
19171917 var configuration = DocumentationContext . Configuration ( )
1918+ // Add missing platforms if their fallback platform is present.
1919+ var currentPlatforms = currentPlatforms ?? [ : ]
1920+ for (platform, fallbackPlatform) in DefaultAvailability . fallbackPlatforms where currentPlatforms [ platform. displayName] == nil {
1921+ currentPlatforms [ platform. displayName] = currentPlatforms [ fallbackPlatform. displayName]
1922+ }
19181923 configuration. externalMetadata. currentPlatforms = currentPlatforms
19191924
19201925 let ( _, bundle, context) = try testBundleAndContext ( named: " TestBundle " , configuration: configuration)
19211926
1922- let reference = ResolvedTopicReference ( bundleIdentifier: bundle. identifier, path: " /documentation/MyKit/MyClass " , sourceLanguage: . swift)
1927+ let reference = ResolvedTopicReference ( bundleIdentifier: bundle. identifier, path: referencePath , sourceLanguage: . swift)
19231928 return ( bundle, context, reference)
19241929 }
19251930
19261931 // Not a beta platform
19271932 do {
1928- let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: nil )
1933+ let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: nil , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
19291934
19301935 let node = try context. entity ( with: reference)
19311936 let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -1940,7 +1945,7 @@ Document
19401945
19411946 let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
19421947 " Custom Name " : PlatformVersion ( VersionTriplet ( 100 , 0 , 0 ) , beta: true )
1943- ] )
1948+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
19441949 let node = try context. entity ( with: reference)
19451950 ( node. semantic as? Symbol ) ? . availability = SymbolGraph . Symbol. Availability ( availability: [ ] )
19461951 let documentationContentRendered = DocumentationContentRenderer ( documentationContext: context, bundle: bundle)
@@ -1953,7 +1958,7 @@ Document
19531958 do {
19541959 let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
19551960 " tvOS " : PlatformVersion ( VersionTriplet ( 100 , 0 , 0 ) , beta: true )
1956- ] )
1961+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
19571962
19581963 let node = try context. entity ( with: reference)
19591964 let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -1967,7 +1972,7 @@ Document
19671972 do {
19681973 let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
19691974 " macOS " : PlatformVersion ( VersionTriplet ( 100 , 0 , 0 ) , beta: true )
1970- ] )
1975+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
19711976
19721977 let node = try context. entity ( with: reference)
19731978 let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -1981,21 +1986,21 @@ Document
19811986 do {
19821987 let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
19831988 " macOS " : PlatformVersion ( VersionTriplet ( 10 , 15 , 0 ) , beta: true )
1984- ] )
1989+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
19851990
19861991 let node = try context. entity ( with: reference)
19871992 let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
19881993
19891994 // Verify platform beta was plumbed all the way to the render JSON
1990- XCTAssertEqual ( renderNode. metadata. platforms? . first ( where: { $0. name == " macOS " } ) ? . isBeta, true )
1995+ XCTAssertEqual ( renderNode. metadata. platforms? . first ( where: { $0. name == " macOS " } ) ? . isBeta, true )
19911996 }
19921997
19931998 // Beta platform earlier than the introduced version
19941999
19952000 do {
19962001 let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
19972002 " macOS " : PlatformVersion ( VersionTriplet ( 10 , 14 , 0 ) , beta: true )
1998- ] )
2003+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
19992004
20002005 let node = try context. entity ( with: reference)
20012006 let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -2004,36 +2009,36 @@ Document
20042009 XCTAssertEqual ( renderNode. metadata. platforms? . first ( where: { $0. name == " macOS " } ) ? . isBeta, true )
20052010 }
20062011
2007- // Set only some platforms to beta & the exact version MyClass is being introduced at
2012+ // Set only some platforms to beta & the exact version globalFunction is being introduced at
20082013
20092014 do {
20102015 let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
20112016 " macOS " : PlatformVersion ( VersionTriplet ( 10 , 15 , 0 ) , beta: true ) ,
20122017 " watchOS " : PlatformVersion ( VersionTriplet ( 9 , 0 , 0 ) , beta: true ) ,
20132018 " tvOS " : PlatformVersion ( VersionTriplet ( 1 , 0 , 0 ) , beta: true ) ,
2014- ] )
2019+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
20152020
20162021 let node = try context. entity ( with: reference)
20172022 let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
20182023
2019- // Verify task group link is beta
2020- XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/MyClass " ] as? TopicRenderReference ) ? . isBeta, false )
2024+ // Verify task group link is not in beta betas "iOS" is not being marked as beta
2025+ XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/globalFunction(_:considering:) " ] as? TopicRenderReference ) ? . isBeta, false )
20212026 }
20222027
2023- // Set all platforms to beta & the exact version MyClass is being introduced at to test beta SDK documentation
2028+ // Set all platforms to beta & the exact version globalFunction is being introduced at to test beta SDK documentation
20242029 do {
20252030 let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
20262031 " macOS " : PlatformVersion ( VersionTriplet ( 10 , 15 , 0 ) , beta: true ) ,
20272032 " watchOS " : PlatformVersion ( VersionTriplet ( 6 , 0 , 0 ) , beta: true ) ,
20282033 " tvOS " : PlatformVersion ( VersionTriplet ( 13 , 0 , 0 ) , beta: true ) ,
2029- " iOS " : PlatformVersion ( VersionTriplet ( 13 , 0 , 0 ) , beta: true ) ,
2030- ] )
2034+ " iOS " : PlatformVersion ( VersionTriplet ( 13 , 0 , 0 ) , beta: true )
2035+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
20312036
20322037 let node = try context. entity ( with: reference)
20332038 let renderNode = try XCTUnwrap ( DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node) )
20342039
20352040 // Verify task group link is beta
2036- XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/MyClass " ] as? TopicRenderReference ) ? . isBeta, true )
2041+ XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/globalFunction(_:considering:) " ] as? TopicRenderReference ) ? . isBeta, true )
20372042 }
20382043
20392044 // Set all platforms to beta where the symbol is available,
@@ -2045,13 +2050,13 @@ Document
20452050 " iOS " : PlatformVersion ( VersionTriplet ( 13 , 0 , 0 ) , beta: true ) ,
20462051 " FictionalOS " : PlatformVersion ( VersionTriplet ( 42 , 0 , 0 ) , beta: false ) ,
20472052 " ImaginaryOS " : PlatformVersion ( VersionTriplet ( 3 , 3 , 3 ) , beta: false ) ,
2048- ] )
2053+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
20492054
20502055 let node = try context. entity ( with: reference)
20512056 let renderNode = try XCTUnwrap ( DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node) )
20522057
20532058 // Verify task group link is beta
2054- XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/MyClass " ] as? TopicRenderReference ) ? . isBeta, true )
2059+ XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/globalFunction(_:considering:) " ] as? TopicRenderReference ) ? . isBeta, true )
20552060
20562061 // Add ImaginaryOS platform - but make it unconditionally unavailable and
20572062 // verify that it doesn't affect the beta status
@@ -2064,7 +2069,24 @@ Document
20642069 let renderNode = try XCTUnwrap ( DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node) )
20652070
20662071 // Verify task group link is beta
2067- XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/MyClass " ] as? TopicRenderReference ) ? . isBeta, true )
2072+ XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/globalFunction(_:considering:) " ] as? TopicRenderReference ) ? . isBeta, true )
2073+ }
2074+
2075+ // Set all platforms to beta & the exact version MyClass is being introduced.
2076+ // Expect the symbol to no be in beta sinceit does not have an introduced version for iOS
2077+ do {
2078+ let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
2079+ " macOS " : PlatformVersion ( VersionTriplet ( 10 , 15 , 0 ) , beta: true ) ,
2080+ " watchOS " : PlatformVersion ( VersionTriplet ( 6 , 0 , 0 ) , beta: true ) ,
2081+ " tvOS " : PlatformVersion ( VersionTriplet ( 13 , 0 , 0 ) , beta: true ) ,
2082+ " iOS " : PlatformVersion ( VersionTriplet ( 13 , 0 , 0 ) , beta: true )
2083+ ] , referencePath: " /documentation/MyKit " )
2084+
2085+ let node = try context. entity ( with: reference)
2086+ let renderNode = try XCTUnwrap ( DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node) )
2087+
2088+ // Verify task group link is not in beta because `iOS` does not have an introduced version
2089+ XCTAssertEqual ( ( renderNode. references [ " doc://org.swift.docc.example/documentation/MyKit/MyClass " ] as? TopicRenderReference ) ? . isBeta, false )
20682090 }
20692091 }
20702092
0 commit comments