@@ -83,6 +83,7 @@ public typealias BundleIdentifier = String
83
83
/// - ``parents(of:)``
84
84
///
85
85
public class DocumentationContext {
86
+ private let signposter = ConvertActionConverter . signposter
86
87
87
88
/// An error that's encountered while interacting with a ``SwiftDocC/DocumentationContext``.
88
89
public enum ContextError : DescribedError {
@@ -563,6 +564,11 @@ public class DocumentationContext {
563
564
Attempt to resolve links in curation-only documentation, converting any ``TopicReferences`` from `.unresolved` to `.resolved` where possible.
564
565
*/
565
566
private func resolveLinks( curatedReferences: Set < ResolvedTopicReference > , bundle: DocumentationBundle ) {
567
+ let signpostHandle = signposter. beginInterval ( " Resolve links " , id: signposter. makeSignpostID ( ) )
568
+ defer {
569
+ signposter. endInterval ( " Resolve links " , signpostHandle)
570
+ }
571
+
566
572
let references = Array ( curatedReferences)
567
573
let results = Synchronized < [ LinkResolveResult ] > ( [ ] )
568
574
results. sync ( { $0. reserveCapacity ( references. count) } )
@@ -708,6 +714,11 @@ public class DocumentationContext {
708
714
tutorialArticles: [ SemanticResult < TutorialArticle > ] ,
709
715
bundle: DocumentationBundle
710
716
) {
717
+ let signpostHandle = signposter. beginInterval ( " Resolve links " , id: signposter. makeSignpostID ( ) )
718
+ defer {
719
+ signposter. endInterval ( " Resolve links " , signpostHandle)
720
+ }
721
+
711
722
let sourceLanguages = soleRootModuleReference. map { self . sourceLanguages ( for: $0) } ?? [ . swift]
712
723
713
724
// Tutorial table-of-contents
@@ -1147,6 +1158,11 @@ public class DocumentationContext {
1147
1158
) throws {
1148
1159
// Making sure that we correctly let decoding memory get released, do not remove the autorelease pool.
1149
1160
try autoreleasepool {
1161
+ let signpostHandle = signposter. beginInterval ( " Register symbols " , id: signposter. makeSignpostID ( ) )
1162
+ defer {
1163
+ signposter. endInterval ( " Register symbols " , signpostHandle)
1164
+ }
1165
+
1150
1166
/// We need only unique relationships so we'll collect them in a set.
1151
1167
var combinedRelationshipsBySelector = [ UnifiedSymbolGraph . Selector : Set < SymbolGraph . Relationship > ] ( )
1152
1168
/// Also track the unique relationships across all languages and platforms
@@ -1157,7 +1173,9 @@ public class DocumentationContext {
1157
1173
var moduleReferences = [ String: ResolvedTopicReference] ( )
1158
1174
1159
1175
// Build references for all symbols in all of this module's symbol graphs.
1160
- let symbolReferences = linkResolver. localResolver. referencesForSymbols ( in: symbolGraphLoader. unifiedGraphs, bundle: bundle, context: self )
1176
+ let symbolReferences = signposter. withIntervalSignpost ( " Disambiguate references " ) {
1177
+ linkResolver. localResolver. referencesForSymbols ( in: symbolGraphLoader. unifiedGraphs, bundle: bundle, context: self )
1178
+ }
1161
1179
1162
1180
// Set the index and cache storage capacity to avoid ad-hoc storage resizing.
1163
1181
documentationCache. reserveCapacity ( symbolReferences. count)
@@ -1223,7 +1241,9 @@ public class DocumentationContext {
1223
1241
let moduleSymbolReference = SymbolReference ( moduleName, interfaceLanguages: moduleInterfaceLanguages, defaultSymbol: moduleSymbol)
1224
1242
moduleReference = ResolvedTopicReference ( symbolReference: moduleSymbolReference, moduleName: moduleName, bundle: bundle)
1225
1243
1226
- addSymbolsToTopicGraph ( symbolGraph: unifiedSymbolGraph, url: fileURL, symbolReferences: symbolReferences, moduleReference: moduleReference)
1244
+ signposter. withIntervalSignpost ( " Add symbols to topic graph " , id: signposter. makeSignpostID ( ) ) {
1245
+ addSymbolsToTopicGraph ( symbolGraph: unifiedSymbolGraph, url: fileURL, symbolReferences: symbolReferences, moduleReference: moduleReference)
1246
+ }
1227
1247
1228
1248
// For inherited symbols we remove the source docs (if inheriting docs is disabled) before creating their documentation nodes.
1229
1249
for (_, relationships) in unifiedSymbolGraph. relationshipsByLanguage {
@@ -1375,15 +1395,17 @@ public class DocumentationContext {
1375
1395
)
1376
1396
1377
1397
// Parse and prepare the nodes' content concurrently.
1378
- let updatedNodes = Array ( documentationCache. symbolReferences) . concurrentMap { finalReference in
1379
- // Match the symbol's documentation extension and initialize the node content.
1380
- let match = uncuratedDocumentationExtensions [ finalReference]
1381
- let updatedNode = nodeWithInitializedContent ( reference: finalReference, match: match)
1382
-
1383
- return ( (
1384
- node: updatedNode,
1385
- matchedArticleURL: match? . source
1386
- ) )
1398
+ let updatedNodes = signposter. withIntervalSignpost ( " Parse symbol markup " , id: signposter. makeSignpostID ( ) ) {
1399
+ Array ( documentationCache. symbolReferences) . concurrentMap { finalReference in
1400
+ // Match the symbol's documentation extension and initialize the node content.
1401
+ let match = uncuratedDocumentationExtensions [ finalReference]
1402
+ let updatedNode = nodeWithInitializedContent ( reference: finalReference, match: match)
1403
+
1404
+ return ( (
1405
+ node: updatedNode,
1406
+ matchedArticleURL: match? . source
1407
+ ) )
1408
+ }
1387
1409
}
1388
1410
1389
1411
// Update cache with up-to-date nodes
@@ -2177,9 +2199,16 @@ public class DocumentationContext {
2177
2199
)
2178
2200
2179
2201
do {
2180
- try symbolGraphLoader. loadAll ( )
2181
- let pathHierarchy = PathHierarchy ( symbolGraphLoader: symbolGraphLoader, bundleName: urlReadablePath ( bundle. displayName) , knownDisambiguatedPathComponents: configuration. convertServiceConfiguration. knownDisambiguatedSymbolPathComponents)
2182
- hierarchyBasedResolver = PathHierarchyBasedLinkResolver ( pathHierarchy: pathHierarchy)
2202
+ try signposter. withIntervalSignpost ( " Load symbols " , id: signposter. makeSignpostID ( ) ) {
2203
+ try symbolGraphLoader. loadAll ( )
2204
+ }
2205
+ hierarchyBasedResolver = signposter. withIntervalSignpost ( " Build PathHierarchy " , id: signposter. makeSignpostID ( ) ) {
2206
+ PathHierarchyBasedLinkResolver ( pathHierarchy: PathHierarchy (
2207
+ symbolGraphLoader: symbolGraphLoader,
2208
+ bundleName: urlReadablePath ( bundle. displayName) ,
2209
+ knownDisambiguatedPathComponents: configuration. convertServiceConfiguration. knownDisambiguatedSymbolPathComponents
2210
+ ) )
2211
+ }
2183
2212
} catch {
2184
2213
// Pipe the error out of the dispatch queue.
2185
2214
discoveryError. sync ( {
@@ -2191,7 +2220,9 @@ public class DocumentationContext {
2191
2220
// First, all the resources are added since they don't reference anything else.
2192
2221
discoveryGroup. async ( queue: discoveryQueue) { [ unowned self] in
2193
2222
do {
2194
- try self . registerMiscResources ( from: bundle)
2223
+ try signposter. withIntervalSignpost ( " Load resources " , id: signposter. makeSignpostID ( ) ) {
2224
+ try self . registerMiscResources ( from: bundle)
2225
+ }
2195
2226
} catch {
2196
2227
// Pipe the error out of the dispatch queue.
2197
2228
discoveryError. sync ( {
@@ -2215,7 +2246,9 @@ public class DocumentationContext {
2215
2246
2216
2247
discoveryGroup. async ( queue: discoveryQueue) { [ unowned self] in
2217
2248
do {
2218
- result = try self . registerDocuments ( from: bundle)
2249
+ result = try signposter. withIntervalSignpost ( " Load documents " , id: signposter. makeSignpostID ( ) ) {
2250
+ try self . registerDocuments ( from: bundle)
2251
+ }
2219
2252
} catch {
2220
2253
// Pipe the error out of the dispatch queue.
2221
2254
discoveryError. sync ( {
@@ -2226,7 +2259,9 @@ public class DocumentationContext {
2226
2259
2227
2260
discoveryGroup. async ( queue: discoveryQueue) { [ unowned self] in
2228
2261
do {
2229
- try linkResolver. loadExternalResolvers ( dependencyArchives: configuration. externalDocumentationConfiguration. dependencyArchives)
2262
+ try signposter. withIntervalSignpost ( " Load external resolvers " , id: signposter. makeSignpostID ( ) ) {
2263
+ try linkResolver. loadExternalResolvers ( dependencyArchives: configuration. externalDocumentationConfiguration. dependencyArchives)
2264
+ }
2230
2265
} catch {
2231
2266
// Pipe the error out of the dispatch queue.
2232
2267
discoveryError. sync ( {
@@ -2361,7 +2396,9 @@ public class DocumentationContext {
2361
2396
try shouldContinueRegistration ( )
2362
2397
2363
2398
// Fourth, automatically curate all symbols that haven't been curated manually
2364
- let automaticallyCurated = autoCurateSymbolsInTopicGraph ( )
2399
+ let automaticallyCurated = signposter. withIntervalSignpost ( " Auto-curate symbols " , id: signposter. makeSignpostID ( ) ) {
2400
+ autoCurateSymbolsInTopicGraph ( )
2401
+ }
2365
2402
2366
2403
// Crawl the rest of the symbols that haven't been crawled so far in hierarchy pre-order.
2367
2404
allCuratedReferences = try crawlSymbolCuration ( in: automaticallyCurated. map ( \. symbol) , bundle: bundle, initial: allCuratedReferences)
@@ -2407,7 +2444,9 @@ public class DocumentationContext {
2407
2444
}
2408
2445
2409
2446
// Seventh, the complete topic graph—with all nodes and all edges added—is analyzed.
2410
- topicGraphGlobalAnalysis ( )
2447
+ signposter. withIntervalSignpost ( " Analyze topic graph " , id: signposter. makeSignpostID ( ) ) {
2448
+ topicGraphGlobalAnalysis ( )
2449
+ }
2411
2450
2412
2451
preResolveModuleNames ( )
2413
2452
}
@@ -2606,6 +2645,11 @@ public class DocumentationContext {
2606
2645
/// - Returns: The references of all the symbols that were curated.
2607
2646
@discardableResult
2608
2647
func crawlSymbolCuration( in references: [ ResolvedTopicReference ] , bundle: DocumentationBundle , initial: Set < ResolvedTopicReference > = [ ] ) throws -> Set < ResolvedTopicReference > {
2648
+ let signpostHandle = signposter. beginInterval ( " Curate symbols " , id: signposter. makeSignpostID ( ) )
2649
+ defer {
2650
+ signposter. endInterval ( " Curate symbols " , signpostHandle)
2651
+ }
2652
+
2609
2653
var crawler = DocumentationCurator ( in: self , bundle: bundle, initial: initial)
2610
2654
2611
2655
for reference in references {
0 commit comments