@@ -3349,6 +3349,81 @@ Document
3349
3349
] )
3350
3350
}
3351
3351
3352
+ func testLanguageSpecificTopicSectionDoesNotAppearInAutomaticSeeAlso( ) throws {
3353
+ let catalog = Folder ( name: " Something.docc " , content: [
3354
+ JSONFile ( name: " Something-swift.symbols.json " , content: makeSymbolGraph ( moduleName: " Something " , symbols: ( 1 ... 4 ) . map {
3355
+ makeSymbol ( id: " symbol-id- \( $0) " , language: . swift, kind: . class, pathComponents: [ " SomeClass \( $0) " ] )
3356
+ } ) ) ,
3357
+
3358
+ JSONFile ( name: " Something-objc.symbols.json " , content: makeSymbolGraph ( moduleName: " Something " , symbols: ( 1 ... 4 ) . map {
3359
+ makeSymbol ( id: " symbol-id- \( $0) " , language: . objectiveC, kind: . class, pathComponents: [ " SomeClass \( $0) " ] )
3360
+ } ) ) ,
3361
+
3362
+ TextFile ( name: " ModuleExtension.md " , utf8Content: """
3363
+ # ``Something``
3364
+
3365
+ ## Topics
3366
+
3367
+ ### Something Swift only
3368
+
3369
+ @SupportedLanguage(swift)
3370
+
3371
+ - ``SomeClass1``
3372
+ - ``SomeClass2``
3373
+ - ``SomeClass3``
3374
+
3375
+ ### Something Objective-C only
3376
+
3377
+ @SupportedLanguage(objc)
3378
+
3379
+ - ``SomeClass2``
3380
+ - ``SomeClass3``
3381
+ - ``SomeClass4``
3382
+ """ ) ,
3383
+ ] )
3384
+ let ( bundle, context) = try loadBundle ( catalog: catalog)
3385
+ XCTAssert ( context. problems. isEmpty, " \( context. problems. map ( \. diagnostic. summary) ) " )
3386
+
3387
+ let moduleReference = try XCTUnwrap ( context. soleRootModuleReference)
3388
+ let reference = moduleReference. appendingPath ( " SomeClass3 " )
3389
+
3390
+ let documentationNode = try context. entity ( with: reference)
3391
+ XCTAssertEqual ( documentationNode. availableVariantTraits. count, 2 , " This page has Swift and Objective-C variants " )
3392
+
3393
+ // There's a behavioral difference between DocumentationContextConverter and DocumentationNodeConverter so we check both.
3394
+ // DocumentationContextConverter may use pre-rendered content but the DocumentationNodeConverter computes task groups as-needed.
3395
+
3396
+ func assertExpectedTopicSections( _ renderNode: RenderNode , file: StaticString = #filePath, line: UInt = #line) {
3397
+ let topicSectionsVariants = renderNode. seeAlsoSectionsVariants
3398
+
3399
+ let swiftSeeAlsoSection = topicSectionsVariants. defaultValue
3400
+
3401
+ XCTAssertEqual ( swiftSeeAlsoSection. first? . title, " Something Swift only " , file: file, line: line)
3402
+ XCTAssertEqual ( swiftSeeAlsoSection. first? . identifiers, [
3403
+ " doc://Something/documentation/Something/SomeClass1 " ,
3404
+ " doc://Something/documentation/Something/SomeClass2 " ,
3405
+ ] , file: file, line: line)
3406
+
3407
+ let objcSeeAlsoSection = topicSectionsVariants. value ( for: [ . interfaceLanguage( " occ " ) ] )
3408
+
3409
+ XCTAssertEqual ( objcSeeAlsoSection. first? . title, " Something Objective-C only " , file: file, line: line)
3410
+ XCTAssertEqual ( objcSeeAlsoSection. first? . identifiers, [
3411
+ " doc://Something/documentation/Something/SomeClass2 " ,
3412
+ " doc://Something/documentation/Something/SomeClass4 " ,
3413
+ ] , file: file, line: line)
3414
+ }
3415
+
3416
+ let nodeConverter = DocumentationNodeConverter ( bundle: bundle, context: context)
3417
+ try assertExpectedTopicSections ( nodeConverter. convert ( documentationNode) )
3418
+
3419
+ let contextConverter = DocumentationContextConverter (
3420
+ bundle: bundle,
3421
+ context: context,
3422
+ renderContext: RenderContext ( documentationContext: context, bundle: bundle)
3423
+ )
3424
+ try assertExpectedTopicSections ( XCTUnwrap ( contextConverter. renderNode ( for: documentationNode) ) )
3425
+ }
3426
+
3352
3427
func testTopicSectionWithUnsupportedDirectives( ) throws {
3353
3428
let exampleDocumentation = Folder ( name: " unit-test.docc " , content: [
3354
3429
TextFile ( name: " root.md " , utf8Content: """
0 commit comments