@@ -19,28 +19,59 @@ 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+ public let overridingTitleInlineContent : [ RenderInlineContent ] ?
33+
34+ public init ( identifier: String , overrideTitle: String ? = nil , overridingTitleInlineContent: [ RenderInlineContent ] ? = nil ) {
35+ self . identifier = identifier
36+ self . overrideTitle = overrideTitle
37+ self . overridingTitleInlineContent = overridingTitleInlineContent
38+ }
39+ }
40+
2641 /// Creates a new task group.
2742 /// - Parameters:
2843 /// - title: An optional title for the section.
2944 /// - abstract: An optional abstract summary for the section.
3045 /// - discussion: An optional discussion for the section.
3146 /// - identifiers: A list of topic-graph references.
3247 /// - generated: If `true`, this is an automatically generated group. If `false`, this is an authored group.
48+ @available ( * , deprecated, message: " Please use TaskGroupRenderSection.init(title:abstract:discussion:identifierItems:generated:) instead. " )
3349 public init ( title: String ? , abstract: [ RenderInlineContent ] ? , discussion: RenderSection ? , identifiers: [ String ] , generated: Bool = false ) {
3450 self . title = title
3551 self . abstract = abstract
3652 self . discussion = discussion
37- self . identifiers = identifiers
53+ self . identifierItems = identifiers. map { IdentifierItem ( identifier: $0) }
54+ self . generated = generated
55+ }
56+
57+ /// Creates a new task group.
58+ /// - Parameters:
59+ /// - title: An optional title for the section.
60+ /// - abstract: An optional abstract summary for the section.
61+ /// - discussion: An optional discussion for the section.
62+ /// - identifiers: A list of topic-graph references.
63+ /// - generated: If `true`, this is an automatically generated group. If `false`, this is an authored group.
64+ public init ( title: String ? , abstract: [ RenderInlineContent ] ? , discussion: RenderSection ? , identifierItems: [ IdentifierItem ] , generated: Bool = false ) {
65+ self . title = title
66+ self . abstract = abstract
67+ self . discussion = discussion
68+ self . identifierItems = identifierItems
3869 self . generated = generated
3970 }
4071
4172 /// The list of keys you use to encode or decode this section.
4273 private enum CodingKeys : CodingKey {
43- case title, abstract, discussion, identifiers, generated
74+ case title, abstract, discussion, identifiers, identifierItems , generated
4475 }
4576
4677 public func encode( to encoder: Encoder ) throws {
@@ -50,6 +81,7 @@ public struct TaskGroupRenderSection: RenderSection {
5081 try container. encodeIfPresent ( abstract, forKey: . abstract)
5182 try container. encodeIfPresent ( discussion. map ( CodableRenderSection . init) , forKey: . discussion)
5283 try container. encode ( identifiers, forKey: . identifiers)
84+ try container. encode ( identifierItems, forKey: . identifierItems)
5385 if generated {
5486 try container. encode ( generated, forKey: . generated)
5587 }
@@ -61,11 +93,18 @@ public struct TaskGroupRenderSection: RenderSection {
6193 title = try container. decodeIfPresent ( String . self, forKey: . title)
6294 abstract = try container. decodeIfPresent ( [ RenderInlineContent ] . self, forKey: . abstract)
6395 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-
96+
97+ let identifiers = try container. decodeIfPresent ( [ String ] . self, forKey: . identifiers)
98+ let identifierItems = try container. decodeIfPresent ( [ IdentifierItem ] . self, forKey: . identifierItems)
99+ if let identifierItems = identifierItems {
100+ self . identifierItems = identifierItems
101+ } else if let identifiers = identifiers {
102+ self . identifierItems = identifiers. map { IdentifierItem ( identifier: $0) }
103+ } else {
104+ self . identifierItems = [ ]
105+ }
68106 generated = try container. decodeIfPresent ( Bool . self, forKey: . generated) ?? false
107+ decoder. registerReferences ( self . identifiers)
69108 }
70109}
71110
@@ -76,7 +115,7 @@ extension TaskGroupRenderSection {
76115 self . title = group. title
77116 self . abstract = nil
78117 self . discussion = nil
79- self . identifiers = group. references. map ( { $0. absoluteString } )
118+ self . identifierItems = group. references. map { IdentifierItem ( identifier : $0. absoluteString) }
80119 self . generated = false
81120 }
82121}
0 commit comments