Skip to content

Commit 17a2037

Browse files
committed
Extract the SourceLanguage type to a new "Common" target
1 parent b27288d commit 17a2037

File tree

54 files changed

+95
-19
lines changed

Some content is hidden

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

54 files changed

+95
-19
lines changed

Package.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
This source file is part of the Swift.org open source project
44

5-
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
5+
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
66
Licensed under Apache License v2.0 with Runtime Library Exception
77

88
See https://swift.org/LICENSE.txt for license information
@@ -43,6 +43,7 @@ let package = Package(
4343
.target(
4444
name: "SwiftDocC",
4545
dependencies: [
46+
.target(name: "Common"),
4647
.product(name: "Markdown", package: "swift-markdown"),
4748
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
4849
.product(name: "CLMDB", package: "swift-lmdb"),
@@ -54,6 +55,7 @@ let package = Package(
5455
name: "SwiftDocCTests",
5556
dependencies: [
5657
.target(name: "SwiftDocC"),
58+
.target(name: "Common"),
5759
.target(name: "SwiftDocCTestUtilities"),
5860
],
5961
resources: [
@@ -69,6 +71,7 @@ let package = Package(
6971
name: "SwiftDocCUtilities",
7072
dependencies: [
7173
.target(name: "SwiftDocC"),
74+
.target(name: "Common"),
7275
.product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.macOS, .iOS, .linux, .android])),
7376
.product(name: "ArgumentParser", package: "swift-argument-parser")
7477
],
@@ -79,6 +82,7 @@ let package = Package(
7982
dependencies: [
8083
.target(name: "SwiftDocCUtilities"),
8184
.target(name: "SwiftDocC"),
85+
.target(name: "Common"),
8286
.target(name: "SwiftDocCTestUtilities"),
8387
],
8488
resources: [
@@ -93,6 +97,7 @@ let package = Package(
9397
name: "SwiftDocCTestUtilities",
9498
dependencies: [
9599
.target(name: "SwiftDocC"),
100+
.target(name: "Common"),
96101
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
97102
],
98103
swiftSettings: swiftSettings
@@ -106,6 +111,25 @@ let package = Package(
106111
],
107112
swiftSettings: swiftSettings
108113
),
114+
115+
// A few common types and core functionality that's useable by all other targets.
116+
.target(
117+
name: "Common",
118+
dependencies: [
119+
// This target shouldn't have any local dependencies so that all other targets can depend on it.
120+
// We can add dependencies on SymbolKit and Markdown here but they're not needed yet.
121+
],
122+
swiftSettings: swiftSettings // FIXME: Use `[.swiftLanguageMode(.v6)]` here
123+
),
124+
125+
.testTarget(
126+
name: "CommonTests",
127+
dependencies: [
128+
.target(name: "Common"),
129+
.target(name: "SwiftDocCTestUtilities"),
130+
],
131+
swiftSettings: swiftSettings // FIXME: Use `[.swiftLanguageMode(.v6)]` here
132+
),
109133

110134
// Test app for SwiftDocCUtilities
111135
.executableTarget(

Sources/SwiftDocC/Model/SourceLanguage.swift renamed to Sources/Common/SourceLanguage.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -157,7 +157,9 @@ public struct SourceLanguage: Hashable, Codable, Comparable {
157157

158158
try container.encode(self.name, forKey: SourceLanguage.CodingKeys.name)
159159
try container.encode(self.id, forKey: SourceLanguage.CodingKeys.id)
160-
try container.encodeIfNotEmpty(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases)
160+
if !self.idAliases.isEmpty {
161+
try container.encode(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases)
162+
}
161163
try container.encode(self.linkDisambiguationID, forKey: SourceLanguage.CodingKeys.linkDisambiguationID)
162164
}
163165

Sources/SwiftDocC/Catalog Processing/GeneratedCurationWriter.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2024 Apple Inc. and the Swift project authors
4+
Copyright (c) 2024-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -10,6 +10,7 @@
1010

1111
public import Foundation
1212
import SymbolKit
13+
import Common
1314

1415
/// A type that writes the auto-generated curation into documentation extension files.
1516
public struct GeneratedCurationWriter {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import Foundation
12+
import Common
1213

1314
/// A language specific representation of a render node value for building a navigator index.
1415
protocol NavigatorIndexableRenderNodeRepresentation<Metadata> {

Sources/SwiftDocC/Infrastructure/CoverageDataEntry.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -10,6 +10,7 @@
1010

1111
import Foundation
1212
import SymbolKit
13+
import Common
1314

1415
/// `CoverageDataEntry` represents coverage data for one symbol/USR.
1516
public struct CoverageDataEntry: CustomStringConvertible, Codable {

Sources/SwiftDocC/Infrastructure/DocumentationContext.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
public import Foundation
1212
import Markdown
1313
import SymbolKit
14+
public import Common
1415

1516
/// The documentation context manages the in-memory model for the built documentation.
1617
///

Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver+DeprecatedCommunication.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
public import Foundation
1212
public import SymbolKit
13+
public import Common
1314

1415
extension OutOfProcessReferenceResolver {
1516

Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
public import Foundation
1212
private import Markdown
13+
import Common
1314

1415
/// A reference resolver that launches and interactively communicates with another process or service to resolve links.
1516
///

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import Foundation
1212
import SymbolKit
13+
import Common
1314

1415
/// A rendering-friendly representation of a external node.
1516
package struct ExternalRenderNode {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import Foundation
12+
import Common
1213

1314
/// A class that resolves documentation links by orchestrating calls to other link resolver implementations.
1415
public class LinkResolver {

0 commit comments

Comments
 (0)