Skip to content

Commit 1d8d141

Browse files
committed
Minimally integrate the symbol path tree.
1 parent 7fd9e9a commit 1d8d141

File tree

27 files changed

+790
-753
lines changed

27 files changed

+790
-753
lines changed

Sources/SwiftDocC/Infrastructure/DocumentationContext.swift

Lines changed: 207 additions & 216 deletions
Large diffs are not rendered by default.

Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -196,10 +196,9 @@ enum GeneratedDocumentationTopics {
196196
/// ```
197197
/// - Parameters:
198198
/// - relationships: A set of relationships to inspect.
199-
/// - symbolsURLHierarchy: A symbol graph hierarchy as created during symbol registration.
200199
/// - context: A documentation context to update.
201200
/// - bundle: The current documentation bundle.
202-
static func createInheritedSymbolsAPICollections(relationships: Set<SymbolGraph.Relationship>, symbolsURLHierarchy: inout BidirectionalTree<ResolvedTopicReference>, context: DocumentationContext, bundle: DocumentationBundle) throws {
201+
static func createInheritedSymbolsAPICollections(relationships: Set<SymbolGraph.Relationship>, context: DocumentationContext, bundle: DocumentationBundle) throws {
203202
var inheritanceIndex = InheritedSymbols()
204203

205204
// Walk the symbol graph relationships and look for parent <-> child links that stem in a different module.
@@ -220,7 +219,7 @@ enum GeneratedDocumentationTopics {
220219
}
221220
}
222221

223-
// Create the API Collection nodes and the neccessary topic graph curation.
222+
// Create the API Collection nodes and the necessary topic graph curation.
224223
for (typeReference, collections) in inheritanceIndex.implementingTypes where !collections.inheritedFromTypeName.isEmpty {
225224
for (_, collection) in collections.inheritedFromTypeName where !collection.identifiers.isEmpty {
226225
// Create a collection for the given provider type's inherited symbols

Sources/SwiftDocC/Infrastructure/SymbolPathTree.swift

Lines changed: 198 additions & 61 deletions
Large diffs are not rendered by default.

Sources/SwiftDocC/Utility/DataStructures/BidirectionalTree.swift

Lines changed: 0 additions & 168 deletions
This file was deleted.

Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -342,8 +342,10 @@ class ConvertServiceTests: XCTestCase {
342342
)
343343
}
344344

345+
// ???: Is this valid?
346+
// myFunction() is an instance method and this tries to configure it to be disambiguated as a type method
345347
request.knownDisambiguatedSymbolPathComponents = [
346-
"s:5MyKit0A5ClassC10myFunctionyyF": ["MyClass-swift.class", "myFunction()-swift.type.method"],
348+
"s:5MyKit0A5ClassC10myFunctionyyF": ["MyClass-swift.class", "myFunction()-swift.method"],
347349
]
348350

349351
try processAndAssert(request: request) { message in
@@ -355,20 +357,28 @@ class ConvertServiceTests: XCTestCase {
355357

356358
XCTAssertEqual(
357359
renderNode.identifier.path,
358-
"/documentation/MyKit/MyClass-swift.class/myFunction()-swift.type.method"
360+
"/documentation/MyKit/MyClass-swift.class/myFunction()-swift.method"
359361
)
360362

361363
XCTAssertEqual(
362364
renderNode.abstract?.first,
363-
.codeVoice(code: "myFunction()")
365+
.reference(
366+
identifier: .init("""
367+
doc://identifier/documentation/MyKit/MyClass-swift.class/myFunction()-swift.method
368+
"""
369+
),
370+
isActive: true,
371+
overridingTitle: nil,
372+
overridingTitleInlineContent: nil
373+
)
364374
)
365375
}
366376

367377
let symbolGraphWithAdjustedLink = Data(
368378
try XCTUnwrap(
369379
String(data: symbolGraph, encoding: .utf8)
370380
)
371-
.replacingOccurrences(of: "``myFunction()``", with: "``myFunction()-swift.type.method``")
381+
.replacingOccurrences(of: "``myFunction()``", with: "``myFunction()-swift.method``")
372382
.utf8
373383
)
374384

@@ -383,14 +393,14 @@ class ConvertServiceTests: XCTestCase {
383393

384394
XCTAssertEqual(
385395
renderNode.identifier.path,
386-
"/documentation/MyKit/MyClass-swift.class/myFunction()-swift.type.method"
396+
"/documentation/MyKit/MyClass-swift.class/myFunction()-swift.method"
387397
)
388398

389399
XCTAssertEqual(
390400
renderNode.abstract?.first,
391401
.reference(
392402
identifier: .init("""
393-
doc://identifier/documentation/MyKit/MyClass-swift.class/myFunction()-swift.type.method
403+
doc://identifier/documentation/MyKit/MyClass-swift.class/myFunction()-swift.method
394404
"""
395405
),
396406
isActive: true,

Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -366,7 +366,7 @@ Root
366366

367367
let renderIndex = try RenderIndex.fromURL(targetURL.appendingPathComponent("index.json"))
368368
XCTAssertEqual(renderIndex.interfaceLanguages.keys.count, 1)
369-
XCTAssertEqual(renderIndex.interfaceLanguages["swift"]?.count, 27)
369+
XCTAssertEqual(renderIndex.interfaceLanguages["swift"]?.count, 29)
370370

371371
XCTAssertEqual(renderIndex.interfaceLanguages["swift"]?.first?.title, "Functions")
372372
XCTAssertEqual(renderIndex.interfaceLanguages["swift"]?.first?.path, nil)
@@ -620,7 +620,10 @@ Root
620620
XCTAssertNil(navigatorIndex.path(for: 0)) // Root should have not path persisted.
621621
XCTAssertEqual(navigatorIndex.path(for: 1), "/documentation/fillintroduced")
622622
XCTAssertEqual(navigatorIndex.path(for: 4), "/tutorials/testoverview")
623-
XCTAssertEqual(navigatorIndex.path(for: 10), "/documentation/fillintroduced/maccatalystonlydeprecated()")
623+
XCTAssertEqual(navigatorIndex.path(for: 9), "/documentation/fillintroduced/maccatalystonlydeprecated()")
624+
XCTAssertEqual(navigatorIndex.path(for: 10), "/documentation/fillintroduced/maccatalystonlyintroduced()")
625+
XCTAssertEqual(navigatorIndex.path(for: 21), "/documentation/mykit/globalfunction(_:considering:)")
626+
XCTAssertEqual(navigatorIndex.path(for: 23), "/documentation/sidekit/uncuratedclass/angle")
624627

625628
assertUniqueIDs(node: navigatorIndex.navigatorTree.root)
626629
results.insert(navigatorIndex.navigatorTree.root.dumpTree())
@@ -643,7 +646,7 @@ Root
643646
XCTAssertEqual(Set(navigatorIndex.languages), Set(["Swift"]))
644647

645648
// Get the Swift language group.
646-
XCTAssertEqual(navigatorIndex.navigatorTree.numericIdentifierToNode[1]?.children.count, 5)
649+
XCTAssertEqual(navigatorIndex.navigatorTree.numericIdentifierToNode[1]?.children.count, 4)
647650

648651
assertUniqueIDs(node: navigatorIndex.navigatorTree.root)
649652
assertEqualDumps(navigatorIndex.navigatorTree.root.dumpTree(), try testTree(named: "testNavigatorIndexGenerationWithLanguageGrouping"))

Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,31 @@ class AutomaticCurationTests: XCTestCase {
167167

168168
graph.symbols[duplicateSymbol.identifier.precise] = duplicateSymbol
169169

170-
// Duplicate all the edges to and from the symbbol
170+
// Duplicate all the edges and nodes to and from the symbol
171171
for relationship in graph.relationships where relationship.source == sideClassIdentifier {
172172
var newRelationship = relationship
173173
newRelationship.source = duplicateSymbol.identifier.precise
174+
175+
// Duplicate the target symbol to avoid symbols being members of more than one other symbol.
176+
let newTarget = relationship.target + suffix
177+
newRelationship.target = newTarget
178+
if let targetSymbol = graph.symbols[relationship.target] {
179+
graph.symbols[newTarget] = targetSymbol
180+
}
181+
174182
graph.relationships.append(newRelationship)
175183
}
176184
for relationship in graph.relationships where relationship.target == sideClassIdentifier {
177185
var newRelationship = relationship
178186
newRelationship.target = duplicateSymbol.identifier.precise
187+
188+
// Duplicate the source symbol to avoid symbols being members of more than one other symbol.
189+
let newSource = relationship.source + suffix
190+
newRelationship.source = newSource
191+
if let targetSymbol = graph.symbols[relationship.target] {
192+
graph.symbols[newSource] = targetSymbol
193+
}
194+
179195
graph.relationships.append(newRelationship)
180196
}
181197

0 commit comments

Comments
 (0)