Skip to content

Commit eec57a2

Browse files
authored
Rename "Technology" to "Tutorial Table of Contents" (#1039)
* Rename Technology to match user-facing TutorialTableOfContents term * Update usage of the renamed technology type * Update other API that use the Technology name * Rename technology case for URL creation * Rename technology documentation node kind * Rename bundle's technology reference properties * Update directive symbol graph file * Update additional uses of technology in tests * Rename `preferTechnologysRoot` to `preferTutorialTableOfContentsRoot * Add comments to deprecations to indicate when they can be removed * Update link in contributor documentation * Update additional variables and code comments * Add back deprecated fallbackOverview cases in switch statements * Add "Results" suffix to TOC semantic results lists to avoid `for A in A {}` pattern
1 parent 8643c59 commit eec57a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+313
-249
lines changed

Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public struct DocumentationBundle {
128128
self.themeSettings = themeSettings
129129
self.rootReference = ResolvedTopicReference(bundleIdentifier: info.identifier, path: "/", sourceLanguage: .swift)
130130
self.documentationRootReference = ResolvedTopicReference(bundleIdentifier: info.identifier, path: NodeURLGenerator.Path.documentationFolder, sourceLanguage: .swift)
131-
self.tutorialsRootReference = ResolvedTopicReference(bundleIdentifier: info.identifier, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift)
132-
self.technologyTutorialsRootReference = tutorialsRootReference.appendingPath(urlReadablePath(info.displayName))
131+
self.tutorialTableOfContentsContainer = ResolvedTopicReference(bundleIdentifier: info.identifier, path: NodeURLGenerator.Path.tutorialsFolder, sourceLanguage: .swift)
132+
self.tutorialsContainerReference = tutorialTableOfContentsContainer.appendingPath(urlReadablePath(info.displayName))
133133
self.articlesDocumentationRootReference = documentationRootReference.appendingPath(urlReadablePath(info.displayName))
134134
}
135135

@@ -154,12 +154,22 @@ public struct DocumentationBundle {
154154
/// Default path to resolve symbol links.
155155
public private(set) var documentationRootReference: ResolvedTopicReference
156156

157-
/// Default path to resolve technology links.
158-
public var tutorialsRootReference: ResolvedTopicReference
157+
@available(*, deprecated, renamed: "tutorialTableOfContentsContainer", message: "Use 'tutorialTableOfContentsContainer' instead. This deprecated API will be removed after 6.2 is released")
158+
public var tutorialsRootReference: ResolvedTopicReference {
159+
tutorialTableOfContentsContainer
160+
}
161+
162+
/// Default path to resolve tutorial table-of-contents links.
163+
public var tutorialTableOfContentsContainer: ResolvedTopicReference
164+
165+
@available(*, deprecated, renamed: "tutorialsContainerReference", message: "Use 'tutorialsContainerReference' instead. This deprecated API will be removed after 6.2 is released")
166+
public var technologyTutorialsRootReference: ResolvedTopicReference {
167+
tutorialsContainerReference
168+
}
169+
170+
/// Default path to resolve tutorial links.
171+
public var tutorialsContainerReference: ResolvedTopicReference
159172

160-
/// Default path to resolve tutorials.
161-
public var technologyTutorialsRootReference: ResolvedTopicReference
162-
163173
/// Default path to resolve articles.
164174
public var articlesDocumentationRootReference: ResolvedTopicReference
165175
}

Sources/SwiftDocC/Infrastructure/DocumentationContext+Breadcrumbs.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ extension DocumentationContext {
1313
struct PathOptions: OptionSet {
1414
let rawValue: Int
1515

16-
/// Prefer a technology as the canonical path over a shorter path.
17-
static let preferTechnologyRoot = PathOptions(rawValue: 1 << 0)
16+
/// Prefer a tutorial table-of-contents page as the canonical path over a shorter path.
17+
static let preferTutorialTableOfContentsRoot = PathOptions(rawValue: 1 << 0)
1818
}
1919

2020
/// Finds all finite (acyclic) paths, also called "breadcrumbs", to the given reference in the topic graph.
@@ -38,9 +38,9 @@ extension DocumentationContext {
3838
// To match the caller's expectations we remove the starting point and then flip the paths.
3939
.map { $0.dropFirst().reversed() }
4040
.sorted { (lhs, rhs) -> Bool in
41-
// Order a path rooted in a technology as the canonical one.
42-
if options.contains(.preferTechnologyRoot), let first = lhs.first {
43-
return try! entity(with: first).semantic is Technology
41+
// Order a path rooted in a tutorial table-of-contents as the canonical one.
42+
if options.contains(.preferTutorialTableOfContentsRoot), let first = lhs.first {
43+
return try! entity(with: first).semantic is TutorialTableOfContents
4444
}
4545

4646
return breadcrumbsAreInIncreasingOrder(lhs, rhs)

Sources/SwiftDocC/Infrastructure/DocumentationContext.swift

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,15 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
136136
/// The set of all manually curated references if `shouldStoreManuallyCuratedReferences` was true at the time of processing and has remained `true` since.. Nil if curation has not been processed yet.
137137
public private(set) var manuallyCuratedReferences: Set<ResolvedTopicReference>?
138138

139-
/// The root technology nodes of the Topic Graph.
139+
@available(*, deprecated, renamed: "tutorialTableOfContentsReferences", message: "Use 'tutorialTableOfContentsReferences' This deprecated API will be removed after 6.2 is released")
140140
public var rootTechnologies: [ResolvedTopicReference] {
141+
tutorialTableOfContentsReferences
142+
}
143+
144+
/// The tutorial table-of-contents nodes in the topic graph.
145+
public var tutorialTableOfContentsReferences: [ResolvedTopicReference] {
141146
return topicGraph.nodes.values.compactMap { node in
142-
guard node.kind == .technology && parents(of: node.reference).isEmpty else {
147+
guard node.kind == .tutorialTableOfContents && parents(of: node.reference).isEmpty else {
143148
return nil
144149
}
145150
return node.reference
@@ -606,65 +611,65 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
606611
/// up in the context, not from the arrays that was passed as arguments.
607612
///
608613
/// - Parameters:
609-
/// - technologies: The list of temporary 'technology' pages.
614+
/// - tutorialTableOfContentsResults: The list of temporary 'tutorial table-of-contents' pages.
610615
/// - tutorials: The list of temporary 'tutorial' pages.
611616
/// - tutorialArticles: The list of temporary 'tutorialArticle' pages.
612617
/// - bundle: The bundle to resolve links against.
613-
private func resolveLinks(technologies: [SemanticResult<Technology>],
614-
tutorials: [SemanticResult<Tutorial>],
615-
tutorialArticles: [SemanticResult<TutorialArticle>],
616-
bundle: DocumentationBundle) {
617-
618+
private func resolveLinks(
619+
tutorialTableOfContents tutorialTableOfContentsResults: [SemanticResult<TutorialTableOfContents>],
620+
tutorials: [SemanticResult<Tutorial>],
621+
tutorialArticles: [SemanticResult<TutorialArticle>],
622+
bundle: DocumentationBundle
623+
) {
618624
let sourceLanguages = soleRootModuleReference.map { self.sourceLanguages(for: $0) } ?? [.swift]
619625

620-
// Technologies
621-
622-
for technologyResult in technologies {
626+
// Tutorial table-of-contents
627+
628+
for tableOfContentsResult in tutorialTableOfContentsResults {
623629
autoreleasepool {
624-
let url = technologyResult.source
625-
let unresolvedTechnology = technologyResult.value
630+
let url = tableOfContentsResult.source
626631
var resolver = ReferenceResolver(context: self, bundle: bundle)
627-
let technology = resolver.visit(unresolvedTechnology) as! Technology
632+
let tableOfContents = resolver.visit(tableOfContentsResult.value) as! TutorialTableOfContents
628633
diagnosticEngine.emit(resolver.problems)
629634

630635
// Add to document map
631-
documentLocationMap[url] = technologyResult.topicGraphNode.reference
632-
633-
let technologyReference = technologyResult.topicGraphNode.reference.withSourceLanguages(sourceLanguages)
636+
documentLocationMap[url] = tableOfContentsResult.topicGraphNode.reference
634637

635-
let technologyNode = DocumentationNode(
636-
reference: technologyReference,
637-
kind: .technology,
638+
let tableOfContentsReference = tableOfContentsResult.topicGraphNode.reference.withSourceLanguages(sourceLanguages)
639+
640+
let tutorialTableOfContentsNode = DocumentationNode(
641+
reference: tableOfContentsReference,
642+
kind: .tutorialTableOfContents,
638643
sourceLanguage: Self.defaultLanguage(in: sourceLanguages),
639644
availableSourceLanguages: sourceLanguages,
640-
name: .conceptual(title: technology.intro.title),
641-
markup: technology.originalMarkup,
642-
semantic: technology
645+
name: .conceptual(title: tableOfContents.intro.title),
646+
markup: tableOfContents.originalMarkup,
647+
semantic: tableOfContents
643648
)
644-
documentationCache[technologyReference] = technologyNode
649+
documentationCache[tableOfContentsReference] = tutorialTableOfContentsNode
645650

646-
// Update the reference in the topic graph with the technology's available languages.
651+
// Update the reference in the topic graph with the table-of-contents page's available languages.
647652
topicGraph.updateReference(
648-
technologyResult.topicGraphNode.reference,
649-
newReference: technologyReference
653+
tableOfContentsResult.topicGraphNode.reference,
654+
newReference: tableOfContentsReference
650655
)
651656

652657
let anonymousVolumeName = "$volume"
653658

654-
for volume in technology.volumes {
659+
for volume in tableOfContents.volumes {
655660
// Graph node: Volume
656-
let volumeReference = technologyNode.reference.appendingPath(volume.name ?? anonymousVolumeName)
661+
let volumeReference = tutorialTableOfContentsNode.reference.appendingPath(volume.name ?? anonymousVolumeName)
657662
let volumeNode = TopicGraph.Node(reference: volumeReference, kind: .volume, source: .file(url: url), title: volume.name ?? anonymousVolumeName)
658663
topicGraph.addNode(volumeNode)
659664

660-
// Graph edge: Technology -> Volume
661-
topicGraph.addEdge(from: technologyResult.topicGraphNode, to: volumeNode)
665+
// Graph edge: Tutorial table-of-contents -> Volume
666+
topicGraph.addEdge(from: tableOfContentsResult.topicGraphNode, to: volumeNode)
662667

663668
for chapter in volume.chapters {
664669
// Graph node: Module
665670
let baseNodeReference: ResolvedTopicReference
666671
if volume.name == nil {
667-
baseNodeReference = technologyNode.reference
672+
baseNodeReference = tutorialTableOfContentsNode.reference
668673
} else {
669674
baseNodeReference = volumeNode.reference
670675
}
@@ -761,15 +766,15 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
761766
}
762767

763768
private func registerDocuments(from bundle: DocumentationBundle) throws -> (
764-
technologies: [SemanticResult<Technology>],
769+
tutorialTableOfContentsResults: [SemanticResult<TutorialTableOfContents>],
765770
tutorials: [SemanticResult<Tutorial>],
766771
tutorialArticles: [SemanticResult<TutorialArticle>],
767772
articles: [SemanticResult<Article>],
768773
documentationExtensions: [SemanticResult<Article>]
769774
) {
770775
// First, try to understand the basic structure of the document by
771776
// analyzing it and putting references in as "unresolved".
772-
var technologies = [SemanticResult<Technology>]()
777+
var tutorialTableOfContentsResults = [SemanticResult<TutorialTableOfContents>]()
773778
var tutorials = [SemanticResult<Tutorial>]()
774779
var tutorialArticles = [SemanticResult<TutorialArticle>]()
775780
var articles = [SemanticResult<Article>]()
@@ -857,11 +862,11 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
857862
Add all topic graph nodes up front before resolution starts, because
858863
there may be circular linking.
859864
*/
860-
if let technology = analyzed as? Technology {
861-
let topicGraphNode = TopicGraph.Node(reference: reference, kind: .technology, source: .file(url: url), title: technology.intro.title)
865+
if let tableOfContents = analyzed as? TutorialTableOfContents {
866+
let topicGraphNode = TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .file(url: url), title: tableOfContents.intro.title)
862867
topicGraph.addNode(topicGraphNode)
863-
let result = SemanticResult(value: technology, source: url, topicGraphNode: topicGraphNode)
864-
technologies.append(result)
868+
let result = SemanticResult(value: tableOfContents, source: url, topicGraphNode: topicGraphNode)
869+
tutorialTableOfContentsResults.append(result)
865870
} else if let tutorial = analyzed as? Tutorial {
866871
let topicGraphNode = TopicGraph.Node(reference: reference, kind: .tutorial, source: .file(url: url), title: tutorial.title ?? "")
867872
topicGraph.addNode(topicGraphNode)
@@ -920,7 +925,7 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
920925
}
921926
}
922927

923-
return (technologies, tutorials, tutorialArticles, articles, documentationExtensions)
928+
return (tutorialTableOfContentsResults, tutorials, tutorialArticles, articles, documentationExtensions)
924929
}
925930

926931
private func insertLandmarks(_ landmarks: some Sequence<Landmark>, from topicGraphNode: TopicGraph.Node, source url: URL) {
@@ -2098,7 +2103,7 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
20982103
// symbols or attempt to resolve links/references since the topic graph may not contain all documents
20992104
// or all symbols yet.
21002105
var result: (
2101-
technologies: [SemanticResult<Technology>],
2106+
tutorialTableOfContentsResults: [SemanticResult<TutorialTableOfContents>],
21022107
tutorials: [SemanticResult<Tutorial>],
21032108
tutorialArticles: [SemanticResult<TutorialArticle>],
21042109
articles: [SemanticResult<Article>],
@@ -2137,7 +2142,7 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
21372142
}
21382143

21392144
// All discovery went well, process the inputs.
2140-
let (technologies, tutorials, tutorialArticles, allArticles, documentationExtensions) = result
2145+
let (tutorialTableOfContentsResults, tutorials, tutorialArticles, allArticles, documentationExtensions) = result
21412146
var (otherArticles, rootPageArticles) = splitArticles(allArticles)
21422147

21432148
let globalOptions = (allArticles + documentationExtensions).compactMap { article in
@@ -2185,8 +2190,8 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
21852190
for article in tutorialArticles {
21862191
hierarchyBasedResolver.addTutorialArticle(article)
21872192
}
2188-
for technology in technologies {
2189-
hierarchyBasedResolver.addTechnology(technology)
2193+
for tutorialTableOfContents in tutorialTableOfContentsResults {
2194+
hierarchyBasedResolver.addTutorialTableOfContents(tutorialTableOfContents)
21902195
}
21912196

21922197
registerRootPages(from: rootPageArticles, in: bundle)
@@ -2221,13 +2226,13 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
22212226

22222227
// Third, any processing that relies on resolving other content is done, mainly resolving links.
22232228
preResolveExternalLinks(semanticObjects:
2224-
technologies.map(referencedSemanticObject) +
2229+
tutorialTableOfContentsResults.map(referencedSemanticObject) +
22252230
tutorials.map(referencedSemanticObject) +
22262231
tutorialArticles.map(referencedSemanticObject),
22272232
localBundleID: bundle.identifier)
22282233

22292234
resolveLinks(
2230-
technologies: technologies,
2235+
tutorialTableOfContents: tutorialTableOfContentsResults,
22312236
tutorials: tutorials,
22322237
tutorialArticles: tutorialArticles,
22332238
bundle: bundle
@@ -2913,8 +2918,8 @@ public class DocumentationContext: DocumentationContextDataProviderDelegate {
29132918
extension DocumentationContext {
29142919

29152920
/// The nodes that are allowed to be roots in the topic graph.
2916-
static var allowedRootNodeKinds: [DocumentationNode.Kind] = [.technology, .module]
2917-
2921+
static var allowedRootNodeKinds: [DocumentationNode.Kind] = [.tutorialTableOfContents, .module]
2922+
29182923
func analyzeTopicGraph() {
29192924
// Find all nodes that are loose in the graph and have no parent but aren't supposed to
29202925
let unexpectedRoots = topicGraph.nodes.values.filter { node in

Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ private final class FallbackResolverBasedLinkResolver {
193193
// First look up articles path
194194
currentBundle.articlesDocumentationRootReference.url.appendingPathComponent(unresolvedReference.path),
195195
// Then technology tutorials root path (for individual tutorial pages)
196-
currentBundle.technologyTutorialsRootReference.url.appendingPathComponent(unresolvedReference.path),
196+
currentBundle.tutorialsContainerReference.url.appendingPathComponent(unresolvedReference.path),
197197
// Then tutorials root path (for tutorial table of contents pages)
198-
currentBundle.tutorialsRootReference.url.appendingPathComponent(unresolvedReference.path),
198+
currentBundle.tutorialTableOfContentsContainer.url.appendingPathComponent(unresolvedReference.path),
199199
])
200200
}
201201
// Try resolving in the local context (as child)

Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ struct PathHierarchy {
419419
/// - Parameter name: The path component name of the tutorial overview (the file name without the file extension).
420420
/// - Returns: The new unique identifier that represent this tutorial overview.
421421
mutating func addTutorialOverview(name: String) -> ResolvedIdentifier {
422-
return addNonSymbolChild(parent: tutorialOverviewContainer.identifier, name: name, kind: "technology")
422+
return addNonSymbolChild(parent: tutorialOverviewContainer.identifier, name: name, kind: "tutorial-toc")
423423
}
424424

425425
/// Adds a non-symbol child element to an existing element in the path hierarchy.

0 commit comments

Comments
 (0)