@@ -19,28 +19,57 @@ public struct TaskGroupRenderSection: RenderSection {
1919 /// An optional discussion for the section.
2020 public let discussion : RenderSection ?
2121 /// A list of topic graph references.
22- public let identifiers : [ String ]
22+ @available ( * , deprecated, message: " Please use identifierItems instead. " )
23+ public var identifiers : [ String ] { identifierItems. map { $0. identifier } }
24+ /// A list of topic graph reference items
25+ public let identifierItems : [ IdentifierItem ]
2326 /// If true, this is an automatically generated group. If false, this is an authored group.
2427 public let generated : Bool
2528
29+ public struct IdentifierItem : Codable {
30+ public let identifier : String
31+ public let overrideTitle : String ?
32+
33+ public init ( identifier: String , overrideTitle: String ? = nil ) {
34+ self . identifier = identifier
35+ self . overrideTitle = overrideTitle
36+ }
37+ }
38+
2639 /// Creates a new task group.
2740 /// - Parameters:
2841 /// - title: An optional title for the section.
2942 /// - abstract: An optional abstract summary for the section.
3043 /// - discussion: An optional discussion for the section.
3144 /// - identifiers: A list of topic-graph references.
3245 /// - generated: If `true`, this is an automatically generated group. If `false`, this is an authored group.
46+ @available ( * , deprecated, message: " Please use TaskGroupRenderSection.init(title:abstract:discussion:identifierItems:generated:) instead. " )
3347 public init ( title: String ? , abstract: [ RenderInlineContent ] ? , discussion: RenderSection ? , identifiers: [ String ] , generated: Bool = false ) {
3448 self . title = title
3549 self . abstract = abstract
3650 self . discussion = discussion
37- self . identifiers = identifiers
51+ self . identifierItems = identifiers. map { IdentifierItem ( identifier: $0) }
52+ self . generated = generated
53+ }
54+
55+ /// Creates a new task group.
56+ /// - Parameters:
57+ /// - title: An optional title for the section.
58+ /// - abstract: An optional abstract summary for the section.
59+ /// - discussion: An optional discussion for the section.
60+ /// - identifiers: A list of topic-graph references.
61+ /// - generated: If `true`, this is an automatically generated group. If `false`, this is an authored group.
62+ public init ( title: String ? , abstract: [ RenderInlineContent ] ? , discussion: RenderSection ? , identifierItems: [ IdentifierItem ] , generated: Bool = false ) {
63+ self . title = title
64+ self . abstract = abstract
65+ self . discussion = discussion
66+ self . identifierItems = identifierItems
3867 self . generated = generated
3968 }
4069
4170 /// The list of keys you use to encode or decode this section.
4271 private enum CodingKeys : CodingKey {
43- case title, abstract, discussion, identifiers, generated
72+ case title, abstract, discussion, identifiers, identifierItems , generated
4473 }
4574
4675 public func encode( to encoder: Encoder ) throws {
@@ -50,6 +79,7 @@ public struct TaskGroupRenderSection: RenderSection {
5079 try container. encodeIfPresent ( abstract, forKey: . abstract)
5180 try container. encodeIfPresent ( discussion. map ( CodableRenderSection . init) , forKey: . discussion)
5281 try container. encode ( identifiers, forKey: . identifiers)
82+ try container. encode ( identifierItems, forKey: . identifierItems)
5383 if generated {
5484 try container. encode ( generated, forKey: . generated)
5585 }
@@ -61,11 +91,18 @@ public struct TaskGroupRenderSection: RenderSection {
6191 title = try container. decodeIfPresent ( String . self, forKey: . title)
6292 abstract = try container. decodeIfPresent ( [ RenderInlineContent ] . self, forKey: . abstract)
6393 discussion = ( try container. decodeIfPresent ( CodableContentSection . self, forKey: . discussion) ) . map { $0. section }
64- identifiers = try container. decode ( [ String ] . self, forKey: . identifiers)
65-
66- decoder. registerReferences ( identifiers)
67-
94+
95+ let identifiers = try container. decodeIfPresent ( [ String ] . self, forKey: . identifiers)
96+ let identifierItems = try container. decodeIfPresent ( [ IdentifierItem ] . self, forKey: . identifierItems)
97+ if let identifierItems = identifierItems {
98+ self . identifierItems = identifierItems
99+ } else if let identifiers = identifiers {
100+ self . identifierItems = identifiers. map { IdentifierItem ( identifier: $0) }
101+ } else {
102+ self . identifierItems = [ ]
103+ }
68104 generated = try container. decodeIfPresent ( Bool . self, forKey: . generated) ?? false
105+ decoder. registerReferences ( self . identifiers)
69106 }
70107}
71108
@@ -76,7 +113,7 @@ extension TaskGroupRenderSection {
76113 self . title = group. title
77114 self . abstract = nil
78115 self . discussion = nil
79- self . identifiers = group. references. map ( { $0. absoluteString } )
116+ self . identifierItems = group. references. map { IdentifierItem ( identifier : $0. absoluteString) }
80117 self . generated = false
81118 }
82119}
0 commit comments