Skip to content

Commit bd66e8f

Browse files
committed
implement handling of extensions to external types as enabled by swiftlang/swift#59047
- introduce transformation generating internal Extended Types Symbol Graph Format from the Extension Block Symbol Graph Format emmitted by the compiler - register symbols and relationships used by Extended Types Symbol Graph Format - adapt reference collision detection logic to deal with emitted path components that occur when extending external nested types - adapt reference resolution logic to first search for paths in the local module by default and introduce shorthand absolute syntax with "/" prefix to mark paths as absolute (to be searched for only in the global scope) - adapt SymbolGraphLoader to automatically detect if input Symbol Graph Files use the Extension Block Symbol Graph Format and apply the ExtendedTypesFormatTransformation in case - improve Swift title token parsing to correctly identify Symbol titles of nested types, which contain "." infixes
1 parent 566a177 commit bd66e8f

21 files changed

+1162
-243
lines changed

Package.resolved

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
},
4040
{
4141
"package": "SymbolKit",
42-
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
42+
"repositoryURL": "https://github.com/themomax/swift-docc-symbolkit",
4343
"state": {
44-
"branch": "main",
45-
"revision": "da6cedd103e0e08a2bc7b14869ec37fba4db72d9",
44+
"branch": "docc-extensions-to-external-types-base",
45+
"revision": "dba9c2dc32a3c02d5be84b67e9b2c4af108d3ba0",
4646
"version": null
4747
}
4848
},

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
124124
.package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")),
125125
.package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")),
126126
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")),
127-
.package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("main")),
127+
.package(name: "SymbolKit", url: "https://github.com/themomax/swift-docc-symbolkit", .branch("docc-extensions-to-external-types-base")),
128128
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.2")),
129129
]
130130

Sources/SwiftDocC/Coverage/DocumentationCoverageOptions.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ extension DocumentationCoverageOptions.KindFilterOptions {
185185
/// Converts given ``DocumentationNode.Kind`` to corresponding `BitFlagRepresentation` if possible. Returns `nil` if the given Kind is not representable.
186186
fileprivate init?(kind: DocumentationNode.Kind) {
187187
switch kind {
188-
case .module: // 1
188+
case .module, .extendedModule: // 1
189189
self = .module
190-
case .class: // 2
190+
case .class, .extendedClass: // 2
191191
self = .class
192-
case .structure: // 3
192+
case .structure, .extendedStructure: // 3
193193
self = .structure
194-
case .enumeration: // 4
194+
case .enumeration, .extendedEnumeration: // 4
195195
self = .enumeration
196-
case .protocol: // 5
196+
case .protocol, .extendedProtocol: // 5
197197
self = .protocol
198198
case .typeAlias: // 6
199199
self = .typeAlias

Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex+Ext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class FileSystemRenderNodeProvider: RenderNodeProvider {
7676

7777
extension RenderNode {
7878
private static let typesThatShouldNotUseNavigatorTitle: Set<NavigatorIndex.PageType> = [
79-
.framework, .class, .structure, .enumeration, .protocol, .typeAlias, .associatedType
79+
.framework, .class, .structure, .enumeration, .protocol, .typeAlias, .associatedType, .extension
8080
]
8181

8282
/// Returns a navigator title preferring the fragments inside the metadata, if applicable.

Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ extension CoverageDataEntry {
243243
.protocol,
244244
.typeAlias,
245245
.associatedType,
246-
.typeDef:
246+
.typeDef,
247+
.extendedClass,
248+
.extendedStructure,
249+
.extendedEnumeration,
250+
.extendedProtocol:
247251
self = .types
248252
case .localVariable,
249253
.instanceProperty,
@@ -256,7 +260,7 @@ extension CoverageDataEntry {
256260
.typeSubscript,
257261
.instanceSubscript:
258262
self = .members
259-
case .function, .module, .globalVariable, .operator:
263+
case .function, .module, .globalVariable, .operator, .extendedModule:
260264
self = .globals
261265
case let kind where SummaryCategory.allKnownNonSymbolKindNames.contains(kind.name):
262266
self = .nonSymbol
@@ -297,46 +301,46 @@ extension CoverageDataEntry {
297301
context: DocumentationContext
298302
) throws {
299303
switch documentationNode.kind {
300-
case DocumentationNode.Kind.class:
304+
case .class, .extendedClass:
301305
self = try .class(
302306
memberStats: KindSpecificData.extractChildStats(
303307
documentationNode: documentationNode,
304308
context: context))
305-
case DocumentationNode.Kind.enumeration:
309+
case .enumeration, .extendedEnumeration:
306310
self = try .enumeration(
307311
memberStats: KindSpecificData.extractChildStats(
308312
documentationNode: documentationNode,
309313
context: context))
310-
case DocumentationNode.Kind.structure:
314+
case .structure, .extendedStructure:
311315
self = try .structure(
312316
memberStats: KindSpecificData.extractChildStats(
313317
documentationNode: documentationNode,
314318
context: context))
315-
case DocumentationNode.Kind.protocol:
316-
self = try .enumeration(
319+
case .protocol, .extendedProtocol:
320+
self = try .protocol(
317321
memberStats: KindSpecificData.extractChildStats(
318322
documentationNode: documentationNode,
319323
context: context))
320324

321-
case DocumentationNode.Kind.instanceMethod:
325+
case .instanceMethod:
322326
self = try .instanceMethod(
323327
parameterStats: CoverageDataEntry.KindSpecificData.extractFunctionSignatureStats(
324328
documentationNode: documentationNode,
325329
context: context
326330
, fieldName: "method parameters"))
327-
case DocumentationNode.Kind.operator:
331+
case .operator:
328332
self = try .`operator`(
329333
parameterStats: CoverageDataEntry.KindSpecificData.extractFunctionSignatureStats(
330334
documentationNode: documentationNode,
331335
context: context,
332336
fieldName: "operator parameters"))
333-
case DocumentationNode.Kind.function:
337+
case .function:
334338
self = try .`operator`(
335339
parameterStats: CoverageDataEntry.KindSpecificData.extractFunctionSignatureStats(
336340
documentationNode: documentationNode,
337341
context: context,
338342
fieldName: "function parameters"))
339-
case DocumentationNode.Kind.initializer:
343+
case .initializer:
340344
self = try .`operator`(
341345
parameterStats: CoverageDataEntry.KindSpecificData.extractFunctionSignatureStats(
342346
documentationNode: documentationNode,

0 commit comments

Comments
 (0)