Skip to content

Commit fc2d491

Browse files
authored
Rename TitleStyle to PropertyListTitleStyle to clarify its purpose (#919)
* Rename `TitleStyle` to `PropertyListTitleStyle` to clarify its purpose rdar://126292460 * Avoid referring to deprecated "IDE title" in updated documentation
1 parent 31c8ccf commit fc2d491

File tree

9 files changed

+250
-94
lines changed

9 files changed

+250
-94
lines changed

Sources/SwiftDocC/Indexing/RenderSection+TextIndexing.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ extension AttributesRenderSection {
328328

329329
extension PlistDetailsRenderSection {
330330
public var headings: [String] {
331-
if let ideTitle = details.ideTitle {
332-
return [details.name, ideTitle]
331+
if let displayName = details.displayName {
332+
return [details.rawKey, displayName]
333333
} else {
334-
return [details.name]
334+
return [details.rawKey]
335335
}
336336
}
337337

338338
public func rawIndexableTextContent(references: [String : RenderReference]) -> String {
339-
return [details.name, details.ideTitle ?? ""].joined(separator: " ")
339+
return [details.rawKey, details.displayName ?? ""].joined(separator: " ")
340340
}
341341
}
342342

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

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE
157157
fragments: resolvedInformation.declarationFragments?.declarationFragments.map { DeclarationRenderSection.Token(fragment: $0, identifier: nil) },
158158
isBeta: (resolvedInformation.platforms ?? []).contains(where: { $0.isBeta == true }),
159159
isDeprecated: (resolvedInformation.platforms ?? []).contains(where: { $0.deprecated != nil }),
160-
titleStyle: resolvedInformation.kind.isSymbol ? .symbol : .title,
161160
images: resolvedInformation.topicImages ?? []
162161
)
163162
for variant in resolvedInformation.variants ?? [] {

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ private extension LinkDestinationSummary {
218218
isBeta: platforms?.contains(where: { $0.isBeta == true }) ?? false,
219219
isDeprecated: platforms?.contains(where: { $0.unconditionallyDeprecated == true }) ?? false,
220220
defaultImplementationCount: nil,
221-
titleStyle: self.kind.isSymbol ? .symbol : .title,
222-
name: title,
223-
ideTitle: nil,
221+
propertyListKeyNames: nil,
224222
tags: nil,
225223
images: topicImages ?? []
226224
)

Sources/SwiftDocC/Model/Rendering/References/TopicRenderReference.swift

+195-44
Large diffs are not rendered by default.

Sources/SwiftDocC/Model/Rendering/Symbol/PlistDetailsRenderSection.swift

+32-29
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-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
@@ -10,55 +10,58 @@
1010

1111
import Foundation
1212

13-
/// A title style for a property list key or an entitlement key.
13+
/// A style for how to render links to a property list key or an entitlement key.
14+
public enum PropertyListTitleStyle: String, Codable, Equatable {
15+
/// Render links to the property list key using the raw key, for example "com.apple.enableDataAccess".
16+
///
17+
/// ## See Also
18+
/// - ``TopicRenderReference/PropertyListKeyNames/rawKey``
19+
case useRawKey = "symbol"
20+
/// Render links to the property list key using the display name, for example "Enables Data Access".
21+
///
22+
/// ## See Also
23+
/// - ``TopicRenderReference/PropertyListKeyNames/displayName``
24+
case useDisplayName = "title"
25+
}
26+
27+
@available(*, deprecated, renamed: "PropertyListTitleStyle", message: "Use 'PropertyListTitleStyle' instead. This deprecated API will be removed after 6.1 is released")
1428
public enum TitleStyle: String, Codable, Equatable {
15-
// Render links to the symbol using the "raw" name, for example, "com.apple.enableDataAccess".
29+
@available(*, deprecated, renamed: "PropertyListTitleStyle.useRawKey", message: "Use 'PropertyListTitleStyle.useRawKey' instead. This deprecated API will be removed after 6.1 is released")
1630
case symbol
17-
// Render links to the symbol using a special "IDE title" name, for example, "Enables Data Access".
31+
@available(*, deprecated, renamed: "PropertyListTitleStyle.useDisplayName", message: "Use 'PropertyListTitleStyle.useDisplayName' instead. This deprecated API will be removed after 6.1 is released")
1832
case title
1933
}
2034

2135
/// A section that contains details about a property list key.
2236
struct PlistDetailsRenderSection: RenderSection, Equatable {
23-
public var kind: RenderSectionKind = .plistDetails
37+
var kind: RenderSectionKind = .plistDetails
2438
/// A title for the section.
25-
public var title = "Details"
39+
var title = "Details"
2640

2741
/// Details for a property list key.
2842
struct Details: Codable, Equatable {
2943
/// The name of the key.
30-
let name: String
44+
let rawKey: String
3145
/// A list of types acceptable for this key's value.
3246
let value: [TypeDetails]
3347
/// A list of platforms to which this key applies.
3448
let platforms: [String]
3549
/// An optional, human-friendly name of the key.
36-
let ideTitle: String?
50+
let displayName: String?
3751
/// A title rendering style.
38-
let titleStyle: TitleStyle
52+
let titleStyle: PropertyListTitleStyle
53+
54+
enum CodingKeys: String, CodingKey {
55+
case rawKey = "name"
56+
case value
57+
case platforms
58+
case displayName = "ideTitle"
59+
case titleStyle
60+
}
3961
}
4062

4163
/// The details of the property key.
42-
public let details: Details
43-
44-
// MARK: - Codable
45-
46-
/// The list of keys you use to encode or decode this details section.
47-
public enum CodingKeys: String, CodingKey {
48-
case kind, title, details
49-
}
50-
51-
public init(from decoder: Decoder) throws {
52-
let container = try decoder.container(keyedBy: CodingKeys.self)
53-
details = try container.decode(Details.self, forKey: .details)
54-
}
55-
56-
public func encode(to encoder: Encoder) throws {
57-
var container = encoder.container(keyedBy: CodingKeys.self)
58-
try container.encode(kind, forKey: .kind)
59-
try container.encode(title, forKey: .title)
60-
try container.encode(details, forKey: .details)
61-
}
64+
let details: Details
6265
}
6366

6467
// Diffable conformance

Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class ExternalReferenceResolverTests: XCTestCase {
4949
role: role,
5050
fragments: resolvedEntityDeclarationFragments?.declarationFragments.map { fragment in
5151
return DeclarationRenderSection.Token(fragment: fragment, identifier: nil)
52-
},
53-
estimatedTime: nil,
54-
titleStyle: resolvedEntityKind.isSymbol ? .symbol : .title
52+
}
5553
),
5654
renderReferenceDependencies: RenderReferenceDependencies(),
5755
sourceLanguages: [resolvedEntityLanguage]

Tests/SwiftDocCTests/Infrastructure/TestExternalReferenceResolvers.swift

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class TestMultiResultExternalReferenceResolver: ExternalDocumentationSource {
105105
fragments: entityInfo.declarationFragments?.declarationFragments.map { fragment in
106106
return DeclarationRenderSection.Token(fragment: fragment, identifier: nil)
107107
},
108-
titleStyle: entityInfo.kind.isSymbol ? .symbol : .title,
109108
images: entityInfo.topicImages?.map(\.0) ?? []
110109
),
111110
renderReferenceDependencies: dependencies,

Tests/SwiftDocCTests/Rendering/PlistSymbolTests.swift

+9-9
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
@@ -33,9 +33,9 @@ class PlistSymbolTests: XCTestCase {
3333
return
3434
}
3535

36-
XCTAssertEqual(section.details.name, "com.apple.developer.networking.wifi")
37-
XCTAssertEqual(section.details.ideTitle, "WiFi access")
38-
XCTAssertEqual(section.details.titleStyle, .title)
36+
XCTAssertEqual(section.details.rawKey, "com.apple.developer.networking.wifi")
37+
XCTAssertEqual(section.details.displayName, "WiFi access")
38+
XCTAssertEqual(section.details.titleStyle, .useDisplayName)
3939
guard section.details.value.count == 2 else {
4040
XCTFail("Invalid number of value types found")
4141
return
@@ -113,9 +113,9 @@ class PlistSymbolTests: XCTestCase {
113113
XCTFail("Did not find doc://org.swift.docc.example/plist/dataaccess reference")
114114
return
115115
}
116-
XCTAssertEqual(reference.titleStyle, .title)
117-
XCTAssertEqual(reference.name, "com.apple.enabledataaccess")
118-
XCTAssertEqual(reference.ideTitle, "Enable Data Access")
116+
XCTAssertEqual(reference.propertyListKeyNames?.titleStyle, .useDisplayName)
117+
XCTAssertEqual(reference.propertyListKeyNames?.rawKey, "com.apple.enabledataaccess")
118+
XCTAssertEqual(reference.propertyListKeyNames?.displayName, "Enable Data Access")
119119

120120
// Test navigator information
121121
XCTAssertEqual(symbol.navigatorPageType(), .propertyListKey)
@@ -143,8 +143,8 @@ class PlistSymbolTests: XCTestCase {
143143
return
144144
}
145145

146-
XCTAssertEqual(section.details.name, "com.apple.developer.networking.wifi")
147-
XCTAssertNil(section.details.ideTitle)
146+
XCTAssertEqual(section.details.rawKey, "com.apple.developer.networking.wifi")
147+
XCTAssertNil(section.details.displayName)
148148

149149
AssertRoundtrip(for: symbol)
150150
}

Tests/SwiftDocCUtilitiesTests/OutOfProcessReferenceResolverTests.swift

+8
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ class OutOfProcessReferenceResolverTests: XCTestCase {
314314
XCTFail("Unexpected fragments variant patch")
315315
}
316316

317+
XCTAssertNil(entity.topicRenderReference.conformance)
318+
XCTAssertNil(entity.topicRenderReference.estimatedTime)
319+
XCTAssertNil(entity.topicRenderReference.defaultImplementationCount)
320+
XCTAssertFalse(entity.topicRenderReference.isBeta)
321+
XCTAssertFalse(entity.topicRenderReference.isDeprecated)
322+
XCTAssertNil(entity.topicRenderReference.propertyListKeyNames)
323+
XCTAssertNil(entity.topicRenderReference.tags)
324+
317325
XCTAssertEqual(entity.topicRenderReference.images.count, 1)
318326
let topicImage = try XCTUnwrap(entity.topicRenderReference.images.first)
319327
XCTAssertEqual(topicImage.type, .card)

0 commit comments

Comments
 (0)