From bf23afc5b0b922a0bef829eb70738de615d08dde Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 16 Nov 2025 07:30:23 +0000 Subject: [PATCH] Revert "Create new target for common code (#1331)" This reverts commit 70a8a0d32d57903a545c06b5cbac0dfdac9b5e3b. --- Package.swift | 24 ------------------- .../Model}/SourceLanguage.swift | 10 ++++---- .../SwiftDocC/Utility/CommonTypeExports.swift | 13 ---------- .../CMakeLists.txt | 0 .../Model}/SourceLanguageTests.swift | 2 +- 5 files changed, 5 insertions(+), 44 deletions(-) rename Sources/{DocCCommon => SwiftDocC/Model}/SourceLanguage.swift (95%) delete mode 100644 Sources/SwiftDocC/Utility/CommonTypeExports.swift rename Sources/{CommandLine => SwiftDocCUtilities}/CMakeLists.txt (100%) rename Tests/{DocCCommonTests => SwiftDocCTests/Model}/SourceLanguageTests.swift (96%) diff --git a/Package.swift b/Package.swift index 3ceb324be8..9ad6fa6d7a 100644 --- a/Package.swift +++ b/Package.swift @@ -43,7 +43,6 @@ let package = Package( .target( name: "SwiftDocC", dependencies: [ - .target(name: "DocCCommon"), .product(name: "Markdown", package: "swift-markdown"), .product(name: "SymbolKit", package: "swift-docc-symbolkit"), .product(name: "CLMDB", package: "swift-lmdb"), @@ -56,7 +55,6 @@ let package = Package( name: "SwiftDocCTests", dependencies: [ .target(name: "SwiftDocC"), - .target(name: "DocCCommon"), .target(name: "SwiftDocCTestUtilities"), ], resources: [ @@ -72,7 +70,6 @@ let package = Package( name: "SwiftDocCUtilities", dependencies: [ .target(name: "SwiftDocC"), - .target(name: "DocCCommon"), .product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.macOS, .iOS, .linux, .android])), .product(name: "ArgumentParser", package: "swift-argument-parser") ], @@ -84,7 +81,6 @@ let package = Package( dependencies: [ .target(name: "SwiftDocCUtilities"), .target(name: "SwiftDocC"), - .target(name: "DocCCommon"), .target(name: "SwiftDocCTestUtilities"), ], resources: [ @@ -99,7 +95,6 @@ let package = Package( name: "SwiftDocCTestUtilities", dependencies: [ .target(name: "SwiftDocC"), - .target(name: "DocCCommon"), .product(name: "SymbolKit", package: "swift-docc-symbolkit"), ], swiftSettings: swiftSettings @@ -114,25 +109,6 @@ let package = Package( exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings ), - - // A few common types and core functionality that's useable by all other targets. - .target( - name: "DocCCommon", - 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: [.swiftLanguageMode(.v6)] - ), - - .testTarget( - name: "DocCCommonTests", - dependencies: [ - .target(name: "DocCCommon"), - .target(name: "SwiftDocCTestUtilities"), - ], - swiftSettings: [.swiftLanguageMode(.v6)] - ), // Test app for SwiftDocCUtilities .executableTarget( diff --git a/Sources/DocCCommon/SourceLanguage.swift b/Sources/SwiftDocC/Model/SourceLanguage.swift similarity index 95% rename from Sources/DocCCommon/SourceLanguage.swift rename to Sources/SwiftDocC/Model/SourceLanguage.swift index 4483219757..2866213456 100644 --- a/Sources/DocCCommon/SourceLanguage.swift +++ b/Sources/SwiftDocC/Model/SourceLanguage.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-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 @@ -9,7 +9,7 @@ */ /// A programming language. -public struct SourceLanguage: Hashable, Codable, Comparable, Sendable { +public struct SourceLanguage: Hashable, Codable, Comparable { /// 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, Sendable { public static let metal = SourceLanguage(name: "Metal", id: "metal") /// The list of programming languages that are known to DocC. - public static let knownLanguages: [SourceLanguage] = [.swift, .objectiveC, .javaScript, .data, .metal] + public static var knownLanguages: [SourceLanguage] = [.swift, .objectiveC, .javaScript, .data, .metal] enum CodingKeys: CodingKey { case name @@ -157,9 +157,7 @@ public struct SourceLanguage: Hashable, Codable, Comparable, Sendable { try container.encode(self.name, forKey: SourceLanguage.CodingKeys.name) try container.encode(self.id, forKey: SourceLanguage.CodingKeys.id) - if !self.idAliases.isEmpty { - try container.encode(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases) - } + try container.encodeIfNotEmpty(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases) try container.encode(self.linkDisambiguationID, forKey: SourceLanguage.CodingKeys.linkDisambiguationID) } diff --git a/Sources/SwiftDocC/Utility/CommonTypeExports.swift b/Sources/SwiftDocC/Utility/CommonTypeExports.swift deleted file mode 100644 index 7194a5c125..0000000000 --- a/Sources/SwiftDocC/Utility/CommonTypeExports.swift +++ /dev/null @@ -1,13 +0,0 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 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 DocCCommon - -public typealias SourceLanguage = DocCCommon.SourceLanguage diff --git a/Sources/CommandLine/CMakeLists.txt b/Sources/SwiftDocCUtilities/CMakeLists.txt similarity index 100% rename from Sources/CommandLine/CMakeLists.txt rename to Sources/SwiftDocCUtilities/CMakeLists.txt diff --git a/Tests/DocCCommonTests/SourceLanguageTests.swift b/Tests/SwiftDocCTests/Model/SourceLanguageTests.swift similarity index 96% rename from Tests/DocCCommonTests/SourceLanguageTests.swift rename to Tests/SwiftDocCTests/Model/SourceLanguageTests.swift index d63b6dcaac..734c5c7a1d 100644 --- a/Tests/DocCCommonTests/SourceLanguageTests.swift +++ b/Tests/SwiftDocCTests/Model/SourceLanguageTests.swift @@ -8,7 +8,7 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors */ -import DocCCommon +@testable import SwiftDocC import XCTest class SourceLanguageTests: XCTestCase {