@@ -19,28 +19,59 @@ public struct TaskGroupRenderSection: RenderSection {
19
19
/// An optional discussion for the section.
20
20
public let discussion : RenderSection ?
21
21
/// 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 ]
23
26
/// If true, this is an automatically generated group. If false, this is an authored group.
24
27
public let generated : Bool
25
28
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
+
26
41
/// Creates a new task group.
27
42
/// - Parameters:
28
43
/// - title: An optional title for the section.
29
44
/// - abstract: An optional abstract summary for the section.
30
45
/// - discussion: An optional discussion for the section.
31
46
/// - identifiers: A list of topic-graph references.
32
47
/// - 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. " )
33
49
public init ( title: String ? , abstract: [ RenderInlineContent ] ? , discussion: RenderSection ? , identifiers: [ String ] , generated: Bool = false ) {
34
50
self . title = title
35
51
self . abstract = abstract
36
52
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
38
69
self . generated = generated
39
70
}
40
71
41
72
/// The list of keys you use to encode or decode this section.
42
73
private enum CodingKeys : CodingKey {
43
- case title, abstract, discussion, identifiers, generated
74
+ case title, abstract, discussion, identifiers, identifierItems , generated
44
75
}
45
76
46
77
public func encode( to encoder: Encoder ) throws {
@@ -50,6 +81,7 @@ public struct TaskGroupRenderSection: RenderSection {
50
81
try container. encodeIfPresent ( abstract, forKey: . abstract)
51
82
try container. encodeIfPresent ( discussion. map ( CodableRenderSection . init) , forKey: . discussion)
52
83
try container. encode ( identifiers, forKey: . identifiers)
84
+ try container. encode ( identifierItems, forKey: . identifierItems)
53
85
if generated {
54
86
try container. encode ( generated, forKey: . generated)
55
87
}
@@ -61,11 +93,18 @@ public struct TaskGroupRenderSection: RenderSection {
61
93
title = try container. decodeIfPresent ( String . self, forKey: . title)
62
94
abstract = try container. decodeIfPresent ( [ RenderInlineContent ] . self, forKey: . abstract)
63
95
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
+ }
68
106
generated = try container. decodeIfPresent ( Bool . self, forKey: . generated) ?? false
107
+ decoder. registerReferences ( self . identifiers)
69
108
}
70
109
}
71
110
@@ -76,7 +115,7 @@ extension TaskGroupRenderSection {
76
115
self . title = group. title
77
116
self . abstract = nil
78
117
self . discussion = nil
79
- self . identifiers = group. references. map ( { $0. absoluteString } )
118
+ self . identifierItems = group. references. map { IdentifierItem ( identifier : $0. absoluteString) }
80
119
self . generated = false
81
120
}
82
121
}
0 commit comments