Skip to content

Commit a158311

Browse files
Merge branch 'main' into multilanguage-support
2 parents a2212c2 + 5e0729b commit a158311

File tree

15 files changed

+59
-46
lines changed

15 files changed

+59
-46
lines changed

Sources/SwiftDocC/DocumentationService/Models/Services/Convert/ConvertRequest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public struct ConvertRequest: Codable {
9292
@available(*, deprecated, message: "Use 'bundleInfo.version' instead.")
9393
public var version: String {
9494
get {
95-
return bundleInfo.version.description
95+
return bundleInfo.version ?? "0.0.1"
9696
}
9797
set {
98-
bundleInfo.version = Version(versionString: newValue) ?? bundleInfo.version
98+
bundleInfo.version = newValue
9999
}
100100
}
101101

@@ -159,7 +159,7 @@ public struct ConvertRequest: Codable {
159159
self.bundleInfo = DocumentationBundle.Info(
160160
displayName: displayName,
161161
identifier: identifier,
162-
version: Version(versionString: version)!,
162+
version: version,
163163
defaultCodeListingLanguage: defaultCodeListingLanguage
164164
)
165165
}

Sources/SwiftDocC/Infrastructure/DocumentationBundle.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,9 @@ public struct DocumentationBundle {
6363
/**
6464
The documentation bundle's version.
6565

66-
The build version number should be a string comprised of three non-negative, period-separated integers with the first integer being greater than zero—for example, `3.1.2`. The string should only contain numeric (0-9) and period (.) characters. Leading zeros are truncated from each integer and will be ignored (that is, `1.02.3` is equivalent to `1.2.3`).
67-
68-
The meaning of each element is as follows:
69-
70-
- The first number represents the most recent major release and is limited to a maximum length of four digits.
71-
- The second number represents the most recent significant revision and is limited to a maximum length of two digits.
72-
- The third number represents the most recent minor bug fix and is limited to a maximum length of two digits.
73-
74-
If the value of the third number is 0, you can omit it and the second period.
66+
It's not safe to make computations based on assumptions about the format of bundle's version. The version can be in any format.
7567
*/
76-
public var version: Version {
68+
public var version: String? {
7769
info.version
7870
}
7971

@@ -133,7 +125,7 @@ public struct DocumentationBundle {
133125
info: Info(
134126
displayName: displayName,
135127
identifier: identifier,
136-
version: version,
128+
version: version.description,
137129
defaultCodeListingLanguage: defaultCodeListingLanguage,
138130
defaultAvailability: defaultAvailability
139131
),

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

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

2424
/// The version of the bundle.
25-
public var version: Version
25+
public var version: String?
2626

2727
/// The default language identifier for code listings in the bundle.
2828
public var defaultCodeListingLanguage: String?
@@ -34,7 +34,7 @@ extension DocumentationBundle {
3434
public var defaultModuleKind: String?
3535

3636
/// The keys that must be present in an Info.plist file in order for doc compilation to proceed.
37-
static let requiredKeys: Set<CodingKeys> = [.displayName, .identifier, .version]
37+
static let requiredKeys: Set<CodingKeys> = [.displayName, .identifier]
3838

3939
enum CodingKeys: String, CodingKey, CaseIterable {
4040
case displayName = "CFBundleDisplayName"
@@ -162,7 +162,7 @@ extension DocumentationBundle {
162162

163163
self.displayName = try decodeOrFallback(String.self, with: .displayName)
164164
self.identifier = try decodeOrFallback(String.self, with: .identifier)
165-
self.version = try decodeOrFallback(Version.self, with: .version)
165+
self.version = try decodeOrFallbackIfPresent(String.self, with: .version)
166166

167167
// Finally, decode the optional keys if they're present.
168168

@@ -174,7 +174,7 @@ extension DocumentationBundle {
174174
init(
175175
displayName: String,
176176
identifier: String,
177-
version: Version,
177+
version: String? = nil,
178178
defaultCodeListingLanguage: String? = nil,
179179
defaultModuleKind: String? = nil,
180180
defaultAvailability: DefaultAvailability? = nil

Sources/SwiftDocC/Servers/DocumentationSchemeHandler.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public class DocumentationSchemeHandler: NSObject {
8383
}
8484

8585
// MARK: WKURLSchemeHandler protocol
86-
@available(OSX 10.13, iOS 11.0, *)
8786
extension DocumentationSchemeHandler: WKURLSchemeHandler {
8887

8988
public func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {

Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ConvertServiceTests: XCTestCase {
1717
private let testBundleInfo = DocumentationBundle.Info(
1818
displayName: "TestBundle",
1919
identifier: "identifier",
20-
version: Version(versionString: "1.0.0")!
20+
version: "1.0.0"
2121
)
2222

2323
func testConvertSinglePage() throws {
@@ -966,7 +966,7 @@ class ConvertServiceTests: XCTestCase {
966966
bundleInfo: DocumentationBundle.Info(
967967
displayName: "TestBundle",
968968
identifier: "com.test.bundle",
969-
version: Version(versionString: "1.0.0")!
969+
version: "1.0.0"
970970
),
971971
externalIDsToConvert: ["s:5MyKit0A5ClassC10myFunctionyyF"],
972972
documentPathsToConvert: [],
@@ -1252,7 +1252,7 @@ class ConvertServiceTests: XCTestCase {
12521252
bundleInfo: DocumentationBundle.Info(
12531253
displayName: "TestBundleDisplayName",
12541254
identifier: "com.test.bundle",
1255-
version: Version(versionString: "1.0.0")!
1255+
version: "1.0.0"
12561256
),
12571257
externalIDsToConvert: ["s:21SmallTestingFramework40EnumerationWithSingleUnresolvableDocLinkO"],
12581258
documentPathsToConvert: [],
@@ -1299,7 +1299,7 @@ class ConvertServiceTests: XCTestCase {
12991299
bundleInfo: DocumentationBundle.Info(
13001300
displayName: "TestBundleDisplayName",
13011301
identifier: "com.test.bundle",
1302-
version: Version(versionString: "1.0.0")!
1302+
version: "1.0.0"
13031303
),
13041304
externalIDsToConvert: ["s:21SmallTestingFramework15TestEnumerationO06NesteddE0O0D6StructV06deeplyfD31FunctionWithUnresolvableDocLinkyyF"],
13051305
documentPathsToConvert: [],
@@ -1339,7 +1339,7 @@ class ConvertServiceTests: XCTestCase {
13391339
bundleInfo: DocumentationBundle.Info(
13401340
displayName: "TestBundleDisplayName",
13411341
identifier: "com.test.bundle",
1342-
version: Version(versionString: "1.0.0")!
1342+
version: "1.0.0"
13431343
),
13441344
externalIDsToConvert: ["s:21SmallTestingFramework43EnumerationWithSingleUnresolvableSymbolLinkO"],
13451345
documentPathsToConvert: [],

Tests/SwiftDocCTests/DocumentationService/DocumentationServer+DefaultTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class DocumentationServer_DefaultTests: XCTestCase {
6969
bundleInfo: DocumentationBundle.Info(
7070
displayName: "TestBundle",
7171
identifier: "identifier",
72-
version: Version(versionString: "1.0.0")!
72+
version: "1.0.0"
7373
),
7474
externalIDsToConvert: ["s:5MyKit0A5ClassC10myFunctionyyF"],
7575
symbolGraphs: [symbolGraph],

Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class BundleDiscoveryTests: XCTestCase {
279279
// The bundle information was specified via the options
280280
XCTAssertEqual(bundle.identifier, "com.fallback.bundle.identifier")
281281
XCTAssertEqual(bundle.displayName, "Fallback Display Name")
282-
XCTAssertEqual(bundle.version, Version(arrayLiteral: 1, 2, 3))
282+
XCTAssertEqual(bundle.version, "1.2.3")
283283
}
284284

285285
func testNoCustomTemplates() throws {

Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DocumentationBundleInfoTests: XCTestCase {
2323

2424
XCTAssertEqual(info.displayName, "Test Bundle")
2525
XCTAssertEqual(info.identifier, "org.swift.docc.example")
26-
XCTAssertEqual(info.version.description, "0.1.0")
26+
XCTAssertEqual(info.version, "0.1.0")
2727
XCTAssertEqual(info.defaultCodeListingLanguage, "swift")
2828
}
2929

@@ -57,7 +57,7 @@ class DocumentationBundleInfoTests: XCTestCase {
5757

5858
let infoPlistWithAllFieldsData = Data(infoPlistWithAllFields.utf8)
5959

60-
let infoPlistWithSomeFields = """
60+
let infoPlistWithoutDisplayName = """
6161
<plist version="1.0">
6262
<dict>
6363
<key>CFBundleIdentifier</key>
@@ -68,7 +68,7 @@ class DocumentationBundleInfoTests: XCTestCase {
6868
</plist>
6969
"""
7070

71-
let infoPlistWithSomeFieldsData = Data(infoPlistWithSomeFields.utf8)
71+
let infoPlistWithoutDisplayNameData = Data(infoPlistWithoutDisplayName.utf8)
7272

7373
let bundleDiscoveryOptions = BundleDiscoveryOptions(
7474
infoPlistFallbacks: [
@@ -86,7 +86,7 @@ class DocumentationBundleInfoTests: XCTestCase {
8686
DocumentationBundle.Info(
8787
displayName: "Info Plist Display Name",
8888
identifier: "com.info.Plist",
89-
version: Version(arrayLiteral: 1,0,0)
89+
version: "1.0.0"
9090
)
9191
)
9292

@@ -98,19 +98,44 @@ class DocumentationBundleInfoTests: XCTestCase {
9898
DocumentationBundle.Info(
9999
displayName: "Fallback Display Name",
100100
identifier: "com.fallback.Identifier",
101-
version: Version(arrayLiteral: 2,0,0)
101+
version: "2.0.0"
102102
)
103103
)
104104

105105
XCTAssertEqual(
106106
try DocumentationBundle.Info(
107-
from: infoPlistWithSomeFieldsData,
107+
from: infoPlistWithoutDisplayNameData,
108108
bundleDiscoveryOptions: bundleDiscoveryOptions
109109
),
110110
DocumentationBundle.Info(
111111
displayName: "Fallback Display Name",
112112
identifier: "com.info.Plist",
113-
version: Version(arrayLiteral: 1,0,0)
113+
version: "1.0.0"
114+
)
115+
)
116+
117+
let infoPlistWithoutVersion = """
118+
<plist version="1.0">
119+
<dict>
120+
<key>CFBundleDisplayName</key>
121+
<string>Info Plist Display Name</string>
122+
<key>CFBundleIdentifier</key>
123+
<string>com.info.Plist</string>
124+
</dict>
125+
</plist>
126+
"""
127+
128+
let infoPlistWithoutVersionData = Data(infoPlistWithoutVersion.utf8)
129+
130+
XCTAssertEqual(
131+
try DocumentationBundle.Info(
132+
from: infoPlistWithoutVersionData,
133+
bundleDiscoveryOptions: nil
134+
),
135+
DocumentationBundle.Info(
136+
displayName: "Info Plist Display Name",
137+
identifier: "com.info.Plist",
138+
version: nil
114139
)
115140
)
116141
}
@@ -217,7 +242,7 @@ class DocumentationBundleInfoTests: XCTestCase {
217242
DocumentationBundle.Info(
218243
displayName: "Display Name",
219244
identifier: "swift.org.Identifier",
220-
version: Version(arrayLiteral: 1,0,0),
245+
version: "1.0.0",
221246
defaultCodeListingLanguage: "swift",
222247
defaultModuleKind: "Executable",
223248
defaultAvailability: DefaultAvailability(
@@ -238,7 +263,7 @@ class DocumentationBundleInfoTests: XCTestCase {
238263
let info = DocumentationBundle.Info(
239264
displayName: "Display Name",
240265
identifier: "swift.org.Identifier",
241-
version: Version(arrayLiteral: 1,0,0),
266+
version: "1.0.0",
242267
defaultCodeListingLanguage: "swift",
243268
defaultModuleKind: "Executable",
244269
defaultAvailability: DefaultAvailability(

Tests/SwiftDocCTests/Infrastructure/DocumentationWorkspaceTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class DocumentationWorkspaceTests: XCTestCase {
149149
info: DocumentationBundle.Info(
150150
displayName: "Test" + suffix,
151151
identifier: "com.example.test" + suffix,
152-
version: Version(versionString: "0.1.0")!
152+
version: "0.1.0"
153153
),
154154
symbolGraphURLs: [testSymbolGraphFile],
155155
markupURLs: [testMarkupFile],

Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PresentationURLGeneratorTests: XCTestCase {
3939
info: DocumentationBundle.Info(
4040
displayName: "Test",
4141
identifier: "com.example.test",
42-
version: Version(versionString: "1.0")!
42+
version: "1.0"
4343
),
4444
baseURL: URL(string: "https://example.com/example")!,
4545
symbolGraphURLs: [],
@@ -91,7 +91,7 @@ class PresentationURLGeneratorTests: XCTestCase {
9191
info: DocumentationBundle.Info(
9292
displayName: "Test",
9393
identifier: "com.example.test",
94-
version: Version(versionString: "1.0")!
94+
version: "1.0"
9595
),
9696
baseURL: URL(string: "https://example.com/example")!,
9797
symbolGraphURLs: [],

0 commit comments

Comments
 (0)