From 17a20373d949abd1877f41c32927ff6e97f61f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 14 Oct 2025 10:53:58 +0200 Subject: [PATCH 1/6] Extract the SourceLanguage type to a new "Common" target --- Package.swift | 26 ++++++++++++++++++- .../Model => Common}/SourceLanguage.swift | 6 +++-- .../GeneratedCurationWriter.swift | 3 ++- .../Navigator/RenderNode+NavigatorIndex.swift | 1 + .../Infrastructure/CoverageDataEntry.swift | 3 ++- .../Infrastructure/DocumentationContext.swift | 1 + ...enceResolver+DeprecatedCommunication.swift | 1 + .../OutOfProcessReferenceResolver.swift | 1 + .../LinkResolver+NavigatorIndex.swift | 1 + .../Link Resolution/LinkResolver.swift | 1 + .../PathHierarchy+PathComponent.swift | 3 ++- .../PathHierarchy+TypeSignature.swift | 3 ++- .../Link Resolution/PathHierarchy.swift | 1 + ...erarchyBasedLinkResolver+Breadcrumbs.swift | 3 ++- .../PathHierarchyBasedLinkResolver.swift | 1 + .../GeneratedDocumentationTopics.swift | 1 + .../Symbol Graph/SymbolGraphLoader.swift | 1 + .../Symbol Graph/SymbolReference.swift | 3 ++- .../Topic Graph/AutomaticCuration.swift | 2 +- .../LinkTargets/LinkDestinationSummary.swift | 1 + .../SwiftDocC/Model/DocumentationNode.swift | 1 + Sources/SwiftDocC/Model/Identifier.swift | 1 + .../Model/ParametersAndReturnValidator.swift | 3 ++- .../DocumentationContentRenderer.swift | 1 + .../RenderHierarchyTranslator.swift | 1 + .../Rendering/RenderNodeTranslator.swift | 1 + .../Variants/VariantPatchOperation.swift | 3 ++- .../SwiftDocC/Semantics/Article/Article.swift | 1 + .../Metadata/SupportedLanguage.swift | 3 ++- .../Symbol/DocumentationDataVariants.swift | 3 ++- .../SymbolGraphCreation.swift | 5 ++-- .../Action/Actions/Merge/MergeAction.swift | 3 ++- .../SourceLanguageTests.swift | 4 +-- .../Benchmark/ExternalTopicsHashTests.swift | 1 + .../Indexing/ExternalRenderNodeTests.swift | 1 + .../Indexing/NavigatorIndexTests.swift | 1 + ...xt+MixedLanguageSourceLanguagesTests.swift | 1 + .../DocumentationContextTests.swift | 1 + .../ExternalPathHierarchyResolverTests.swift | 1 + .../ExternalReferenceResolverTests.swift | 1 + .../Infrastructure/PathHierarchyTests.swift | 1 + .../ReferenceResolverTests.swift | 1 + .../Infrastructure/SnippetResolverTests.swift | 1 + ...SymbolGraphRelationshipsBuilderTests.swift | 1 + .../Infrastructure/SymbolReferenceTests.swift | 1 + .../TestExternalReferenceResolvers.swift | 1 + .../LinkDestinationSummaryTests.swift | 1 + .../ParametersAndReturnValidatorTests.swift | 1 + .../SemaToRenderNodeDictionaryDataTests.swift | 1 + .../SemaToRenderNodeHTTPRequestTests.swift | 1 + .../SemaToRenderNodeMultiLanguageTests.swift | 1 + .../Rendering/TermListTests.swift | 1 + .../Semantics/DoxygenTests.swift | 1 + .../ConvertActionTests.swift | 1 + 54 files changed, 95 insertions(+), 19 deletions(-) rename Sources/{SwiftDocC/Model => Common}/SourceLanguage.swift (97%) rename Tests/{SwiftDocCTests/Model => CommonTests}/SourceLanguageTests.swift (87%) diff --git a/Package.swift b/Package.swift index f954d00903..7ca1391543 100644 --- a/Package.swift +++ b/Package.swift @@ -2,7 +2,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2024 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -43,6 +43,7 @@ let package = Package( .target( name: "SwiftDocC", dependencies: [ + .target(name: "Common"), .product(name: "Markdown", package: "swift-markdown"), .product(name: "SymbolKit", package: "swift-docc-symbolkit"), .product(name: "CLMDB", package: "swift-lmdb"), @@ -54,6 +55,7 @@ let package = Package( name: "SwiftDocCTests", dependencies: [ .target(name: "SwiftDocC"), + .target(name: "Common"), .target(name: "SwiftDocCTestUtilities"), ], resources: [ @@ -69,6 +71,7 @@ let package = Package( name: "SwiftDocCUtilities", dependencies: [ .target(name: "SwiftDocC"), + .target(name: "Common"), .product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.macOS, .iOS, .linux, .android])), .product(name: "ArgumentParser", package: "swift-argument-parser") ], @@ -79,6 +82,7 @@ let package = Package( dependencies: [ .target(name: "SwiftDocCUtilities"), .target(name: "SwiftDocC"), + .target(name: "Common"), .target(name: "SwiftDocCTestUtilities"), ], resources: [ @@ -93,6 +97,7 @@ let package = Package( name: "SwiftDocCTestUtilities", dependencies: [ .target(name: "SwiftDocC"), + .target(name: "Common"), .product(name: "SymbolKit", package: "swift-docc-symbolkit"), ], swiftSettings: swiftSettings @@ -106,6 +111,25 @@ let package = Package( ], swiftSettings: swiftSettings ), + + // A few common types and core functionality that's useable by all other targets. + .target( + name: "Common", + dependencies: [ + // This target shouldn't have any local dependencies so that all other targets can depend on it. + // We can add dependencies on SymbolKit and Markdown here but they're not needed yet. + ], + swiftSettings: swiftSettings // FIXME: Use `[.swiftLanguageMode(.v6)]` here + ), + + .testTarget( + name: "CommonTests", + dependencies: [ + .target(name: "Common"), + .target(name: "SwiftDocCTestUtilities"), + ], + swiftSettings: swiftSettings // FIXME: Use `[.swiftLanguageMode(.v6)]` here + ), // Test app for SwiftDocCUtilities .executableTarget( diff --git a/Sources/SwiftDocC/Model/SourceLanguage.swift b/Sources/Common/SourceLanguage.swift similarity index 97% rename from Sources/SwiftDocC/Model/SourceLanguage.swift rename to Sources/Common/SourceLanguage.swift index 2866213456..c9f7c04ad9 100644 --- a/Sources/SwiftDocC/Model/SourceLanguage.swift +++ b/Sources/Common/SourceLanguage.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -157,7 +157,9 @@ public struct SourceLanguage: Hashable, Codable, Comparable { try container.encode(self.name, forKey: SourceLanguage.CodingKeys.name) try container.encode(self.id, forKey: SourceLanguage.CodingKeys.id) - try container.encodeIfNotEmpty(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases) + if !self.idAliases.isEmpty { + try container.encode(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases) + } try container.encode(self.linkDisambiguationID, forKey: SourceLanguage.CodingKeys.linkDisambiguationID) } diff --git a/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift b/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift index a700bde21a..36a7faba7e 100644 --- a/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift +++ b/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2024 Apple Inc. and the Swift project authors + Copyright (c) 2024-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ public import Foundation import SymbolKit +import Common /// A type that writes the auto-generated curation into documentation extension files. public struct GeneratedCurationWriter { diff --git a/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift b/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift index 21fc7aa5ff..c3b9e7581f 100644 --- a/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift +++ b/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift @@ -9,6 +9,7 @@ */ import Foundation +import Common /// A language specific representation of a render node value for building a navigator index. protocol NavigatorIndexableRenderNodeRepresentation { diff --git a/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift b/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift index 11ca715d7a..f767e9b02e 100644 --- a/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift +++ b/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2024 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common /// `CoverageDataEntry` represents coverage data for one symbol/USR. public struct CoverageDataEntry: CustomStringConvertible, Codable { diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index 9d4d83216b..193c99ca4e 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -11,6 +11,7 @@ public import Foundation import Markdown import SymbolKit +public import Common /// The documentation context manages the in-memory model for the built documentation. /// diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift index 153a9aa72d..b5adbad568 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift @@ -10,6 +10,7 @@ public import Foundation public import SymbolKit +public import Common extension OutOfProcessReferenceResolver { diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index 25523e6520..a7bde00382 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -10,6 +10,7 @@ public import Foundation private import Markdown +import Common /// A reference resolver that launches and interactively communicates with another process or service to resolve links. /// diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift index 2bb01f5abe..56ae120f63 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common /// A rendering-friendly representation of a external node. package struct ExternalRenderNode { diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift index d7a5f331cf..15145db00c 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift @@ -9,6 +9,7 @@ */ import Foundation +import Common /// A class that resolves documentation links by orchestrating calls to other link resolver implementations. public class LinkResolver { diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift index f067c735b9..0b720175fa 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2024 Apple Inc. and the Swift project authors + Copyright (c) 2023-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common /// All known symbol kind identifiers. /// diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift index 06d33cdf38..efb0774b90 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2024 Apple Inc. and the Swift project authors + Copyright (c) 2023-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common // MARK: From symbols diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift index d4891efab4..37ce96aec8 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common /// An opaque identifier that uniquely identifies a resolved entry in the path hierarchy, /// diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift index d806b00e08..8b76bda165 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2024 Apple Inc. and the Swift project authors + Copyright (c) 2024-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common extension PathHierarchyBasedLinkResolver { diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift index 652580be28..8cb9467dc9 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common /// A type that encapsulates resolving links by searching a hierarchy of path components. final class PathHierarchyBasedLinkResolver { diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift index cf461d3286..fbcc5732da 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift @@ -11,6 +11,7 @@ import Foundation import SymbolKit import Markdown +import Common /// A collection of APIs to generate documentation topics. enum GeneratedDocumentationTopics { diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift index 620d184122..ea2e847a1f 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common /// Loads symbol graph files from a documentation bundle. /// diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift index e4ce644f78..db4edfa7bf 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ import Foundation public import SymbolKit +public import Common extension String { /// Returns a copy of the string with an appended hash of the given identifier. diff --git a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift index d0deba7971..ea5289ff22 100644 --- a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift +++ b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift @@ -11,7 +11,7 @@ import Foundation import Markdown import SymbolKit - +import Common private let automaticSeeAlsoLimit: Int = { ProcessInfo.processInfo.environment["DOCC_AUTOMATIC_SEE_ALSO_LIMIT"].flatMap { Int($0) } ?? 15 diff --git a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift index e6407e9057..8aca73da59 100644 --- a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift +++ b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift @@ -11,6 +11,7 @@ public import Foundation import Markdown import SymbolKit +public import Common // Link resolution works in two parts: // diff --git a/Sources/SwiftDocC/Model/DocumentationNode.swift b/Sources/SwiftDocC/Model/DocumentationNode.swift index 0ff7e33841..bcdfcde421 100644 --- a/Sources/SwiftDocC/Model/DocumentationNode.swift +++ b/Sources/SwiftDocC/Model/DocumentationNode.swift @@ -11,6 +11,7 @@ import Foundation public import Markdown public import SymbolKit +public import Common /// A documentation node holds all the information about a documentation entity's content. /// diff --git a/Sources/SwiftDocC/Model/Identifier.swift b/Sources/SwiftDocC/Model/Identifier.swift index 469af2f4ca..13e304b82d 100644 --- a/Sources/SwiftDocC/Model/Identifier.swift +++ b/Sources/SwiftDocC/Model/Identifier.swift @@ -11,6 +11,7 @@ public import Foundation import SymbolKit public import Markdown +public import Common /// A resolved or unresolved reference to a piece of documentation. /// diff --git a/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift b/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift index efa43e189b..dbf8383f96 100644 --- a/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift +++ b/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2024 Apple Inc. and the Swift project authors + Copyright (c) 2023-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -11,6 +11,7 @@ import Foundation import SymbolKit import Markdown +import Common /// A type that validates and filters a symbol's parameter and return value documentation based on the symbol's function signature. /// diff --git a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift index 0d6ee8dd40..00a96211b9 100644 --- a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift +++ b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift @@ -11,6 +11,7 @@ import Foundation import SymbolKit import Markdown +import Common public struct RenderReferenceDependencies { public var topicReferences = [ResolvedTopicReference]() diff --git a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift index c62907e757..8f433fc399 100644 --- a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift @@ -9,6 +9,7 @@ */ import Foundation +import Common /// A hierarchy translator that converts a part of the topic graph into a hierarchy tree. struct RenderHierarchyTranslator { diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift index a32006d4af..fa6bd746a7 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift @@ -11,6 +11,7 @@ public import Foundation public import Markdown import SymbolKit +import Common /// A visitor which converts a semantic model into a render node. /// diff --git a/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift b/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift index 848915709f..860157a403 100644 --- a/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift +++ b/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2024 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -9,6 +9,7 @@ */ import Foundation +import Common /// A patch to update a render node value. public enum VariantPatchOperation { diff --git a/Sources/SwiftDocC/Semantics/Article/Article.swift b/Sources/SwiftDocC/Semantics/Article/Article.swift index 42195c74c4..f5ab4eb1e4 100644 --- a/Sources/SwiftDocC/Semantics/Article/Article.swift +++ b/Sources/SwiftDocC/Semantics/Article/Article.swift @@ -10,6 +10,7 @@ public import Foundation public import Markdown +public import Common /// The in-memory representation of an article. /// diff --git a/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift b/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift index 0f0231251e..c64b0eaca0 100644 --- a/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift +++ b/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023 Apple Inc. and the Swift project authors + Copyright (c) 2023-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ import Foundation public import Markdown +public import Common /// A directive that controls what programming languages an article is available in. /// diff --git a/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift b/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift index 5452d0c6f9..2a7bfc78f5 100644 --- a/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift +++ b/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2022 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,6 +10,7 @@ import Foundation public import SymbolKit +import Common /// A model type that encapsulates variants of documentation node data. /// diff --git a/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift b/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift index 6a15e4596b..27af5d7935 100644 --- a/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift +++ b/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2024 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -12,7 +12,8 @@ import Foundation public import XCTest package import SymbolKit -package import SwiftDocC +import SwiftDocC +package import Common // MARK: - Symbol Graph objects diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift index d68fa32af6..7409285cb8 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2024 Apple Inc. and the Swift project authors + Copyright (c) 2024-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -11,6 +11,7 @@ import Foundation import SwiftDocC import Markdown +import Common /// An action that merges a list of documentation archives into a combined archive. struct MergeAction: AsyncAction { diff --git a/Tests/SwiftDocCTests/Model/SourceLanguageTests.swift b/Tests/CommonTests/SourceLanguageTests.swift similarity index 87% rename from Tests/SwiftDocCTests/Model/SourceLanguageTests.swift rename to Tests/CommonTests/SourceLanguageTests.swift index 734c5c7a1d..7e67953f3b 100644 --- a/Tests/SwiftDocCTests/Model/SourceLanguageTests.swift +++ b/Tests/CommonTests/SourceLanguageTests.swift @@ -1,14 +1,14 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2022-2023 Apple Inc. and the Swift project authors + Copyright (c) 2022-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information See https://swift.org/CONTRIBUTORS.txt for Swift project authors */ -@testable import SwiftDocC +import Common import XCTest class SourceLanguageTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift index ee391de385..e80db9ae48 100644 --- a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift @@ -10,6 +10,7 @@ import XCTest @_spi(ExternalLinks) @testable import SwiftDocC +import Common import Markdown class ExternalTopicsGraphHashTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift b/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift index 1d5ed2b1cc..758dc891f9 100644 --- a/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift +++ b/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift @@ -11,6 +11,7 @@ import Foundation import XCTest @_spi(ExternalLinks) @testable import SwiftDocC +import Common import SwiftDocCTestUtilities class ExternalRenderNodeTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift index 6029282a9d..03e01e11da 100644 --- a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift +++ b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift @@ -10,6 +10,7 @@ import XCTest @testable import SwiftDocC +import Common import SwiftDocCTestUtilities typealias Node = NavigatorTree.Node diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift index 2206ad29ea..330fbd96af 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift @@ -10,6 +10,7 @@ import XCTest @testable import SwiftDocC +import Common class DocumentationContext_MixedLanguageSourceLanguagesTests: XCTestCase { func testArticleAvailableSourceLanguagesIsSwiftInSwiftModule() async throws { diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index e788f1b192..175d16a8b8 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -11,6 +11,7 @@ import XCTest import SymbolKit @testable @_spi(ExternalLinks) import SwiftDocC +import Common import Markdown import SwiftDocCTestUtilities diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift index 0d0bab01b5..032b0b0479 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift @@ -12,6 +12,7 @@ import XCTest import Markdown import SymbolKit @testable @_spi(ExternalLinks) import SwiftDocC +import Common import SwiftDocCTestUtilities class ExternalPathHierarchyResolverTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 803868d2ad..41e45a1cb6 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -10,6 +10,7 @@ import XCTest @_spi(ExternalLinks) @testable import SwiftDocC +import Common import Markdown import SymbolKit import SwiftDocCTestUtilities diff --git a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift index c7c54f5495..e247737ae7 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift @@ -11,6 +11,7 @@ import XCTest import SymbolKit @testable import SwiftDocC +import Common import SwiftDocCTestUtilities import Markdown diff --git a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift index 4a37493359..bb5c278780 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift @@ -10,6 +10,7 @@ import XCTest @_spi(ExternalLinks) @testable import SwiftDocC +import Common import Markdown import SymbolKit diff --git a/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift index 84e39551d5..690f00fa99 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift @@ -10,6 +10,7 @@ import XCTest @testable import SwiftDocC +import Common import SymbolKit import SwiftDocCTestUtilities diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift index 329a53f3b9..57654130da 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift @@ -12,6 +12,7 @@ import Foundation import XCTest @testable import SymbolKit @testable import SwiftDocC +import Common class SymbolGraphRelationshipsBuilderTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift index 49d4985b93..c28f8993c1 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift @@ -11,6 +11,7 @@ import XCTest @testable import SymbolKit @testable import SwiftDocC +import Common import SwiftDocCTestUtilities class SymbolReferenceTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift index d02463b820..1d1477f4db 100644 --- a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift +++ b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift @@ -10,6 +10,7 @@ import Foundation @_spi(ExternalLinks) @testable import SwiftDocC +import Common import SymbolKit import Markdown diff --git a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift index 5ac4655d92..349cd2610d 100644 --- a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift +++ b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift @@ -11,6 +11,7 @@ import XCTest import SymbolKit @testable import SwiftDocC +import Common import SwiftDocCTestUtilities class LinkDestinationSummaryTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift index 912ac6fdb3..a7d1866d15 100644 --- a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift +++ b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift @@ -13,6 +13,7 @@ import XCTest import Markdown @testable import SymbolKit @testable import SwiftDocC +import Common import SwiftDocCTestUtilities class ParametersAndReturnValidatorTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift index b0335f9745..3db1ed26a5 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift @@ -10,6 +10,7 @@ import Foundation @testable import SwiftDocC +import Common import SymbolKit import XCTest diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift index 6ebf753a32..d699d01764 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift @@ -10,6 +10,7 @@ import Foundation @testable import SwiftDocC +import Common import SymbolKit import XCTest diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift index d3a3fc2446..b523749e05 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift @@ -10,6 +10,7 @@ import Foundation @testable import SwiftDocC +import Common import SymbolKit import SwiftDocCTestUtilities import XCTest diff --git a/Tests/SwiftDocCTests/Rendering/TermListTests.swift b/Tests/SwiftDocCTests/Rendering/TermListTests.swift index d5e496456c..42eeb375c6 100644 --- a/Tests/SwiftDocCTests/Rendering/TermListTests.swift +++ b/Tests/SwiftDocCTests/Rendering/TermListTests.swift @@ -12,6 +12,7 @@ import Foundation import XCTest import Markdown @testable import SwiftDocC +import Common import SwiftDocCTestUtilities class TermListTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift index 100ad050b7..2bb2648333 100644 --- a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift @@ -12,6 +12,7 @@ import Foundation import XCTest @testable import SwiftDocC +import Common import SwiftDocCTestUtilities @testable import SymbolKit diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift index a4f76bcd53..a7a7693383 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift @@ -13,6 +13,7 @@ import Foundation @testable @_spi(ExternalLinks) import SwiftDocC @testable import SwiftDocCUtilities import SymbolKit +import Common import Markdown @testable import SwiftDocCTestUtilities From b413e1d7e6054eae65b59f54989a980312510e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Tue, 14 Oct 2025 11:18:33 +0200 Subject: [PATCH 2/6] Extract the Lock type to the same "Common" target --- Sources/{SwiftDocC/Utility => Common}/Synchronization.swift | 0 Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift | 1 + .../Infrastructure/Diagnostics/DiagnosticEngine.swift | 1 + .../Symbol Graph/SymbolGraphConcurrentDecoder.swift | 3 +-- .../DeclarationsSectionTranslator.swift | 1 + Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift | 1 + Sources/SwiftDocC/Utility/LogHandle.swift | 1 + .../SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift | 1 + .../Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift | 1 + Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift | 1 + Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift | 1 + .../Utility => CommonTests}/SynchronizationTests.swift | 2 +- .../Converter/TopicRenderReferenceEncoderTests.swift | 1 + Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift | 1 + 14 files changed, 13 insertions(+), 3 deletions(-) rename Sources/{SwiftDocC/Utility => Common}/Synchronization.swift (100%) rename Tests/{SwiftDocCTests/Utility => CommonTests}/SynchronizationTests.swift (98%) diff --git a/Sources/SwiftDocC/Utility/Synchronization.swift b/Sources/Common/Synchronization.swift similarity index 100% rename from Sources/SwiftDocC/Utility/Synchronization.swift rename to Sources/Common/Synchronization.swift diff --git a/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift b/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift index 034ae3c9e1..4a4e89a908 100644 --- a/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift +++ b/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift @@ -9,6 +9,7 @@ */ public import Foundation +public import Common /// A thread-safe cache for encoded render references. public typealias RenderReferenceCache = Synchronized<[String: (reference: Data, overrides: [VariantOverride])]> diff --git a/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift b/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift index ee014a95e6..fc1ea5854e 100644 --- a/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift +++ b/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift @@ -9,6 +9,7 @@ */ import Foundation +import Common /// A type that collects and dispatches diagnostics during compilation. public final class DiagnosticEngine { diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift index 93243ccf1c..4deb82a03f 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common public extension CodingUserInfoKey { /// A user info key to store a symbol counter in the decoder. @@ -55,8 +56,6 @@ enum SymbolGraphConcurrentDecoder { /// so that we can get the best performance out of the concurrent work. static func decode(_ data: Data, concurrentBatches: Int = 4, using decoder: JSONDecoder = JSONDecoder()) throws -> SymbolGraph { - - var symbolGraph: SymbolGraph! let decodeError = Synchronized<(any Error)?>(nil) diff --git a/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift index 7e255a2883..54da2e6342 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift @@ -10,6 +10,7 @@ import Foundation import SymbolKit +import Common typealias OverloadDeclaration = ( declaration: [SymbolGraph.Symbol.DeclarationFragments.Fragment], diff --git a/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift b/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift index 37a0a5fe33..3b197784b3 100644 --- a/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift +++ b/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift @@ -9,6 +9,7 @@ */ import Foundation +import Common // Until we find a better way to manage memory on Linux we will disable // concurrency in the Collection extensions in this file and have tests expect diff --git a/Sources/SwiftDocC/Utility/LogHandle.swift b/Sources/SwiftDocC/Utility/LogHandle.swift index 8665daf22c..07f5cdb28b 100644 --- a/Sources/SwiftDocC/Utility/LogHandle.swift +++ b/Sources/SwiftDocC/Utility/LogHandle.swift @@ -9,6 +9,7 @@ */ public import Foundation +import Common /// An object that writes logs to the given output device. /// diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift index 5a721a8e45..d340ea9cee 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift @@ -10,6 +10,7 @@ import Foundation import SwiftDocC +private import Common extension ConvertAction { diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift index 30ac26eb0d..0e9eb304dd 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift @@ -10,6 +10,7 @@ import Foundation import SwiftDocC +import Common /// An object that writes render nodes, as JSON files, into a target folder. /// diff --git a/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift index 8feefca057..e58a535a0c 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift @@ -10,6 +10,7 @@ import Foundation public import SwiftDocC +private import Common #if canImport(NIOHTTP1) /// A preview server instance. diff --git a/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift b/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift index 57795e0d08..2b52339120 100644 --- a/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift +++ b/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift @@ -10,6 +10,7 @@ import Foundation import SwiftDocC +private import Common #if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) import Darwin diff --git a/Tests/SwiftDocCTests/Utility/SynchronizationTests.swift b/Tests/CommonTests/SynchronizationTests.swift similarity index 98% rename from Tests/SwiftDocCTests/Utility/SynchronizationTests.swift rename to Tests/CommonTests/SynchronizationTests.swift index eff24f6533..4c9546dfd5 100644 --- a/Tests/SwiftDocCTests/Utility/SynchronizationTests.swift +++ b/Tests/CommonTests/SynchronizationTests.swift @@ -9,7 +9,7 @@ */ import XCTest -@testable import SwiftDocC +@testable import Common // to directly access the internal "lock" property #if os(Windows) import func WinSDK.TryAcquireSRWLockExclusive #endif diff --git a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift index 0686fe3243..3e8b870d8a 100644 --- a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift +++ b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift @@ -10,6 +10,7 @@ import XCTest @testable import SwiftDocC +private import Common class TopicRenderReferenceEncoderTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift b/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift index c9eca9a9e9..cff9c97e05 100644 --- a/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift +++ b/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift @@ -11,6 +11,7 @@ import Foundation @testable import SwiftDocC import XCTest +import Common class TestRenderNodeOutputConsumer: ConvertOutputConsumer, ExternalNodeConsumer { var renderNodes = Synchronized<[RenderNode]>([]) From 72254fa94d0083ab429123774263a556e80b4efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Fri, 7 Nov 2025 13:38:51 +0100 Subject: [PATCH 3/6] Keep public type aliases to moved types --- .../GeneratedCurationWriter.swift | 3 +-- .../Converter/TopicRenderReferenceEncoder.swift | 2 +- .../Navigator/RenderNode+NavigatorIndex.swift | 1 - .../Infrastructure/CoverageDataEntry.swift | 3 +-- .../Diagnostics/DiagnosticEngine.swift | 1 - .../Infrastructure/DocumentationContext.swift | 1 - ...eferenceResolver+DeprecatedCommunication.swift | 1 - .../OutOfProcessReferenceResolver.swift | 1 - .../LinkResolver+NavigatorIndex.swift | 1 - .../Link Resolution/LinkResolver.swift | 1 - .../PathHierarchy+PathComponent.swift | 3 +-- .../PathHierarchy+TypeSignature.swift | 3 +-- .../Link Resolution/PathHierarchy.swift | 1 - ...thHierarchyBasedLinkResolver+Breadcrumbs.swift | 3 +-- .../PathHierarchyBasedLinkResolver.swift | 1 - .../GeneratedDocumentationTopics.swift | 1 - .../SymbolGraphConcurrentDecoder.swift | 3 ++- .../Symbol Graph/SymbolGraphLoader.swift | 1 - .../Symbol Graph/SymbolReference.swift | 3 +-- .../Topic Graph/AutomaticCuration.swift | 1 - .../LinkTargets/LinkDestinationSummary.swift | 1 - Sources/SwiftDocC/Model/DocumentationNode.swift | 1 - Sources/SwiftDocC/Model/Identifier.swift | 1 - .../Model/ParametersAndReturnValidator.swift | 3 +-- .../Rendering/DocumentationContentRenderer.swift | 1 - .../RenderHierarchyTranslator.swift | 1 - .../Model/Rendering/RenderNodeTranslator.swift | 1 - .../DeclarationsSectionTranslator.swift | 1 - .../Variants/VariantPatchOperation.swift | 3 +-- Sources/SwiftDocC/Model/SourceLanguage.swift | 13 +++++++++++++ Sources/SwiftDocC/Semantics/Article/Article.swift | 1 - .../Semantics/Metadata/SupportedLanguage.swift | 3 +-- .../Symbol/DocumentationDataVariants.swift | 3 +-- .../Utility/Collection+ConcurrentPerform.swift | 1 - Sources/SwiftDocC/Utility/LogHandle.swift | 1 - Sources/SwiftDocC/Utility/Synchronization.swift | 15 +++++++++++++++ .../SymbolGraphCreation.swift | 5 ++--- .../Action/Actions/Convert/Indexer.swift | 1 - .../Convert/JSONEncodingRenderNodeWriter.swift | 1 - .../Action/Actions/Merge/MergeAction.swift | 3 +-- .../Action/Actions/PreviewAction.swift | 1 - .../Utility/DirectoryMonitor.swift | 1 - Tests/CommonTests/SourceLanguageTests.swift | 2 +- .../Benchmark/ExternalTopicsHashTests.swift | 1 - .../TopicRenderReferenceEncoderTests.swift | 1 - .../Indexing/ExternalRenderNodeTests.swift | 1 - .../Indexing/NavigatorIndexTests.swift | 1 - ...ontext+MixedLanguageSourceLanguagesTests.swift | 1 - .../DocumentationContextTests.swift | 1 - .../ExternalPathHierarchyResolverTests.swift | 1 - .../ExternalReferenceResolverTests.swift | 1 - .../Infrastructure/PathHierarchyTests.swift | 1 - .../Infrastructure/ReferenceResolverTests.swift | 1 - .../Infrastructure/SnippetResolverTests.swift | 1 - .../SymbolGraphRelationshipsBuilderTests.swift | 1 - .../Infrastructure/SymbolReferenceTests.swift | 1 - .../TestExternalReferenceResolvers.swift | 1 - .../LinkTargets/LinkDestinationSummaryTests.swift | 1 - .../Model/ParametersAndReturnValidatorTests.swift | 1 - .../SemaToRenderNodeDictionaryDataTests.swift | 1 - .../Model/SemaToRenderNodeHTTPRequestTests.swift | 1 - .../SemaToRenderNodeMultiLanguageTests.swift | 1 - .../SwiftDocCTests/Rendering/TermListTests.swift | 1 - Tests/SwiftDocCTests/Semantics/DoxygenTests.swift | 1 - .../TestRenderNodeOutputConsumer.swift | 1 - .../ConvertActionTests.swift | 1 - 66 files changed, 45 insertions(+), 77 deletions(-) create mode 100644 Sources/SwiftDocC/Model/SourceLanguage.swift create mode 100644 Sources/SwiftDocC/Utility/Synchronization.swift diff --git a/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift b/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift index 36a7faba7e..a700bde21a 100644 --- a/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift +++ b/Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2024-2025 Apple Inc. and the Swift project authors + Copyright (c) 2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ public import Foundation import SymbolKit -import Common /// A type that writes the auto-generated curation into documentation extension files. public struct GeneratedCurationWriter { diff --git a/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift b/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift index 4a4e89a908..21c39e0e3c 100644 --- a/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift +++ b/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift @@ -12,7 +12,7 @@ public import Foundation public import Common /// A thread-safe cache for encoded render references. -public typealias RenderReferenceCache = Synchronized<[String: (reference: Data, overrides: [VariantOverride])]> +public typealias RenderReferenceCache = Common.Synchronized<[String: (reference: Data, overrides: [VariantOverride])]> enum TopicRenderReferenceEncoder { /// Inserts an encoded list of render references to an already encoded as data render node. diff --git a/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift b/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift index c3b9e7581f..21fc7aa5ff 100644 --- a/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift +++ b/Sources/SwiftDocC/Indexing/Navigator/RenderNode+NavigatorIndex.swift @@ -9,7 +9,6 @@ */ import Foundation -import Common /// A language specific representation of a render node value for building a navigator index. protocol NavigatorIndexableRenderNodeRepresentation { diff --git a/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift b/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift index f767e9b02e..11ca715d7a 100644 --- a/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift +++ b/Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2025 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common /// `CoverageDataEntry` represents coverage data for one symbol/USR. public struct CoverageDataEntry: CustomStringConvertible, Codable { diff --git a/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift b/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift index fc1ea5854e..ee014a95e6 100644 --- a/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift +++ b/Sources/SwiftDocC/Infrastructure/Diagnostics/DiagnosticEngine.swift @@ -9,7 +9,6 @@ */ import Foundation -import Common /// A type that collects and dispatches diagnostics during compilation. public final class DiagnosticEngine { diff --git a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift index 193c99ca4e..9d4d83216b 100644 --- a/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift +++ b/Sources/SwiftDocC/Infrastructure/DocumentationContext.swift @@ -11,7 +11,6 @@ public import Foundation import Markdown import SymbolKit -public import Common /// The documentation context manages the in-memory model for the built documentation. /// diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift index b5adbad568..153a9aa72d 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift @@ -10,7 +10,6 @@ public import Foundation public import SymbolKit -public import Common extension OutOfProcessReferenceResolver { diff --git a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift index a7bde00382..25523e6520 100644 --- a/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift @@ -10,7 +10,6 @@ public import Foundation private import Markdown -import Common /// A reference resolver that launches and interactively communicates with another process or service to resolve links. /// diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift index 56ae120f63..2bb01f5abe 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver+NavigatorIndex.swift @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common /// A rendering-friendly representation of a external node. package struct ExternalRenderNode { diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift index 15145db00c..d7a5f331cf 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/LinkResolver.swift @@ -9,7 +9,6 @@ */ import Foundation -import Common /// A class that resolves documentation links by orchestrating calls to other link resolver implementations. public class LinkResolver { diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift index 0b720175fa..f067c735b9 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+PathComponent.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2025 Apple Inc. and the Swift project authors + Copyright (c) 2023-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common /// All known symbol kind identifiers. /// diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift index efb0774b90..06d33cdf38 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy+TypeSignature.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2025 Apple Inc. and the Swift project authors + Copyright (c) 2023-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common // MARK: From symbols diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift index 37ce96aec8..d4891efab4 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchy.swift @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common /// An opaque identifier that uniquely identifies a resolved entry in the path hierarchy, /// diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift index 8b76bda165..d806b00e08 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver+Breadcrumbs.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2024-2025 Apple Inc. and the Swift project authors + Copyright (c) 2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common extension PathHierarchyBasedLinkResolver { diff --git a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift index 8cb9467dc9..652580be28 100644 --- a/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift +++ b/Sources/SwiftDocC/Infrastructure/Link Resolution/PathHierarchyBasedLinkResolver.swift @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common /// A type that encapsulates resolving links by searching a hierarchy of path components. final class PathHierarchyBasedLinkResolver { diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift index fbcc5732da..cf461d3286 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/GeneratedDocumentationTopics.swift @@ -11,7 +11,6 @@ import Foundation import SymbolKit import Markdown -import Common /// A collection of APIs to generate documentation topics. enum GeneratedDocumentationTopics { diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift index 4deb82a03f..93243ccf1c 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphConcurrentDecoder.swift @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common public extension CodingUserInfoKey { /// A user info key to store a symbol counter in the decoder. @@ -56,6 +55,8 @@ enum SymbolGraphConcurrentDecoder { /// so that we can get the best performance out of the concurrent work. static func decode(_ data: Data, concurrentBatches: Int = 4, using decoder: JSONDecoder = JSONDecoder()) throws -> SymbolGraph { + + var symbolGraph: SymbolGraph! let decodeError = Synchronized<(any Error)?>(nil) diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift index ea2e847a1f..620d184122 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common /// Loads symbol graph files from a documentation bundle. /// diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift index db4edfa7bf..e4ce644f78 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolReference.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2025 Apple Inc. and the Swift project authors + Copyright (c) 2021 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ import Foundation public import SymbolKit -public import Common extension String { /// Returns a copy of the string with an appended hash of the given identifier. diff --git a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift index ea5289ff22..3a205c89f2 100644 --- a/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift +++ b/Sources/SwiftDocC/Infrastructure/Topic Graph/AutomaticCuration.swift @@ -11,7 +11,6 @@ import Foundation import Markdown import SymbolKit -import Common private let automaticSeeAlsoLimit: Int = { ProcessInfo.processInfo.environment["DOCC_AUTOMATIC_SEE_ALSO_LIMIT"].flatMap { Int($0) } ?? 15 diff --git a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift index 8aca73da59..e6407e9057 100644 --- a/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift +++ b/Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift @@ -11,7 +11,6 @@ public import Foundation import Markdown import SymbolKit -public import Common // Link resolution works in two parts: // diff --git a/Sources/SwiftDocC/Model/DocumentationNode.swift b/Sources/SwiftDocC/Model/DocumentationNode.swift index 6fe2e39277..d0fe3e811f 100644 --- a/Sources/SwiftDocC/Model/DocumentationNode.swift +++ b/Sources/SwiftDocC/Model/DocumentationNode.swift @@ -11,7 +11,6 @@ import Foundation public import Markdown public import SymbolKit -public import Common /// A documentation node holds all the information about a documentation entity's content. /// diff --git a/Sources/SwiftDocC/Model/Identifier.swift b/Sources/SwiftDocC/Model/Identifier.swift index 13e304b82d..469af2f4ca 100644 --- a/Sources/SwiftDocC/Model/Identifier.swift +++ b/Sources/SwiftDocC/Model/Identifier.swift @@ -11,7 +11,6 @@ public import Foundation import SymbolKit public import Markdown -public import Common /// A resolved or unresolved reference to a piece of documentation. /// diff --git a/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift b/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift index dbf8383f96..efa43e189b 100644 --- a/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift +++ b/Sources/SwiftDocC/Model/ParametersAndReturnValidator.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2025 Apple Inc. and the Swift project authors + Copyright (c) 2023-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -11,7 +11,6 @@ import Foundation import SymbolKit import Markdown -import Common /// A type that validates and filters a symbol's parameter and return value documentation based on the symbol's function signature. /// diff --git a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift index 00a96211b9..0d6ee8dd40 100644 --- a/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift +++ b/Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift @@ -11,7 +11,6 @@ import Foundation import SymbolKit import Markdown -import Common public struct RenderReferenceDependencies { public var topicReferences = [ResolvedTopicReference]() diff --git a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift index 8f433fc399..c62907e757 100644 --- a/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/Navigation Tree/RenderHierarchyTranslator.swift @@ -9,7 +9,6 @@ */ import Foundation -import Common /// A hierarchy translator that converts a part of the topic graph into a hierarchy tree. struct RenderHierarchyTranslator { diff --git a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift index d561c60981..b01c820978 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift @@ -11,7 +11,6 @@ public import Foundation public import Markdown import SymbolKit -import Common /// A visitor which converts a semantic model into a render node. /// diff --git a/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift b/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift index 54da2e6342..7e255a2883 100644 --- a/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift +++ b/Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DeclarationsSectionTranslator.swift @@ -10,7 +10,6 @@ import Foundation import SymbolKit -import Common typealias OverloadDeclaration = ( declaration: [SymbolGraph.Symbol.DeclarationFragments.Fragment], diff --git a/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift b/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift index 860157a403..848915709f 100644 --- a/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift +++ b/Sources/SwiftDocC/Model/Rendering/Variants/VariantPatchOperation.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2025 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -9,7 +9,6 @@ */ import Foundation -import Common /// A patch to update a render node value. public enum VariantPatchOperation { diff --git a/Sources/SwiftDocC/Model/SourceLanguage.swift b/Sources/SwiftDocC/Model/SourceLanguage.swift new file mode 100644 index 0000000000..097f35ca62 --- /dev/null +++ b/Sources/SwiftDocC/Model/SourceLanguage.swift @@ -0,0 +1,13 @@ +/* + This source file is part of the Swift.org open source project + + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors + Licensed under Apache License v2.0 with Runtime Library Exception + + See https://swift.org/LICENSE.txt for license information + See https://swift.org/CONTRIBUTORS.txt for Swift project authors +*/ + +public import Common + +public typealias SourceLanguage = Common.SourceLanguage diff --git a/Sources/SwiftDocC/Semantics/Article/Article.swift b/Sources/SwiftDocC/Semantics/Article/Article.swift index f5ab4eb1e4..42195c74c4 100644 --- a/Sources/SwiftDocC/Semantics/Article/Article.swift +++ b/Sources/SwiftDocC/Semantics/Article/Article.swift @@ -10,7 +10,6 @@ public import Foundation public import Markdown -public import Common /// The in-memory representation of an article. /// diff --git a/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift b/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift index c64b0eaca0..0f0231251e 100644 --- a/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift +++ b/Sources/SwiftDocC/Semantics/Metadata/SupportedLanguage.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023-2025 Apple Inc. and the Swift project authors + Copyright (c) 2023 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ import Foundation public import Markdown -public import Common /// A directive that controls what programming languages an article is available in. /// diff --git a/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift b/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift index 2a7bfc78f5..5452d0c6f9 100644 --- a/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift +++ b/Sources/SwiftDocC/Semantics/Symbol/DocumentationDataVariants.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2025 Apple Inc. and the Swift project authors + Copyright (c) 2021-2022 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,6 @@ import Foundation public import SymbolKit -import Common /// A model type that encapsulates variants of documentation node data. /// diff --git a/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift b/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift index 3b197784b3..37a0a5fe33 100644 --- a/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift +++ b/Sources/SwiftDocC/Utility/Collection+ConcurrentPerform.swift @@ -9,7 +9,6 @@ */ import Foundation -import Common // Until we find a better way to manage memory on Linux we will disable // concurrency in the Collection extensions in this file and have tests expect diff --git a/Sources/SwiftDocC/Utility/LogHandle.swift b/Sources/SwiftDocC/Utility/LogHandle.swift index 07f5cdb28b..8665daf22c 100644 --- a/Sources/SwiftDocC/Utility/LogHandle.swift +++ b/Sources/SwiftDocC/Utility/LogHandle.swift @@ -9,7 +9,6 @@ */ public import Foundation -import Common /// An object that writes logs to the given output device. /// diff --git a/Sources/SwiftDocC/Utility/Synchronization.swift b/Sources/SwiftDocC/Utility/Synchronization.swift new file mode 100644 index 0000000000..ef08c61284 --- /dev/null +++ b/Sources/SwiftDocC/Utility/Synchronization.swift @@ -0,0 +1,15 @@ +/* + This source file is part of the Swift.org open source project + + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors + Licensed under Apache License v2.0 with Runtime Library Exception + + See https://swift.org/LICENSE.txt for license information + See https://swift.org/CONTRIBUTORS.txt for Swift project authors +*/ + +public import Common + +public typealias Synchronized = Common.Synchronized + +package typealias Lock = Common.Lock diff --git a/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift b/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift index 27af5d7935..6a15e4596b 100644 --- a/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift +++ b/Sources/SwiftDocCTestUtilities/SymbolGraphCreation.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2025 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -12,8 +12,7 @@ import Foundation public import XCTest package import SymbolKit -import SwiftDocC -package import Common +package import SwiftDocC // MARK: - Symbol Graph objects diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift index d340ea9cee..5a721a8e45 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/Indexer.swift @@ -10,7 +10,6 @@ import Foundation import SwiftDocC -private import Common extension ConvertAction { diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift b/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift index 0e9eb304dd..30ac26eb0d 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift @@ -10,7 +10,6 @@ import Foundation import SwiftDocC -import Common /// An object that writes render nodes, as JSON files, into a target folder. /// diff --git a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift index 7409285cb8..d68fa32af6 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2024-2025 Apple Inc. and the Swift project authors + Copyright (c) 2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -11,7 +11,6 @@ import Foundation import SwiftDocC import Markdown -import Common /// An action that merges a list of documentation archives into a combined archive. struct MergeAction: AsyncAction { diff --git a/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift b/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift index e58a535a0c..8feefca057 100644 --- a/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift +++ b/Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift @@ -10,7 +10,6 @@ import Foundation public import SwiftDocC -private import Common #if canImport(NIOHTTP1) /// A preview server instance. diff --git a/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift b/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift index 2b52339120..57795e0d08 100644 --- a/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift +++ b/Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift @@ -10,7 +10,6 @@ import Foundation import SwiftDocC -private import Common #if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) import Darwin diff --git a/Tests/CommonTests/SourceLanguageTests.swift b/Tests/CommonTests/SourceLanguageTests.swift index 7e67953f3b..55e6d11ce3 100644 --- a/Tests/CommonTests/SourceLanguageTests.swift +++ b/Tests/CommonTests/SourceLanguageTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2022-2025 Apple Inc. and the Swift project authors + Copyright (c) 2022-2023 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information diff --git a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift index e80db9ae48..ee391de385 100644 --- a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift @@ -10,7 +10,6 @@ import XCTest @_spi(ExternalLinks) @testable import SwiftDocC -import Common import Markdown class ExternalTopicsGraphHashTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift index 3e8b870d8a..0686fe3243 100644 --- a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift +++ b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift @@ -10,7 +10,6 @@ import XCTest @testable import SwiftDocC -private import Common class TopicRenderReferenceEncoderTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift b/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift index 758dc891f9..1d5ed2b1cc 100644 --- a/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift +++ b/Tests/SwiftDocCTests/Indexing/ExternalRenderNodeTests.swift @@ -11,7 +11,6 @@ import Foundation import XCTest @_spi(ExternalLinks) @testable import SwiftDocC -import Common import SwiftDocCTestUtilities class ExternalRenderNodeTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift index 95a690c2a2..16c63bede5 100644 --- a/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift +++ b/Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift @@ -10,7 +10,6 @@ import XCTest @testable import SwiftDocC -import Common import SwiftDocCTestUtilities typealias Node = NavigatorTree.Node diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift index 330fbd96af..2206ad29ea 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift @@ -10,7 +10,6 @@ import XCTest @testable import SwiftDocC -import Common class DocumentationContext_MixedLanguageSourceLanguagesTests: XCTestCase { func testArticleAvailableSourceLanguagesIsSwiftInSwiftModule() async throws { diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index 175d16a8b8..e788f1b192 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -11,7 +11,6 @@ import XCTest import SymbolKit @testable @_spi(ExternalLinks) import SwiftDocC -import Common import Markdown import SwiftDocCTestUtilities diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift index 032b0b0479..0d0bab01b5 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalPathHierarchyResolverTests.swift @@ -12,7 +12,6 @@ import XCTest import Markdown import SymbolKit @testable @_spi(ExternalLinks) import SwiftDocC -import Common import SwiftDocCTestUtilities class ExternalPathHierarchyResolverTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 41e45a1cb6..803868d2ad 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -10,7 +10,6 @@ import XCTest @_spi(ExternalLinks) @testable import SwiftDocC -import Common import Markdown import SymbolKit import SwiftDocCTestUtilities diff --git a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift index e247737ae7..c7c54f5495 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift @@ -11,7 +11,6 @@ import XCTest import SymbolKit @testable import SwiftDocC -import Common import SwiftDocCTestUtilities import Markdown diff --git a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift index bb5c278780..4a37493359 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift @@ -10,7 +10,6 @@ import XCTest @_spi(ExternalLinks) @testable import SwiftDocC -import Common import Markdown import SymbolKit diff --git a/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift index 690f00fa99..84e39551d5 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SnippetResolverTests.swift @@ -10,7 +10,6 @@ import XCTest @testable import SwiftDocC -import Common import SymbolKit import SwiftDocCTestUtilities diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift index 57654130da..329a53f3b9 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift @@ -12,7 +12,6 @@ import Foundation import XCTest @testable import SymbolKit @testable import SwiftDocC -import Common class SymbolGraphRelationshipsBuilderTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift index c28f8993c1..49d4985b93 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolReferenceTests.swift @@ -11,7 +11,6 @@ import XCTest @testable import SymbolKit @testable import SwiftDocC -import Common import SwiftDocCTestUtilities class SymbolReferenceTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift index 1d1477f4db..d02463b820 100644 --- a/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift +++ b/Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift @@ -10,7 +10,6 @@ import Foundation @_spi(ExternalLinks) @testable import SwiftDocC -import Common import SymbolKit import Markdown diff --git a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift index 349cd2610d..5ac4655d92 100644 --- a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift +++ b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift @@ -11,7 +11,6 @@ import XCTest import SymbolKit @testable import SwiftDocC -import Common import SwiftDocCTestUtilities class LinkDestinationSummaryTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift index a7d1866d15..912ac6fdb3 100644 --- a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift +++ b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift @@ -13,7 +13,6 @@ import XCTest import Markdown @testable import SymbolKit @testable import SwiftDocC -import Common import SwiftDocCTestUtilities class ParametersAndReturnValidatorTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift index 3db1ed26a5..b0335f9745 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeDictionaryDataTests.swift @@ -10,7 +10,6 @@ import Foundation @testable import SwiftDocC -import Common import SymbolKit import XCTest diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift index d699d01764..6ebf753a32 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeHTTPRequestTests.swift @@ -10,7 +10,6 @@ import Foundation @testable import SwiftDocC -import Common import SymbolKit import XCTest diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift index b523749e05..d3a3fc2446 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeMultiLanguageTests.swift @@ -10,7 +10,6 @@ import Foundation @testable import SwiftDocC -import Common import SymbolKit import SwiftDocCTestUtilities import XCTest diff --git a/Tests/SwiftDocCTests/Rendering/TermListTests.swift b/Tests/SwiftDocCTests/Rendering/TermListTests.swift index 42eeb375c6..d5e496456c 100644 --- a/Tests/SwiftDocCTests/Rendering/TermListTests.swift +++ b/Tests/SwiftDocCTests/Rendering/TermListTests.swift @@ -12,7 +12,6 @@ import Foundation import XCTest import Markdown @testable import SwiftDocC -import Common import SwiftDocCTestUtilities class TermListTests: XCTestCase { diff --git a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift index 6720ddf9f4..9832537c9e 100644 --- a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift @@ -12,7 +12,6 @@ import Foundation import XCTest @testable import SwiftDocC -import Common import SwiftDocCTestUtilities @testable import SymbolKit diff --git a/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift b/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift index cff9c97e05..c9eca9a9e9 100644 --- a/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift +++ b/Tests/SwiftDocCTests/TestRenderNodeOutputConsumer.swift @@ -11,7 +11,6 @@ import Foundation @testable import SwiftDocC import XCTest -import Common class TestRenderNodeOutputConsumer: ConvertOutputConsumer, ExternalNodeConsumer { var renderNodes = Synchronized<[RenderNode]>([]) diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift index a7a7693383..a4f76bcd53 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift @@ -13,7 +13,6 @@ import Foundation @testable @_spi(ExternalLinks) import SwiftDocC @testable import SwiftDocCUtilities import SymbolKit -import Common import Markdown @testable import SwiftDocCTestUtilities From 04d9cc1106014876a76815661760130e58b13130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Mon, 10 Nov 2025 11:00:35 +0100 Subject: [PATCH 4/6] Move CMake file into target source directory --- Sources/{SwiftDocCUtilities => CommandLine}/CMakeLists.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Sources/{SwiftDocCUtilities => CommandLine}/CMakeLists.txt (100%) diff --git a/Sources/SwiftDocCUtilities/CMakeLists.txt b/Sources/CommandLine/CMakeLists.txt similarity index 100% rename from Sources/SwiftDocCUtilities/CMakeLists.txt rename to Sources/CommandLine/CMakeLists.txt From f40ce48eeb18ccb364a5eb640c3f9cd877996aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Mon, 10 Nov 2025 17:49:15 +0100 Subject: [PATCH 5/6] Move Synchronized type back into SwiftDocC for now --- Sources/Common/Synchronization.swift | 137 ------------------ .../TopicRenderReferenceEncoder.swift | 3 +- .../SwiftDocC/Utility/Synchronization.swift | 128 +++++++++++++++- .../Utility}/SynchronizationTests.swift | 2 +- 4 files changed, 127 insertions(+), 143 deletions(-) delete mode 100644 Sources/Common/Synchronization.swift rename Tests/{CommonTests => SwiftDocCTests/Utility}/SynchronizationTests.swift (98%) diff --git a/Sources/Common/Synchronization.swift b/Sources/Common/Synchronization.swift deleted file mode 100644 index 80395c176f..0000000000 --- a/Sources/Common/Synchronization.swift +++ /dev/null @@ -1,137 +0,0 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2021-2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See https://swift.org/LICENSE.txt for license information - See https://swift.org/CONTRIBUTORS.txt for Swift project authors -*/ - -import Foundation -#if os(Windows) -import WinSDK -#endif - -/// A wrapper type that ensures a synchronous access to a value. -/// -/// To guarantee safe concurrent access to a value wrap it in a `Synchronized` type. -/// ```swift -/// let index = Synchronized([String: String]()) -/// -/// // Mutate the value -/// index.sync { $0["key"] = "value" } -/// // Access the value -/// let value = index.sync { $0["key"] } -/// ``` -public class Synchronized { - /// A value that requires synchronized access. - private var value: Value - - #if os(macOS) || os(iOS) - /// A lock type appropriate for the current platform. - /// > Note: To avoid access race reports we manage the memory manually. - var lock: UnsafeMutablePointer - #elseif os(Linux) || os(Android) - /// A lock type appropriate for the current platform. - var lock: UnsafeMutablePointer - #elseif os(FreeBSD) - /// A lock type appropriate for the current platform. - var lock: UnsafeMutablePointer - #elseif os(Windows) - var lock: UnsafeMutablePointer - #else - #error("Unsupported platform") - #endif - - /// Creates a new synchronization over the given value. - /// - Parameter value: A value that requires synchronous access. - public init(_ value: Value) { - self.value = value - - #if os(macOS) || os(iOS) - lock = UnsafeMutablePointer.allocate(capacity: 1) - lock.initialize(to: os_unfair_lock()) - #elseif os(Linux) || os(Android) - lock = UnsafeMutablePointer.allocate(capacity: 1) - lock.initialize(to: pthread_mutex_t()) - pthread_mutex_init(lock, nil) - #elseif os(FreeBSD) - lock = UnsafeMutablePointer.allocate(capacity: 1) - lock.initialize(to: nil) - pthread_mutex_init(lock, nil) - #elseif os(Windows) - lock = UnsafeMutablePointer.allocate(capacity: 1) - InitializeSRWLock(lock) - #else - #error("Unsupported platform") - #endif - } - - deinit { - // Release the lock's memory. - lock.deallocate() - } - - /// Performs a given block of code while synchronizing over the type's stored value. - /// - Parameter block: A throwing block of work that optionally returns a value. - /// - Returns: Returns the returned value of `block`, if any. - @discardableResult - public func sync(_ block: (inout Value) throws(Error) -> Result) throws(Error) -> Result { - #if os(macOS) || os(iOS) - os_unfair_lock_lock(lock) - defer { os_unfair_lock_unlock(lock) } - #elseif os(Linux) || os(Android) - pthread_mutex_lock(lock) - defer { pthread_mutex_unlock(lock) } - #elseif os(FreeBSD) - pthread_mutex_lock(lock) - defer { pthread_mutex_unlock(lock) } - #elseif os(Windows) - AcquireSRWLockExclusive(lock) - defer { ReleaseSRWLockExclusive(lock) } - #else - #error("Unsupported platform") - #endif - - return try block(&value) - } -} - -/// A platform-appropriate locking mechanism. -/// - Note: Prefer ``Synchronized`` if you need to synchronize access -/// to a given value instead of a generic lock. -/// ```swift -/// let lock = Lock() -/// -/// lock.sync { myVar = 1 } -/// let result = lock.sync { return index["key"] } -/// ``` -package typealias Lock = Synchronized - -extension Lock { - /// Creates a new lock. - package convenience init() { - self.init(()) - } - - @discardableResult - package func sync(_ block: () throws(Error) -> Result) throws(Error) -> Result { - #if os(macOS) || os(iOS) - os_unfair_lock_lock(lock) - defer { os_unfair_lock_unlock(lock) } - #elseif os(Linux) || os(Android) - pthread_mutex_lock(lock) - defer { pthread_mutex_unlock(lock) } - #elseif os(FreeBSD) - pthread_mutex_lock(lock) - defer { pthread_mutex_unlock(lock) } - #elseif os(Windows) - AcquireSRWLockExclusive(lock) - defer { ReleaseSRWLockExclusive(lock) } - #else - #error("Unsupported platform") - #endif - return try block() - } -} diff --git a/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift b/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift index 21c39e0e3c..034ae3c9e1 100644 --- a/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift +++ b/Sources/SwiftDocC/Converter/TopicRenderReferenceEncoder.swift @@ -9,10 +9,9 @@ */ public import Foundation -public import Common /// A thread-safe cache for encoded render references. -public typealias RenderReferenceCache = Common.Synchronized<[String: (reference: Data, overrides: [VariantOverride])]> +public typealias RenderReferenceCache = Synchronized<[String: (reference: Data, overrides: [VariantOverride])]> enum TopicRenderReferenceEncoder { /// Inserts an encoded list of render references to an already encoded as data render node. diff --git a/Sources/SwiftDocC/Utility/Synchronization.swift b/Sources/SwiftDocC/Utility/Synchronization.swift index ef08c61284..80395c176f 100644 --- a/Sources/SwiftDocC/Utility/Synchronization.swift +++ b/Sources/SwiftDocC/Utility/Synchronization.swift @@ -8,8 +8,130 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors */ -public import Common +import Foundation +#if os(Windows) +import WinSDK +#endif -public typealias Synchronized = Common.Synchronized +/// A wrapper type that ensures a synchronous access to a value. +/// +/// To guarantee safe concurrent access to a value wrap it in a `Synchronized` type. +/// ```swift +/// let index = Synchronized([String: String]()) +/// +/// // Mutate the value +/// index.sync { $0["key"] = "value" } +/// // Access the value +/// let value = index.sync { $0["key"] } +/// ``` +public class Synchronized { + /// A value that requires synchronized access. + private var value: Value + + #if os(macOS) || os(iOS) + /// A lock type appropriate for the current platform. + /// > Note: To avoid access race reports we manage the memory manually. + var lock: UnsafeMutablePointer + #elseif os(Linux) || os(Android) + /// A lock type appropriate for the current platform. + var lock: UnsafeMutablePointer + #elseif os(FreeBSD) + /// A lock type appropriate for the current platform. + var lock: UnsafeMutablePointer + #elseif os(Windows) + var lock: UnsafeMutablePointer + #else + #error("Unsupported platform") + #endif + + /// Creates a new synchronization over the given value. + /// - Parameter value: A value that requires synchronous access. + public init(_ value: Value) { + self.value = value -package typealias Lock = Common.Lock + #if os(macOS) || os(iOS) + lock = UnsafeMutablePointer.allocate(capacity: 1) + lock.initialize(to: os_unfair_lock()) + #elseif os(Linux) || os(Android) + lock = UnsafeMutablePointer.allocate(capacity: 1) + lock.initialize(to: pthread_mutex_t()) + pthread_mutex_init(lock, nil) + #elseif os(FreeBSD) + lock = UnsafeMutablePointer.allocate(capacity: 1) + lock.initialize(to: nil) + pthread_mutex_init(lock, nil) + #elseif os(Windows) + lock = UnsafeMutablePointer.allocate(capacity: 1) + InitializeSRWLock(lock) + #else + #error("Unsupported platform") + #endif + } + + deinit { + // Release the lock's memory. + lock.deallocate() + } + + /// Performs a given block of code while synchronizing over the type's stored value. + /// - Parameter block: A throwing block of work that optionally returns a value. + /// - Returns: Returns the returned value of `block`, if any. + @discardableResult + public func sync(_ block: (inout Value) throws(Error) -> Result) throws(Error) -> Result { + #if os(macOS) || os(iOS) + os_unfair_lock_lock(lock) + defer { os_unfair_lock_unlock(lock) } + #elseif os(Linux) || os(Android) + pthread_mutex_lock(lock) + defer { pthread_mutex_unlock(lock) } + #elseif os(FreeBSD) + pthread_mutex_lock(lock) + defer { pthread_mutex_unlock(lock) } + #elseif os(Windows) + AcquireSRWLockExclusive(lock) + defer { ReleaseSRWLockExclusive(lock) } + #else + #error("Unsupported platform") + #endif + + return try block(&value) + } +} + +/// A platform-appropriate locking mechanism. +/// - Note: Prefer ``Synchronized`` if you need to synchronize access +/// to a given value instead of a generic lock. +/// ```swift +/// let lock = Lock() +/// +/// lock.sync { myVar = 1 } +/// let result = lock.sync { return index["key"] } +/// ``` +package typealias Lock = Synchronized + +extension Lock { + /// Creates a new lock. + package convenience init() { + self.init(()) + } + + @discardableResult + package func sync(_ block: () throws(Error) -> Result) throws(Error) -> Result { + #if os(macOS) || os(iOS) + os_unfair_lock_lock(lock) + defer { os_unfair_lock_unlock(lock) } + #elseif os(Linux) || os(Android) + pthread_mutex_lock(lock) + defer { pthread_mutex_unlock(lock) } + #elseif os(FreeBSD) + pthread_mutex_lock(lock) + defer { pthread_mutex_unlock(lock) } + #elseif os(Windows) + AcquireSRWLockExclusive(lock) + defer { ReleaseSRWLockExclusive(lock) } + #else + #error("Unsupported platform") + #endif + return try block() + } +} diff --git a/Tests/CommonTests/SynchronizationTests.swift b/Tests/SwiftDocCTests/Utility/SynchronizationTests.swift similarity index 98% rename from Tests/CommonTests/SynchronizationTests.swift rename to Tests/SwiftDocCTests/Utility/SynchronizationTests.swift index 4c9546dfd5..eff24f6533 100644 --- a/Tests/CommonTests/SynchronizationTests.swift +++ b/Tests/SwiftDocCTests/Utility/SynchronizationTests.swift @@ -9,7 +9,7 @@ */ import XCTest -@testable import Common // to directly access the internal "lock" property +@testable import SwiftDocC #if os(Windows) import func WinSDK.TryAcquireSRWLockExclusive #endif From 04a7964c9c52e384688d3ff3e186cc436d816d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Mon, 10 Nov 2025 17:52:43 +0100 Subject: [PATCH 6/6] Use Swift 6 language mode in new target --- Package.swift | 4 ++-- Sources/Common/SourceLanguage.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index 1c2fd87669..6630ecfd4c 100644 --- a/Package.swift +++ b/Package.swift @@ -122,7 +122,7 @@ let package = Package( // This target shouldn't have any local dependencies so that all other targets can depend on it. // We can add dependencies on SymbolKit and Markdown here but they're not needed yet. ], - swiftSettings: swiftSettings // FIXME: Use `[.swiftLanguageMode(.v6)]` here + swiftSettings: [.swiftLanguageMode(.v6)] ), .testTarget( @@ -131,7 +131,7 @@ let package = Package( .target(name: "Common"), .target(name: "TestUtilities"), ], - swiftSettings: swiftSettings // FIXME: Use `[.swiftLanguageMode(.v6)]` here + swiftSettings: [.swiftLanguageMode(.v6)] ), // Test app for CommandLine diff --git a/Sources/Common/SourceLanguage.swift b/Sources/Common/SourceLanguage.swift index c9f7c04ad9..4483219757 100644 --- a/Sources/Common/SourceLanguage.swift +++ b/Sources/Common/SourceLanguage.swift @@ -9,7 +9,7 @@ */ /// A programming language. -public struct SourceLanguage: Hashable, Codable, Comparable { +public struct SourceLanguage: Hashable, Codable, Comparable, Sendable { /// The display name of the programming language. public var name: String /// A globally unique identifier for the language. @@ -132,7 +132,7 @@ public struct SourceLanguage: Hashable, Codable, Comparable { public static let metal = SourceLanguage(name: "Metal", id: "metal") /// The list of programming languages that are known to DocC. - public static var knownLanguages: [SourceLanguage] = [.swift, .objectiveC, .javaScript, .data, .metal] + public static let knownLanguages: [SourceLanguage] = [.swift, .objectiveC, .javaScript, .data, .metal] enum CodingKeys: CodingKey { case name