Skip to content

Commit 3963a21

Browse files
authored
Deprecate bundle info version. (#1040)
1 parent f19ead7 commit 3963a21

16 files changed

+74
-94
lines changed

Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public struct DocumentationBundle {
6363

6464
It's not safe to make computations based on assumptions about the format of bundle's version. The version can be in any format.
6565
*/
66+
@available(*, deprecated, message: "This deprecated API will be removed after 6.2 is released")
6667
public var version: String? {
6768
info.version
6869
}

Sources/SwiftDocC/Infrastructure/Workspace/DocumentationBundle+Info.swift

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extension DocumentationBundle {
2222
public var identifier: String
2323

2424
/// The version of the bundle.
25+
@available(*, deprecated, message: "This deprecated API will be removed after 6.2 is released")
2526
public var version: String?
2627

2728
/// The default language identifier for code listings in the bundle.
@@ -42,7 +43,6 @@ extension DocumentationBundle {
4243
enum CodingKeys: String, CodingKey, CaseIterable {
4344
case displayName = "CFBundleDisplayName"
4445
case identifier = "CFBundleIdentifier"
45-
case version = "CFBundleVersion"
4646
case defaultCodeListingLanguage = "CDDefaultCodeListingLanguage"
4747
case defaultAvailability = "CDAppleDefaultAvailability"
4848
case defaultModuleKind = "CDDefaultModuleKind"
@@ -54,8 +54,6 @@ extension DocumentationBundle {
5454
return "--fallback-display-name"
5555
case .identifier:
5656
return "--fallback-bundle-identifier"
57-
case .version:
58-
return "--fallback-bundle-version"
5957
case .defaultCodeListingLanguage:
6058
return "--default-code-listing-language"
6159
case .defaultModuleKind:
@@ -82,26 +80,22 @@ extension DocumentationBundle {
8280
}
8381
}
8482

85-
8683
/// Creates a new documentation bundle information value.
8784
/// - Parameters:
8885
/// - displayName: The display name of the bundle.
8986
/// - identifier: The unique identifier of the bundle.
90-
/// - version: The version of the bundle.
9187
/// - defaultCodeListingLanguage: The default language identifier for code listings in the bundle.
9288
/// - defaultAvailability: The default availability for the various modules in the bundle.
9389
/// - defaultModuleKind: The default kind for the various modules in the bundle.
9490
public init(
9591
displayName: String,
9692
identifier: String,
97-
version: String?,
9893
defaultCodeListingLanguage: String?,
9994
defaultAvailability: DefaultAvailability?,
10095
defaultModuleKind: String?
10196
) {
10297
self.displayName = displayName
10398
self.identifier = identifier
104-
self.version = version
10599
self.defaultCodeListingLanguage = defaultCodeListingLanguage
106100
self.defaultAvailability = defaultAvailability
107101
self.defaultModuleKind = defaultModuleKind
@@ -228,7 +222,6 @@ extension DocumentationBundle {
228222
// contain a display name. If they do but that value fails to decode, that error would be raised before accessing `derivedDisplayName`.
229223
self.displayName = try decodeOrFallbackIfPresent(String.self, with: .displayName) ?? derivedDisplayName!
230224
self.identifier = try decodeOrFallbackIfPresent(String.self, with: .identifier) ?? self.displayName
231-
self.version = try decodeOrFallbackIfPresent(String.self, with: .version)
232225

233226
// Finally, decode the optional keys if they're present.
234227

@@ -237,19 +230,17 @@ extension DocumentationBundle {
237230
self.defaultAvailability = try decodeOrFallbackIfPresent(DefaultAvailability.self, with: .defaultAvailability)
238231
self.featureFlags = try decodeOrFallbackIfPresent(BundleFeatureFlags.self, with: .featureFlags)
239232
}
240-
233+
241234
init(
242235
displayName: String,
243236
identifier: String,
244-
version: String? = nil,
245237
defaultCodeListingLanguage: String? = nil,
246238
defaultModuleKind: String? = nil,
247239
defaultAvailability: DefaultAvailability? = nil,
248240
featureFlags: BundleFeatureFlags? = nil
249241
) {
250242
self.displayName = displayName
251243
self.identifier = identifier
252-
self.version = version
253244
self.defaultCodeListingLanguage = defaultCodeListingLanguage
254245
self.defaultModuleKind = defaultModuleKind
255246
self.defaultAvailability = defaultAvailability
@@ -267,15 +258,13 @@ extension BundleDiscoveryOptions {
267258
/// - Parameters:
268259
/// - fallbackDisplayName: A fallback display name for the bundle.
269260
/// - fallbackIdentifier: A fallback identifier for the bundle.
270-
/// - fallbackVersion: A fallback version for the bundle.
271261
/// - fallbackDefaultCodeListingLanguage: A fallback default code listing language for the bundle.
272262
/// - fallbackDefaultModuleKind: A fallback default module kind for the bundle.
273263
/// - fallbackDefaultAvailability: A fallback default availability for the bundle.
274264
/// - additionalSymbolGraphFiles: Additional symbol graph files to augment any discovered bundles.
275265
public init(
276266
fallbackDisplayName: String? = nil,
277267
fallbackIdentifier: String? = nil,
278-
fallbackVersion: String? = nil,
279268
fallbackDefaultCodeListingLanguage: String? = nil,
280269
fallbackDefaultModuleKind: String? = nil,
281270
fallbackDefaultAvailability: DefaultAvailability? = nil,
@@ -294,8 +283,6 @@ extension BundleDiscoveryOptions {
294283
value = fallbackDisplayName
295284
case .identifier:
296285
value = fallbackIdentifier
297-
case .version:
298-
value = fallbackVersion
299286
case .defaultCodeListingLanguage:
300287
value = fallbackDefaultCodeListingLanguage
301288
case .defaultAvailability:
@@ -318,6 +305,26 @@ extension BundleDiscoveryOptions {
318305
additionalSymbolGraphFiles: additionalSymbolGraphFiles
319306
)
320307
}
308+
309+
@available(*, deprecated, renamed: "init(fallbackDisplayName:fallbackIdentifier:fallbackDefaultCodeListingLanguage:fallbackDefaultModuleKind:fallbackDefaultAvailability:additionalSymbolGraphFiles:)", message: "Use 'init(fallbackDisplayName:fallbackIdentifier:fallbackDefaultCodeListingLanguage:fallbackDefaultModuleKind:fallbackDefaultAvailability:additionalSymbolGraphFiles:)' instead. This deprecated API will be removed after 6.2 is released")
310+
public init(
311+
fallbackDisplayName: String? = nil,
312+
fallbackIdentifier: String? = nil,
313+
fallbackVersion: String?,
314+
fallbackDefaultCodeListingLanguage: String? = nil,
315+
fallbackDefaultModuleKind: String? = nil,
316+
fallbackDefaultAvailability: DefaultAvailability? = nil,
317+
additionalSymbolGraphFiles: [URL] = []
318+
) {
319+
self.init(
320+
fallbackDisplayName: fallbackDisplayName,
321+
fallbackIdentifier: fallbackIdentifier,
322+
fallbackDefaultCodeListingLanguage: fallbackDefaultCodeListingLanguage,
323+
fallbackDefaultModuleKind: fallbackDefaultModuleKind,
324+
fallbackDefaultAvailability: fallbackDefaultAvailability,
325+
additionalSymbolGraphFiles:additionalSymbolGraphFiles
326+
)
327+
}
321328
}
322329

323330
private extension CodingUserInfoKey {
@@ -326,3 +333,23 @@ private extension CodingUserInfoKey {
326333
/// A user info key to store derived display name in the decoder.
327334
static let derivedDisplayName = CodingUserInfoKey(rawValue: "derivedDisplayName")!
328335
}
336+
337+
extension DocumentationBundle.Info {
338+
@available(*, deprecated, renamed: "init(displayName:identifier:defaultCodeListingLanguage:defaultAvailability:defaultModuleKind:)", message: "Use 'init(displayName:identifier:defaultCodeListingLanguage:defaultAvailability:defaultModuleKind:)' instead. This deprecated API will be removed after 6.2 is released")
339+
public init(
340+
displayName: String,
341+
identifier: String,
342+
version: String?,
343+
defaultCodeListingLanguage: String?,
344+
defaultAvailability: DefaultAvailability?,
345+
defaultModuleKind: String?
346+
) {
347+
self.init(
348+
displayName: displayName,
349+
identifier: identifier,
350+
defaultCodeListingLanguage: defaultCodeListingLanguage,
351+
defaultAvailability: defaultAvailability,
352+
defaultModuleKind: defaultModuleKind
353+
)
354+
}
355+
}

Sources/SwiftDocCTestUtilities/FilesAndFolders.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,25 @@ public struct InfoPlist: File, DataRepresentable {
9494
/// The information that the Into.plist file contains.
9595
public let content: Content
9696

97-
public init(displayName: String? = nil, identifier: String? = nil, versionString: String = "1.0") {
97+
public init(displayName: String? = nil, identifier: String? = nil) {
9898
self.content = Content(
9999
displayName: displayName,
100-
identifier: identifier,
101-
versionString: versionString
100+
identifier: identifier
102101
)
103102
}
104103

105104
public struct Content: Codable, Equatable {
106105
public let displayName: String?
107106
public let identifier: String?
108-
public let versionString: String?
109107

110-
fileprivate init(displayName: String?, identifier: String?, versionString: String) {
108+
fileprivate init(displayName: String?, identifier: String?) {
111109
self.displayName = displayName
112110
self.identifier = identifier
113-
self.versionString = versionString
114111
}
115112

116113
enum CodingKeys: String, CodingKey {
117114
case displayName = "CFBundleDisplayName"
118115
case identifier = "CFBundleIdentifier"
119-
case versionString = "CFBundleVersion"
120116
}
121117
}
122118

@@ -127,7 +123,6 @@ public struct InfoPlist: File, DataRepresentable {
127123
return try encoder.encode([
128124
Content.CodingKeys.displayName.rawValue: content.displayName,
129125
Content.CodingKeys.identifier.rawValue: content.identifier,
130-
Content.CodingKeys.versionString.rawValue: content.versionString,
131126
])
132127
}
133128
}

Sources/SwiftDocCUtilities/ArgumentParsing/ActionExtensions/ConvertAction+CommandInitialization.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ extension ConvertAction {
4949
let bundleDiscoveryOptions = BundleDiscoveryOptions(
5050
fallbackDisplayName: convert.fallbackBundleDisplayName,
5151
fallbackIdentifier: convert.fallbackBundleIdentifier,
52-
fallbackVersion: nil,
5352
fallbackDefaultCodeListingLanguage: convert.defaultCodeListingLanguage,
5453
fallbackDefaultModuleKind: convert.fallbackDefaultModuleKind,
5554
additionalSymbolGraphFiles: additionalSymbolGraphFiles

Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import SwiftDocCTestUtilities
1717
class ConvertServiceTests: XCTestCase {
1818
private let testBundleInfo = DocumentationBundle.Info(
1919
displayName: "TestBundle",
20-
identifier: "identifier",
21-
version: "1.0.0"
20+
identifier: "identifier"
2221
)
2322

2423
func testConvertSinglePage() throws {
@@ -1731,8 +1730,7 @@ class ConvertServiceTests: XCTestCase {
17311730
let request = ConvertRequest(
17321731
bundleInfo: DocumentationBundle.Info(
17331732
displayName: "TestBundle",
1734-
identifier: "com.test.bundle",
1735-
version: "1.0.0"
1733+
identifier: "com.test.bundle"
17361734
),
17371735
externalIDsToConvert: ["s:5MyKit0A5ClassC10myFunctionyyF"],
17381736
documentPathsToConvert: [],
@@ -2021,8 +2019,7 @@ class ConvertServiceTests: XCTestCase {
20212019
let request = ConvertRequest(
20222020
bundleInfo: DocumentationBundle.Info(
20232021
displayName: "TestBundle",
2024-
identifier: "org.swift.example",
2025-
version: "1.0.0"
2022+
identifier: "org.swift.example"
20262023
),
20272024
externalIDsToConvert: ["s:32MyKit3FooV"],
20282025
documentPathsToConvert: [],
@@ -2131,8 +2128,7 @@ class ConvertServiceTests: XCTestCase {
21312128
let request = ConvertRequest(
21322129
bundleInfo: DocumentationBundle.Info(
21332130
displayName: "TestBundleDisplayName",
2134-
identifier: "com.test.bundle",
2135-
version: "1.0.0"
2131+
identifier: "com.test.bundle"
21362132
),
21372133
externalIDsToConvert: ["s:21SmallTestingFramework40EnumerationWithSingleUnresolvableDocLinkO"],
21382134
documentPathsToConvert: [],
@@ -2170,8 +2166,7 @@ class ConvertServiceTests: XCTestCase {
21702166
let request = ConvertRequest(
21712167
bundleInfo: DocumentationBundle.Info(
21722168
displayName: "TestBundleDisplayName",
2173-
identifier: "com.test.bundle",
2174-
version: "1.0.0"
2169+
identifier: "com.test.bundle"
21752170
),
21762171
externalIDsToConvert: ["s:21SmallTestingFramework15TestEnumerationO06NesteddE0O0D6StructV06deeplyfD31FunctionWithUnresolvableDocLinkyyF"],
21772172
documentPathsToConvert: [],
@@ -2210,8 +2205,7 @@ class ConvertServiceTests: XCTestCase {
22102205
let request = ConvertRequest(
22112206
bundleInfo: DocumentationBundle.Info(
22122207
displayName: "TestBundleDisplayName",
2213-
identifier: "com.test.bundle",
2214-
version: "1.0.0"
2208+
identifier: "com.test.bundle"
22152209
),
22162210
externalIDsToConvert: ["s:21SmallTestingFramework43EnumerationWithSingleUnresolvableSymbolLinkO"],
22172211
documentPathsToConvert: [],

Tests/SwiftDocCTests/DocumentationService/DocumentationServer+DefaultTests.swift

Lines changed: 2 additions & 3 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 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 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
@@ -68,8 +68,7 @@ class DocumentationServer_DefaultTests: XCTestCase {
6868
let request = ConvertRequest(
6969
bundleInfo: DocumentationBundle.Info(
7070
displayName: "TestBundle",
71-
identifier: "identifier",
72-
version: "1.0.0"
71+
identifier: "identifier"
7372
),
7473
externalIDsToConvert: ["s:5MyKit0A5ClassC10myFunctionyyF"],
7574
symbolGraphs: [symbolGraph],

Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift

Lines changed: 2 additions & 4 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 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 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
@@ -256,8 +256,7 @@ class BundleDiscoveryTests: XCTestCase {
256256
let bundleDiscoveryOptions = BundleDiscoveryOptions(
257257
infoPlistFallbacks: [
258258
"CFBundleDisplayName": "Fallback Display Name",
259-
"CFBundleIdentifier": "com.fallback.bundle.identifier",
260-
"CFBundleVersion": "1.2.3",
259+
"CFBundleIdentifier": "com.fallback.bundle.identifier"
261260
],
262261
additionalSymbolGraphFiles: []
263262
)
@@ -269,7 +268,6 @@ class BundleDiscoveryTests: XCTestCase {
269268
// The bundle information was specified via the options
270269
XCTAssertEqual(bundle.identifier, "com.fallback.bundle.identifier")
271270
XCTAssertEqual(bundle.displayName, "Fallback Display Name")
272-
XCTAssertEqual(bundle.version, "1.2.3")
273271
}
274272

275273
func testNoCustomTemplates() throws {

0 commit comments

Comments
 (0)