@@ -1913,19 +1913,24 @@ Document
1913
1913
}
1914
1914
1915
1915
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 ) {
1917
1917
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
+ }
1918
1923
configuration. externalMetadata. currentPlatforms = currentPlatforms
1919
1924
1920
1925
let ( _, bundle, context) = try testBundleAndContext ( named: " TestBundle " , configuration: configuration)
1921
1926
1922
- let reference = ResolvedTopicReference ( bundleIdentifier: bundle. identifier, path: " /documentation/MyKit/MyClass " , sourceLanguage: . swift)
1927
+ let reference = ResolvedTopicReference ( bundleIdentifier: bundle. identifier, path: referencePath , sourceLanguage: . swift)
1923
1928
return ( bundle, context, reference)
1924
1929
}
1925
1930
1926
1931
// Not a beta platform
1927
1932
do {
1928
- let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: nil )
1933
+ let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: nil , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
1929
1934
1930
1935
let node = try context. entity ( with: reference)
1931
1936
let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -1940,7 +1945,7 @@ Document
1940
1945
1941
1946
let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
1942
1947
" Custom Name " : PlatformVersion ( VersionTriplet ( 100 , 0 , 0 ) , beta: true )
1943
- ] )
1948
+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
1944
1949
let node = try context. entity ( with: reference)
1945
1950
( node. semantic as? Symbol ) ? . availability = SymbolGraph . Symbol. Availability ( availability: [ ] )
1946
1951
let documentationContentRendered = DocumentationContentRenderer ( documentationContext: context, bundle: bundle)
@@ -1953,7 +1958,7 @@ Document
1953
1958
do {
1954
1959
let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
1955
1960
" tvOS " : PlatformVersion ( VersionTriplet ( 100 , 0 , 0 ) , beta: true )
1956
- ] )
1961
+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
1957
1962
1958
1963
let node = try context. entity ( with: reference)
1959
1964
let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -1967,7 +1972,7 @@ Document
1967
1972
do {
1968
1973
let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
1969
1974
" macOS " : PlatformVersion ( VersionTriplet ( 100 , 0 , 0 ) , beta: true )
1970
- ] )
1975
+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
1971
1976
1972
1977
let node = try context. entity ( with: reference)
1973
1978
let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -1981,21 +1986,21 @@ Document
1981
1986
do {
1982
1987
let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
1983
1988
" macOS " : PlatformVersion ( VersionTriplet ( 10 , 15 , 0 ) , beta: true )
1984
- ] )
1989
+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
1985
1990
1986
1991
let node = try context. entity ( with: reference)
1987
1992
let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
1988
1993
1989
1994
// 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 )
1991
1996
}
1992
1997
1993
1998
// Beta platform earlier than the introduced version
1994
1999
1995
2000
do {
1996
2001
let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
1997
2002
" macOS " : PlatformVersion ( VersionTriplet ( 10 , 14 , 0 ) , beta: true )
1998
- ] )
2003
+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
1999
2004
2000
2005
let node = try context. entity ( with: reference)
2001
2006
let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
@@ -2004,36 +2009,36 @@ Document
2004
2009
XCTAssertEqual ( renderNode. metadata. platforms? . first ( where: { $0. name == " macOS " } ) ? . isBeta, true )
2005
2010
}
2006
2011
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
2008
2013
2009
2014
do {
2010
2015
let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
2011
2016
" macOS " : PlatformVersion ( VersionTriplet ( 10 , 15 , 0 ) , beta: true ) ,
2012
2017
" watchOS " : PlatformVersion ( VersionTriplet ( 9 , 0 , 0 ) , beta: true ) ,
2013
2018
" tvOS " : PlatformVersion ( VersionTriplet ( 1 , 0 , 0 ) , beta: true ) ,
2014
- ] )
2019
+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
2015
2020
2016
2021
let node = try context. entity ( with: reference)
2017
2022
let renderNode = try DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node)
2018
2023
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 )
2021
2026
}
2022
2027
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
2024
2029
do {
2025
2030
let ( bundle, context, reference) = try makeTestBundle ( currentPlatforms: [
2026
2031
" macOS " : PlatformVersion ( VersionTriplet ( 10 , 15 , 0 ) , beta: true ) ,
2027
2032
" watchOS " : PlatformVersion ( VersionTriplet ( 6 , 0 , 0 ) , beta: true ) ,
2028
2033
" 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:) " )
2031
2036
2032
2037
let node = try context. entity ( with: reference)
2033
2038
let renderNode = try XCTUnwrap ( DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node) )
2034
2039
2035
2040
// 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 )
2037
2042
}
2038
2043
2039
2044
// Set all platforms to beta where the symbol is available,
@@ -2045,13 +2050,13 @@ Document
2045
2050
" iOS " : PlatformVersion ( VersionTriplet ( 13 , 0 , 0 ) , beta: true ) ,
2046
2051
" FictionalOS " : PlatformVersion ( VersionTriplet ( 42 , 0 , 0 ) , beta: false ) ,
2047
2052
" ImaginaryOS " : PlatformVersion ( VersionTriplet ( 3 , 3 , 3 ) , beta: false ) ,
2048
- ] )
2053
+ ] , referencePath : " /documentation/MyKit/globalFunction(_:considering:) " )
2049
2054
2050
2055
let node = try context. entity ( with: reference)
2051
2056
let renderNode = try XCTUnwrap ( DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node) )
2052
2057
2053
2058
// 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 )
2055
2060
2056
2061
// Add ImaginaryOS platform - but make it unconditionally unavailable and
2057
2062
// verify that it doesn't affect the beta status
@@ -2064,7 +2069,24 @@ Document
2064
2069
let renderNode = try XCTUnwrap ( DocumentationNodeConverter ( bundle: bundle, context: context) . convert ( node) )
2065
2070
2066
2071
// 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 )
2068
2090
}
2069
2091
}
2070
2092
0 commit comments