|
11 | 11 | import Foundation
|
12 | 12 | @testable import SwiftDocC
|
13 | 13 | import SymbolKit
|
| 14 | +import SwiftDocCTestUtilities |
14 | 15 | import XCTest
|
15 | 16 |
|
16 | 17 | class SemaToRenderNodeMixedLanguageTests: XCTestCase {
|
@@ -969,7 +970,48 @@ class SemaToRenderNodeMixedLanguageTests: XCTestCase {
|
969 | 970 | XCTAssertTrue(objCTopicIDs.contains("doc://org.swift.MixedLanguageFramework/documentation/MixedLanguageFramework/_MixedLanguageFrameworkVersionNumber"))
|
970 | 971 | XCTAssertFalse(objCTopicIDs.contains("doc://org.swift.MixedLanguageFramework/documentation/MixedLanguageFramework/SwiftOnlyStruct"))
|
971 | 972 | }
|
972 |
| - |
| 973 | + |
| 974 | + func testAutomaticSeeAlsoSectionElementLimit() throws { |
| 975 | + let fileSystem = try TestFileSystem(folders: [ |
| 976 | + Folder(name: "unit-test.docc", content: [ |
| 977 | + JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph(moduleName: "ModuleName", symbols: (1...50).map { |
| 978 | + makeSymbol(id: "symbol-id-\($0)", kind: .class, pathComponents: ["SymbolName\($0)"]) |
| 979 | + })), |
| 980 | + |
| 981 | + TextFile(name: "ModuleName.md", utf8Content: """ |
| 982 | + # ``ModuleName`` |
| 983 | + |
| 984 | + A topic section with many elements |
| 985 | + |
| 986 | + ## Topics |
| 987 | + |
| 988 | + ### Many symbols |
| 989 | + |
| 990 | + \((1...50).map { "- ``SymbolName\($0)``" }.joined(separator: "\n")) |
| 991 | + """), |
| 992 | + ]) |
| 993 | + ]) |
| 994 | + |
| 995 | + let workspace = DocumentationWorkspace() |
| 996 | + let context = try DocumentationContext(dataProvider: workspace) |
| 997 | + try workspace.registerProvider(fileSystem) |
| 998 | + |
| 999 | + XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") |
| 1000 | + let bundle = try XCTUnwrap(context.registeredBundles.first) |
| 1001 | + |
| 1002 | + let converter = DocumentationNodeConverter(bundle: bundle, context: context) |
| 1003 | + |
| 1004 | + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) |
| 1005 | + let moduleNode = try converter.convert(context.entity(with: moduleReference)) |
| 1006 | + XCTAssertEqual(moduleNode.topicSections.first?.identifiers.count, 50, "The module curates 50 symbols") |
| 1007 | + |
| 1008 | + for number in 1...50 { |
| 1009 | + let symbolReference = moduleReference.appendingPath("SymbolName\(number)") |
| 1010 | + let symbolNode = try converter.convert(context.entity(with: symbolReference)) |
| 1011 | + XCTAssertEqual(symbolNode.seeAlsoSections.first?.identifiers.count, 15, "The limit is applies to the large See Also section") |
| 1012 | + } |
| 1013 | + } |
| 1014 | + |
973 | 1015 | func renderNodeApplyingObjectiveCVariantOverrides(to renderNode: RenderNode) throws -> RenderNode {
|
974 | 1016 | return try renderNodeApplying(variant: "occ", to: renderNode)
|
975 | 1017 | }
|
|
0 commit comments