@@ -83,6 +83,7 @@ public typealias BundleIdentifier = String
8383/// - ``parents(of:)``
8484///
8585public class DocumentationContext {
86+ private let signposter = ConvertActionConverter . signposter
8687
8788 /// An error that's encountered while interacting with a ``SwiftDocC/DocumentationContext``.
8889 public enum ContextError : DescribedError {
@@ -563,6 +564,11 @@ public class DocumentationContext {
563564 Attempt to resolve links in curation-only documentation, converting any ``TopicReferences`` from `.unresolved` to `.resolved` where possible.
564565 */
565566 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+
566572 let references = Array ( curatedReferences)
567573 let results = Synchronized < [ LinkResolveResult ] > ( [ ] )
568574 results. sync ( { $0. reserveCapacity ( references. count) } )
@@ -708,6 +714,11 @@ public class DocumentationContext {
708714 tutorialArticles: [ SemanticResult < TutorialArticle > ] ,
709715 bundle: DocumentationBundle
710716 ) {
717+ let signpostHandle = signposter. beginInterval ( " Resolve links " , id: signposter. makeSignpostID ( ) )
718+ defer {
719+ signposter. endInterval ( " Resolve links " , signpostHandle)
720+ }
721+
711722 let sourceLanguages = soleRootModuleReference. map { self . sourceLanguages ( for: $0) } ?? [ . swift]
712723
713724 // Tutorial table-of-contents
@@ -1147,6 +1158,11 @@ public class DocumentationContext {
11471158 ) throws {
11481159 // Making sure that we correctly let decoding memory get released, do not remove the autorelease pool.
11491160 try autoreleasepool {
1161+ let signpostHandle = signposter. beginInterval ( " Register symbols " , id: signposter. makeSignpostID ( ) )
1162+ defer {
1163+ signposter. endInterval ( " Register symbols " , signpostHandle)
1164+ }
1165+
11501166 /// We need only unique relationships so we'll collect them in a set.
11511167 var combinedRelationshipsBySelector = [ UnifiedSymbolGraph . Selector : Set < SymbolGraph . Relationship > ] ( )
11521168 /// Also track the unique relationships across all languages and platforms
@@ -1157,7 +1173,9 @@ public class DocumentationContext {
11571173 var moduleReferences = [ String: ResolvedTopicReference] ( )
11581174
11591175 // 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+ }
11611179
11621180 // Set the index and cache storage capacity to avoid ad-hoc storage resizing.
11631181 documentationCache. reserveCapacity ( symbolReferences. count)
@@ -1223,7 +1241,9 @@ public class DocumentationContext {
12231241 let moduleSymbolReference = SymbolReference ( moduleName, interfaceLanguages: moduleInterfaceLanguages, defaultSymbol: moduleSymbol)
12241242 moduleReference = ResolvedTopicReference ( symbolReference: moduleSymbolReference, moduleName: moduleName, bundle: bundle)
12251243
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+ }
12271247
12281248 // For inherited symbols we remove the source docs (if inheriting docs is disabled) before creating their documentation nodes.
12291249 for (_, relationships) in unifiedSymbolGraph. relationshipsByLanguage {
@@ -1375,15 +1395,17 @@ public class DocumentationContext {
13751395 )
13761396
13771397 // 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+ }
13871409 }
13881410
13891411 // Update cache with up-to-date nodes
@@ -2177,9 +2199,16 @@ public class DocumentationContext {
21772199 )
21782200
21792201 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+ }
21832212 } catch {
21842213 // Pipe the error out of the dispatch queue.
21852214 discoveryError. sync ( {
@@ -2191,7 +2220,9 @@ public class DocumentationContext {
21912220 // First, all the resources are added since they don't reference anything else.
21922221 discoveryGroup. async ( queue: discoveryQueue) { [ unowned self] in
21932222 do {
2194- try self . registerMiscResources ( from: bundle)
2223+ try signposter. withIntervalSignpost ( " Load resources " , id: signposter. makeSignpostID ( ) ) {
2224+ try self . registerMiscResources ( from: bundle)
2225+ }
21952226 } catch {
21962227 // Pipe the error out of the dispatch queue.
21972228 discoveryError. sync ( {
@@ -2215,7 +2246,9 @@ public class DocumentationContext {
22152246
22162247 discoveryGroup. async ( queue: discoveryQueue) { [ unowned self] in
22172248 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+ }
22192252 } catch {
22202253 // Pipe the error out of the dispatch queue.
22212254 discoveryError. sync ( {
@@ -2226,7 +2259,9 @@ public class DocumentationContext {
22262259
22272260 discoveryGroup. async ( queue: discoveryQueue) { [ unowned self] in
22282261 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+ }
22302265 } catch {
22312266 // Pipe the error out of the dispatch queue.
22322267 discoveryError. sync ( {
@@ -2361,7 +2396,9 @@ public class DocumentationContext {
23612396 try shouldContinueRegistration ( )
23622397
23632398 // 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+ }
23652402
23662403 // Crawl the rest of the symbols that haven't been crawled so far in hierarchy pre-order.
23672404 allCuratedReferences = try crawlSymbolCuration ( in: automaticallyCurated. map ( \. symbol) , bundle: bundle, initial: allCuratedReferences)
@@ -2407,7 +2444,9 @@ public class DocumentationContext {
24072444 }
24082445
24092446 // 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+ }
24112450
24122451 preResolveModuleNames ( )
24132452 }
@@ -2606,6 +2645,11 @@ public class DocumentationContext {
26062645 /// - Returns: The references of all the symbols that were curated.
26072646 @discardableResult
26082647 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+
26092653 var crawler = DocumentationCurator ( in: self , bundle: bundle, initial: initial)
26102654
26112655 for reference in references {
0 commit comments