@@ -139,7 +139,12 @@ public struct LinkDestinationSummary: Codable, Equatable {
139
139
public typealias DeclarationFragments = [ DeclarationRenderSection . Token ]
140
140
/// The fragments for this symbol's declaration, or `nil` if the summarized element isn't a symbol.
141
141
public let declarationFragments : DeclarationFragments ?
142
-
142
+
143
+ /// The abbreviated fragments for this symbol's declaration, or `nil` if the summarized element isn't a symbol.
144
+ ///
145
+ /// They are used for displaying in contexts where the full declaration fragments would be too verbose, like in the Topics section or the navigation index.
146
+ public let subHeadingDeclarationFragments : DeclarationFragments ?
147
+
143
148
/// Any previous URLs for this element.
144
149
///
145
150
/// A web server can use this list of URLs to redirect to the current URL.
@@ -197,7 +202,13 @@ public struct LinkDestinationSummary: Codable, Equatable {
197
202
///
198
203
/// If the summarized element has a declaration but the variant doesn't, this property will be `Optional.some(nil)`.
199
204
public let declarationFragments : VariantValue < DeclarationFragments ? >
200
-
205
+
206
+ /// The abbreviated declaration of the variant or `nil` if the declaration is the same as the summarized element.
207
+ ///
208
+ /// They are used for displaying in contexts where the full declaration fragments would be too verbose, like in the Topics section or the navigation index.
209
+ /// If the summarized element has an abbreviated declaration but the variant doesn't, this property will be `Optional.some(nil)`.
210
+ public let subHeadingDeclarationFragments : VariantValue < DeclarationFragments ? >
211
+
201
212
/// Images that are used to represent the summarized element or `nil` if the images are the same as the summarized element.
202
213
///
203
214
/// If the summarized element has an image but the variant doesn't, this property will be `Optional.some(nil)`.
@@ -215,6 +226,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
215
226
/// - taskGroups: The taskGroups of the variant or `nil` if the taskGroups is the same as the summarized element.
216
227
/// - usr: The precise symbol identifier of the variant or `nil` if the precise symbol identifier is the same as the summarized element.
217
228
/// - declarationFragments: The declaration of the variant or `nil` if the declaration is the same as the summarized element.
229
+ /// - subHeadingDeclarationFragments: The abbreviated declaration of the variant or `nil` if the declaration is the same as the summarized element.
218
230
/// - topicImages: Images that are used to represent the summarized element or `nil` if the images are the same as the summarized element.
219
231
public init (
220
232
traits: [ RenderNode . Variant . Trait ] ,
@@ -226,6 +238,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
226
238
taskGroups: VariantValue < [ LinkDestinationSummary . TaskGroup ] ? > = nil ,
227
239
usr: VariantValue < String ? > = nil ,
228
240
declarationFragments: VariantValue < LinkDestinationSummary . DeclarationFragments ? > = nil ,
241
+ subHeadingDeclarationFragments: VariantValue < LinkDestinationSummary . DeclarationFragments ? > = nil ,
229
242
topicImages: VariantValue < [ TopicImage ] ? > = nil
230
243
) {
231
244
self . traits = traits
@@ -237,6 +250,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
237
250
self . taskGroups = taskGroups
238
251
self . usr = usr
239
252
self . declarationFragments = declarationFragments
253
+ self . subHeadingDeclarationFragments = subHeadingDeclarationFragments
240
254
self . topicImages = topicImages
241
255
}
242
256
}
@@ -258,6 +272,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
258
272
/// - taskGroups: The reference URLs of the summarized element's children, grouped by their task groups.
259
273
/// - 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.
260
274
/// - declarationFragments: The fragments for this symbol's declaration, or `nil` if the summarized element isn't a symbol.
275
+ /// - subHeadingDeclarationFragments: The abbreviated fragments for this symbol's declaration, or `nil` if the summarized element isn't a symbol.
261
276
/// - redirects: Any previous URLs for this element, or `nil` if this element has no previous URLs.
262
277
/// - topicImages: Images that are used to represent the summarized element, or `nil` if this element has no topic images.
263
278
/// - references: References used in the content of the summarized element, or `nil` if this element has no references to other content.
@@ -273,6 +288,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
273
288
taskGroups: [ LinkDestinationSummary . TaskGroup ] ? = nil ,
274
289
usr: String ? = nil ,
275
290
declarationFragments: LinkDestinationSummary . DeclarationFragments ? = nil ,
291
+ subHeadingDeclarationFragments: LinkDestinationSummary . DeclarationFragments ? = nil ,
276
292
redirects: [ URL ] ? = nil ,
277
293
topicImages: [ TopicImage ] ? = nil ,
278
294
references: [ any RenderReference ] ? = nil ,
@@ -289,6 +305,7 @@ public struct LinkDestinationSummary: Codable, Equatable {
289
305
self . taskGroups = taskGroups
290
306
self . usr = usr
291
307
self . declarationFragments = declarationFragments
308
+ self . subHeadingDeclarationFragments = subHeadingDeclarationFragments
292
309
self . redirects = redirects
293
310
self . topicImages = topicImages
294
311
self . references = references
@@ -444,7 +461,11 @@ extension LinkDestinationSummary {
444
461
let usr = symbol. externalIDVariants [ summaryTrait] ?? symbol. externalID
445
462
let declaration = ( symbol. declarationVariants [ summaryTrait] ?? symbol. declaration) . renderDeclarationTokens ( )
446
463
let language = documentationNode. sourceLanguage
447
-
464
+ // Use the render metadata declaration fragments as the subheading declaration fragments.
465
+ // These have been derived from the symbol's original subheading declaration fragments as part of the rendering step.
466
+ // They are an abbreviated version of the declaration for display in Topic sections, the navigator, etc..
467
+ let subHeadingDeclaration = renderNode. metadata. fragmentsVariants. value ( for: language)
468
+
448
469
let variants : [ Variant ] = documentationNode. availableVariantTraits. compactMap { trait in
449
470
// Skip the variant for the summarized elements source language.
450
471
guard let interfaceLanguage = trait. interfaceLanguage, interfaceLanguage != documentationNode. sourceLanguage. id else {
@@ -460,6 +481,11 @@ extension LinkDestinationSummary {
460
481
}
461
482
462
483
let variantTraits = [ RenderNode . Variant. Trait. interfaceLanguage ( interfaceLanguage) ]
484
+
485
+ // Use the render metadata declaration fragments as the subheading declaration fragments.
486
+ // These have been derived from the symbol's original subheading declaration fragments as part of the rendering step.
487
+ // They are an abbreviated version of the declaration for display in Topic sections, the navigator, etc..
488
+ let subHeadingDeclarationVariant = renderNode. metadata. fragmentsVariants. value ( for: variantTraits)
463
489
return Variant (
464
490
traits: variantTraits,
465
491
kind: nilIfEqual ( main: kind, variant: symbol. kindVariants [ trait] . map { DocumentationNode . kind ( forKind: $0. identifier) } ) ,
@@ -470,6 +496,7 @@ extension LinkDestinationSummary {
470
496
taskGroups: nilIfEqual ( main: taskGroups, variant: taskGroupVariants [ variantTraits] ) ,
471
497
usr: nil , // The symbol variant uses the same USR
472
498
declarationFragments: nilIfEqual ( main: declaration, variant: declarationVariant) ,
499
+ subHeadingDeclarationFragments: nilIfEqual ( main: subHeadingDeclaration, variant: subHeadingDeclarationVariant) ,
473
500
topicImages: nil // The symbol variant doesn't currently have their own images
474
501
)
475
502
}
@@ -490,6 +517,7 @@ extension LinkDestinationSummary {
490
517
taskGroups: taskGroups,
491
518
usr: usr,
492
519
declarationFragments: declaration,
520
+ subHeadingDeclarationFragments: subHeadingDeclaration,
493
521
redirects: redirects,
494
522
topicImages: topicImages. nilIfEmpty,
495
523
references: references. nilIfEmpty,
@@ -574,6 +602,7 @@ extension LinkDestinationSummary {
574
602
case kind, referenceURL, title, abstract, language, taskGroups, usr, availableLanguages, platforms, redirects, topicImages, references, variants
575
603
case relativePresentationURL = " path "
576
604
case declarationFragments = " fragments "
605
+ case subHeadingDeclarationFragments = " subheadingFragments "
577
606
}
578
607
579
608
public func encode( to encoder: any Encoder ) throws {
@@ -589,6 +618,7 @@ extension LinkDestinationSummary {
589
618
try container. encodeIfPresent ( taskGroups, forKey: . taskGroups)
590
619
try container. encodeIfPresent ( usr, forKey: . usr)
591
620
try container. encodeIfPresent ( declarationFragments, forKey: . declarationFragments)
621
+ try container. encodeIfPresent ( subHeadingDeclarationFragments, forKey: . subHeadingDeclarationFragments)
592
622
try container. encodeIfPresent ( redirects, forKey: . redirects)
593
623
try container. encodeIfPresent ( topicImages, forKey: . topicImages)
594
624
try container. encodeIfPresent ( references? . map { CodableRenderReference ( $0) } , forKey: . references)
@@ -626,6 +656,7 @@ extension LinkDestinationSummary {
626
656
taskGroups = try container. decodeIfPresent ( [ TaskGroup ] . self, forKey: . taskGroups)
627
657
usr = try container. decodeIfPresent ( String . self, forKey: . usr)
628
658
declarationFragments = try container. decodeIfPresent ( DeclarationFragments . self, forKey: . declarationFragments)
659
+ subHeadingDeclarationFragments = try container. decodeIfPresent ( DeclarationFragments . self, forKey: . subHeadingDeclarationFragments)
629
660
redirects = try container. decodeIfPresent ( [ URL ] . self, forKey: . redirects)
630
661
topicImages = try container. decodeIfPresent ( [ TopicImage ] . self, forKey: . topicImages)
631
662
references = try container. decodeIfPresent ( [ CodableRenderReference ] . self, forKey: . references) . map { decodedReferences in
@@ -641,6 +672,7 @@ extension LinkDestinationSummary.Variant {
641
672
case traits, kind, title, abstract, language, usr, taskGroups, topicImages
642
673
case relativePresentationURL = " path "
643
674
case declarationFragments = " fragments "
675
+ case subHeadingDeclarationFragments = " subheadingFragments "
644
676
}
645
677
646
678
public func encode( to encoder: any Encoder ) throws {
@@ -653,6 +685,7 @@ extension LinkDestinationSummary.Variant {
653
685
try container. encodeIfPresent ( language? . id, forKey: . language)
654
686
try container. encodeIfPresent ( usr, forKey: . usr)
655
687
try container. encodeIfPresent ( declarationFragments, forKey: . declarationFragments)
688
+ try container. encodeIfPresent ( subHeadingDeclarationFragments, forKey: . subHeadingDeclarationFragments)
656
689
try container. encodeIfPresent ( taskGroups, forKey: . taskGroups)
657
690
try container. encodeIfPresent ( topicImages, forKey: . topicImages)
658
691
}
@@ -692,6 +725,8 @@ extension LinkDestinationSummary.Variant {
692
725
abstract = try container. decodeIfPresent ( LinkDestinationSummary . Abstract? . self, forKey: . abstract)
693
726
usr = try container. decodeIfPresent ( String ? . self, forKey: . usr)
694
727
declarationFragments = try container. decodeIfPresent ( LinkDestinationSummary . DeclarationFragments? . self, forKey: . declarationFragments)
728
+ subHeadingDeclarationFragments = try container
729
+ . decodeIfPresent ( LinkDestinationSummary . DeclarationFragments? . self, forKey: . subHeadingDeclarationFragments)
695
730
taskGroups = try container. decodeIfPresent ( [ LinkDestinationSummary . TaskGroup] ? . self, forKey: . taskGroups)
696
731
topicImages = try container. decodeIfPresent ( [ TopicImage] ? . self, forKey: . topicImages)
697
732
}
0 commit comments