Skip to content

Commit fe99385

Browse files
committed
Rename navigatorTitle to navigatorDeclarationFragments
Renamed the property in `LinkDestinationSummary` which stores the declaration fragments for the navigator to `navigatorDeclarationFragments`, to follow the same naming convention as `subheadingDeclarationFragments` which fulfils a very similar purpose. The documentation comments mirror each other, with one explaining that it's intended for use in topic groups, and the other that it's intended for use in navigators.
1 parent 7880114 commit fe99385

File tree

5 files changed

+58
-42
lines changed

5 files changed

+58
-42
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ extension LinkDestinationSummary {
172172
var titleVariants = VariantCollection(defaultValue: title)
173173
var abstractVariants = VariantCollection(defaultValue: abstract ?? [])
174174
var fragmentVariants = VariantCollection(defaultValue: subheadingDeclarationFragments)
175-
var navigatorTitleVariants = VariantCollection(defaultValue: navigatorTitle)
175+
var navigatorTitleVariants = VariantCollection(defaultValue: navigatorDeclarationFragments)
176176

177177
for variant in variants {
178178
let traits = variant.traits
@@ -185,7 +185,7 @@ extension LinkDestinationSummary {
185185
if let fragment = variant.subheadingDeclarationFragments {
186186
fragmentVariants.variants.append(.init(traits: traits, patch: [.replace(value: fragment)]))
187187
}
188-
if let navigatorTitle = variant.navigatorTitle {
188+
if let navigatorTitle = variant.navigatorDeclarationFragments {
189189
navigatorTitleVariants.variants.append(.init(traits: traits, patch: [.replace(value: navigatorTitle)]))
190190
}
191191
}

Sources/SwiftDocC/LinkTargets/LinkDestinationSummary.swift

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
159159
///
160160
/// - Note: The navigator title does not represent the symbol's full declaration.
161161
/// Different overloads may have indistinguishable subheading fragments.
162-
public let navigatorTitle: DeclarationFragments?
162+
public let navigatorDeclarationFragments: DeclarationFragments?
163163

164164
/// Any previous URLs for this element.
165165
///
@@ -236,7 +236,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
236236
/// These navigator fragments are suitable to use to refer to a symbol that's linked to in a navigator.
237237
///
238238
/// If the summarized element has a navigator title but the variant doesn't, this property will be `Optional.some(nil)`.
239-
public let navigatorTitle: VariantValue<DeclarationFragments?>
239+
public let navigatorDeclarationFragments: VariantValue<DeclarationFragments?>
240240

241241
/// Images that are used to represent the summarized element or `nil` if the images are the same as the summarized element.
242242
///
@@ -256,8 +256,8 @@ public struct LinkDestinationSummary: Codable, Equatable {
256256
/// - taskGroups: The taskGroups of the variant or `nil` if the taskGroups is the same as the summarized element.
257257
/// - usr: The precise symbol identifier of the variant or `nil` if the precise symbol identifier is the same as the summarized element.
258258
/// - plainTextDeclaration: The plain text declaration of this symbol, derived from its full declaration fragments, or `nil` if the precise symbol identifier is the same as the summarized element.
259-
/// - subheadingDeclarationFragments: The abbreviated declaration of the variant, to display in links, or `nil` if the declaration is the same as the summarized element.
260-
/// - navigatorTitle: The abbreviated declaration for this symbol's declaration, to display in navigation, or `nil` if the declaration is the same as the summarized element.
259+
/// - subheadingDeclarationFragments: The simplified "subheading" declaration fragments for this symbol, to display in topic groups, or `nil` if the declaration is the same as the summarized element.
260+
/// - navigatorDeclarationFragments: The simplified "navigator" declaration fragments for this symbol, to display in navigation, or `nil` if the declaration is the same as the summarized element.
261261
public init(
262262
traits: [RenderNode.Variant.Trait],
263263
kind: VariantValue<DocumentationNode.Kind> = nil,
@@ -269,7 +269,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
269269
usr: VariantValue<String?> = nil,
270270
plainTextDeclaration: VariantValue<String?> = nil,
271271
subheadingDeclarationFragments: VariantValue<LinkDestinationSummary.DeclarationFragments?> = nil,
272-
navigatorTitle: VariantValue<LinkDestinationSummary.DeclarationFragments?> = nil
272+
navigatorDeclarationFragments: VariantValue<LinkDestinationSummary.DeclarationFragments?> = nil
273273
) {
274274
self.traits = traits
275275
self.kind = kind
@@ -281,10 +281,10 @@ public struct LinkDestinationSummary: Codable, Equatable {
281281
self.usr = usr
282282
self.plainTextDeclaration = plainTextDeclaration
283283
self.subheadingDeclarationFragments = subheadingDeclarationFragments
284-
self.navigatorTitle = navigatorTitle
284+
self.navigatorDeclarationFragments = navigatorDeclarationFragments
285285
}
286286

287-
@available(*, deprecated, renamed: "init(traits:kind:language:relativePresentationURL:title:abstract:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorTitle:)", message: "Use `init(traits:kind:language:relativePresentationURL:title:abstract:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorTitle:)` instead. `TopicRenderReference` doesn't support variant specific topic images. This property will be removed after 6.3 is released")
287+
@available(*, deprecated, renamed: "init(traits:kind:language:relativePresentationURL:title:abstract:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorDeclarationFragments:)", message: "Use `init(traits:kind:language:relativePresentationURL:title:abstract:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorDeclarationFragments:)` instead. `TopicRenderReference` doesn't support variant specific topic images. This property will be removed after 6.3 is released")
288288
public init(
289289
traits: [RenderNode.Variant.Trait],
290290
kind: VariantValue<DocumentationNode.Kind> = nil,
@@ -296,7 +296,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
296296
usr: VariantValue<String?> = nil,
297297
plainTextDeclaration: VariantValue<String?> = nil,
298298
declarationFragments: VariantValue<LinkDestinationSummary.DeclarationFragments?> = nil,
299-
navigatorTitle: VariantValue<LinkDestinationSummary.DeclarationFragments?> = nil,
299+
navigatorDeclarationFragments: VariantValue<LinkDestinationSummary.DeclarationFragments?> = nil,
300300
topicImages: VariantValue<[TopicImage]?> = nil
301301
) {
302302
self.init(
@@ -310,7 +310,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
310310
usr: usr,
311311
plainTextDeclaration: plainTextDeclaration,
312312
subheadingDeclarationFragments: declarationFragments,
313-
navigatorTitle: navigatorTitle
313+
navigatorDeclarationFragments: navigatorDeclarationFragments
314314
)
315315
}
316316
}
@@ -332,8 +332,8 @@ public struct LinkDestinationSummary: Codable, Equatable {
332332
/// - taskGroups: The reference URLs of the summarized element's children, grouped by their task groups.
333333
/// - usr: The unique, precise identifier for this symbol that you use to reference it across different systems, or `nil` if the summarized element isn't a symbol.
334334
/// - plainTextDeclaration: The plain text declaration of this symbol, derived from its full declaration fragments, or `nil` if the summarized element isn't a symbol.
335-
/// - subheadingDeclarationFragments: The simplified "subheading" fragments for this symbol, or `nil` if the summarized element isn't a symbol.
336-
/// - navigatorTitle: The abbreviated fragments for this symbol's declaration, to display in navigation, or `nil` if the summarized element isn't a symbol.
335+
/// - subheadingDeclarationFragments: The simplified "subheading" fragments for this symbol, to display in topic groups, or `nil` if the summarized element isn't a symbol.
336+
/// - navigatorDeclarationFragments: The simplified "subheading" declaration fragments for this symbol, to display in navigation, or `nil` if the summarized element isn't a symbol.
337337
/// - redirects: Any previous URLs for this element, or `nil` if this element has no previous URLs.
338338
/// - topicImages: Images that are used to represent the summarized element, or `nil` if this element has no topic images.
339339
/// - references: References used in the content of the summarized element, or `nil` if this element has no references to other content.
@@ -350,7 +350,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
350350
usr: String? = nil,
351351
plainTextDeclaration: String? = nil,
352352
subheadingDeclarationFragments: LinkDestinationSummary.DeclarationFragments? = nil,
353-
navigatorTitle: LinkDestinationSummary.DeclarationFragments? = nil,
353+
navigatorDeclarationFragments: LinkDestinationSummary.DeclarationFragments? = nil,
354354
redirects: [URL]? = nil,
355355
topicImages: [TopicImage]? = nil,
356356
references: [any RenderReference]? = nil,
@@ -368,14 +368,14 @@ public struct LinkDestinationSummary: Codable, Equatable {
368368
self.usr = usr
369369
self.plainTextDeclaration = plainTextDeclaration
370370
self.subheadingDeclarationFragments = subheadingDeclarationFragments
371-
self.navigatorTitle = navigatorTitle
371+
self.navigatorDeclarationFragments = navigatorDeclarationFragments
372372
self.redirects = redirects
373373
self.topicImages = topicImages
374374
self.references = references
375375
self.variants = variants
376376
}
377377

378-
@available(*, deprecated, renamed: "init(kind:language:relativePresentationURL:referenceURL:title:abstract:availableLanguages:platforms:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorTitle:redirects:topicImages:references:variants:)", message: "Use `init(kind:language:relativePresentationURL:referenceURL:title:abstract:availableLanguages:platforms:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorTitle:redirects:topicImages:references:variants:)` instead. This property will be removed after 6.3 is released")
378+
@available(*, deprecated, renamed: "init(kind:language:relativePresentationURL:referenceURL:title:abstract:availableLanguages:platforms:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorDeclarationFragments:redirects:topicImages:references:variants:)", message: "Use `init(kind:language:relativePresentationURL:referenceURL:title:abstract:availableLanguages:platforms:taskGroups:usr:plainTextDeclaration:subheadingDeclarationFragments:navigatorDeclarationFragments:redirects:topicImages:references:variants:)` instead. This property will be removed after 6.3 is released")
379379
public init(
380380
kind: DocumentationNode.Kind,
381381
language: SourceLanguage,
@@ -388,7 +388,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
388388
usr: String? = nil,
389389
plainTextDeclaration: String? = nil,
390390
declarationFragments: LinkDestinationSummary.DeclarationFragments?,
391-
navigatorTitle: LinkDestinationSummary.DeclarationFragments? = nil,
391+
navigatorDeclarationFragments: LinkDestinationSummary.DeclarationFragments? = nil,
392392
redirects: [URL]? = nil,
393393
topicImages: [TopicImage]? = nil,
394394
references: [any RenderReference]? = nil,
@@ -407,7 +407,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
407407
usr: usr,
408408
plainTextDeclaration: plainTextDeclaration,
409409
subheadingDeclarationFragments: declarationFragments,
410-
navigatorTitle: navigatorTitle,
410+
navigatorDeclarationFragments: navigatorDeclarationFragments,
411411
redirects: redirects,
412412
topicImages: topicImages,
413413
references: references,
@@ -567,7 +567,7 @@ extension LinkDestinationSummary {
567567
// If no abbreviated declaration fragments are available, use the full declaration fragments instead.
568568
// In this case, they are assumed to be the same.
569569
let subheadingDeclarationFragments = renderNode.metadata.fragmentsVariants.value(for: language) ?? (symbol.declarationVariants[summaryTrait] ?? symbol.declaration).renderDeclarationTokens()
570-
let navigatorTitle = renderNode.metadata.navigatorTitleVariants.value(for: language)
570+
let navigatorDeclarationFragments = renderNode.metadata.navigatorTitleVariants.value(for: language)
571571

572572
let variants: [Variant] = documentationNode.availableVariantTraits.compactMap { trait in
573573
// Skip the variant for the summarized elements source language.
@@ -591,8 +591,8 @@ extension LinkDestinationSummary {
591591
//
592592
// However if no abbreviated declaration fragments are available, use the full declaration fragments instead.
593593
// In this case, they are assumed to be the same.
594-
let declarationVariant = renderNode.metadata.fragmentsVariants.value(for: variantTraits) ?? symbol.declarationVariants[trait]?.renderDeclarationTokens()
595-
let navigatorTitleVariant = renderNode.metadata.navigatorTitleVariants.value(for: variantTraits)
594+
let subheadingDeclarationFragmentsVariant = renderNode.metadata.fragmentsVariants.value(for: variantTraits) ?? symbol.declarationVariants[trait]?.renderDeclarationTokens()
595+
let navigatorDeclarationFragmentsVariant = renderNode.metadata.navigatorTitleVariants.value(for: variantTraits)
596596
return Variant(
597597
traits: variantTraits,
598598
kind: nilIfEqual(main: kind, variant: symbol.kindVariants[trait].map { DocumentationNode.kind(forKind: $0.identifier) }),
@@ -603,8 +603,8 @@ extension LinkDestinationSummary {
603603
taskGroups: nilIfEqual(main: taskGroups, variant: taskGroupVariants[variantTraits]),
604604
usr: nil, // The symbol variant uses the same USR
605605
plainTextDeclaration: nilIfEqual(main: plainTextDeclaration, variant: plainTextDeclarationVariant),
606-
subheadingDeclarationFragments: nilIfEqual(main: subheadingDeclarationFragments, variant: declarationVariant),
607-
navigatorTitle: nilIfEqual(main: navigatorTitle, variant: navigatorTitleVariant)
606+
subheadingDeclarationFragments: nilIfEqual(main: subheadingDeclarationFragments, variant: subheadingDeclarationFragmentsVariant),
607+
navigatorDeclarationFragments: nilIfEqual(main: navigatorDeclarationFragments, variant: navigatorDeclarationFragmentsVariant)
608608
)
609609
}
610610

@@ -625,7 +625,7 @@ extension LinkDestinationSummary {
625625
usr: usr,
626626
plainTextDeclaration: plainTextDeclaration,
627627
subheadingDeclarationFragments: subheadingDeclarationFragments,
628-
navigatorTitle: navigatorTitle,
628+
navigatorDeclarationFragments: navigatorDeclarationFragments,
629629
redirects: redirects,
630630
topicImages: topicImages.nilIfEmpty,
631631
references: references.nilIfEmpty,
@@ -707,9 +707,10 @@ extension LinkDestinationSummary {
707707
// Add Codable methods—which include an initializer—in an extension so that it doesn't override the member-wise initializer.
708708
extension LinkDestinationSummary {
709709
enum CodingKeys: String, CodingKey {
710-
case kind, referenceURL, title, abstract, language, taskGroups, usr, availableLanguages, platforms, redirects, topicImages, references, variants, plainTextDeclaration, navigatorTitle
710+
case kind, referenceURL, title, abstract, language, taskGroups, usr, availableLanguages, platforms, redirects, topicImages, references, variants, plainTextDeclaration
711711
case relativePresentationURL = "path"
712712
case subheadingDeclarationFragments = "fragments"
713+
case navigatorDeclarationFragments = "navigatorFragments"
713714
}
714715

715716
public func encode(to encoder: any Encoder) throws {
@@ -741,7 +742,7 @@ extension LinkDestinationSummary {
741742
try container.encodeIfPresent(usr, forKey: .usr)
742743
try container.encodeIfPresent(plainTextDeclaration, forKey: .plainTextDeclaration)
743744
try container.encodeIfPresent(subheadingDeclarationFragments, forKey: .subheadingDeclarationFragments)
744-
try container.encodeIfPresent(navigatorTitle, forKey: .navigatorTitle)
745+
try container.encodeIfPresent(navigatorDeclarationFragments, forKey: .navigatorDeclarationFragments)
745746
try container.encodeIfPresent(redirects, forKey: .redirects)
746747
try container.encodeIfPresent(topicImages, forKey: .topicImages)
747748
try container.encodeIfPresent(references?.map { CodableRenderReference($0) }, forKey: .references)
@@ -799,7 +800,7 @@ extension LinkDestinationSummary {
799800
usr = try container.decodeIfPresent(String.self, forKey: .usr)
800801
plainTextDeclaration = try container.decodeIfPresent(String.self, forKey: .plainTextDeclaration)
801802
subheadingDeclarationFragments = try container.decodeIfPresent(DeclarationFragments.self, forKey: .subheadingDeclarationFragments)
802-
navigatorTitle = try container.decodeIfPresent(DeclarationFragments.self, forKey: .navigatorTitle)
803+
navigatorDeclarationFragments = try container.decodeIfPresent(DeclarationFragments.self, forKey: .navigatorDeclarationFragments)
803804
redirects = try container.decodeIfPresent([URL].self, forKey: .redirects)
804805
topicImages = try container.decodeIfPresent([TopicImage].self, forKey: .topicImages)
805806
references = try container.decodeIfPresent([CodableRenderReference].self, forKey: .references).map { decodedReferences in
@@ -812,9 +813,10 @@ extension LinkDestinationSummary {
812813

813814
extension LinkDestinationSummary.Variant {
814815
enum CodingKeys: String, CodingKey {
815-
case traits, kind, title, abstract, language, usr, taskGroups, plainTextDeclaration, navigatorTitle
816+
case traits, kind, title, abstract, language, usr, taskGroups, plainTextDeclaration
816817
case relativePresentationURL = "path"
817818
case declarationFragments = "fragments"
819+
case navigatorDeclarationFragments = "navigatorFragments"
818820
}
819821

820822
public func encode(to encoder: any Encoder) throws {
@@ -840,7 +842,7 @@ extension LinkDestinationSummary.Variant {
840842
try container.encodeIfPresent(usr, forKey: .usr)
841843
try container.encodeIfPresent(plainTextDeclaration, forKey: .plainTextDeclaration)
842844
try container.encodeIfPresent(subheadingDeclarationFragments, forKey: .declarationFragments)
843-
try container.encodeIfPresent(navigatorTitle, forKey: .navigatorTitle)
845+
try container.encodeIfPresent(navigatorDeclarationFragments, forKey: .navigatorDeclarationFragments)
844846
try container.encodeIfPresent(taskGroups, forKey: .taskGroups)
845847
}
846848

@@ -883,7 +885,8 @@ extension LinkDestinationSummary.Variant {
883885
usr = try container.decodeIfPresent(String?.self, forKey: .usr)
884886
plainTextDeclaration = try container.decodeIfPresent(String?.self, forKey: .plainTextDeclaration)
885887
subheadingDeclarationFragments = try container.decodeIfPresent(LinkDestinationSummary.DeclarationFragments?.self, forKey: .declarationFragments)
886-
navigatorTitle = try container.decodeIfPresent(LinkDestinationSummary.DeclarationFragments?.self, forKey: .navigatorTitle)
888+
navigatorDeclarationFragments = try container
889+
.decodeIfPresent(LinkDestinationSummary.DeclarationFragments?.self, forKey: .navigatorDeclarationFragments)
887890
taskGroups = try container.decodeIfPresent([LinkDestinationSummary.TaskGroup]?.self, forKey: .taskGroups)
888891
}
889892
}

0 commit comments

Comments
 (0)