Skip to content

Commit 77ce3f4

Browse files
committed
Last cleanup before a big refactor to support faster typing propagation between views
1 parent d453a48 commit 77ce3f4

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

CommonplaceBookApp/NoteArchive.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ public struct NoteArchive {
5656
}
5757

5858
public enum RetrievalError: Error {
59+
/// A page with the given page identifier does not exist.
5960
case noSuchPage(String)
61+
/// A text snippet with the given sha1Digest does not exist.
6062
case noSuchText(String)
63+
/// There is no specific text for a challenge template in the archive.
6164
case noSuchTemplateKey(String)
65+
/// The challenge template uses an unkown template class.
6266
case noSuchTemplateClass(String)
6367
}
6468

@@ -117,6 +121,10 @@ public struct NoteArchive {
117121
return noteSnippet.text
118122
}
119123

124+
/// Gets a `ChallengeTemplate` given its key.
125+
/// - parameter key: A reference to a specific challenge template in the archive.
126+
/// - throws: `RetrievalError.noSuchTemplateKey` if the specific challenge text does not exist in the archive.
127+
/// - throws: `RetrievalError.noSuchTemplateClass` if this key uses an unknown challenge template.
120128
public func challengeTemplate(for key: ChallengeTemplateArchiveKey) throws -> ChallengeTemplate {
121129
guard let snippet = archive.snippets[key.digest] else {
122130
throw RetrievalError.noSuchTemplateKey(key.digest)
@@ -165,7 +173,9 @@ public struct NoteArchive {
165173

166174
}
167175

176+
// MARK: - Import
168177
public extension NoteArchive {
178+
/// Adds the contents of a file to the archive as a new note.
169179
mutating func importFile(
170180
named fileName: String,
171181
text: String,
@@ -225,8 +235,11 @@ private extension NoteArchive {
225235
}
226236
}
227237

238+
/// Represents a specific file that has been imported into the archive.
228239
struct FileImportRecord: Codable {
240+
/// The UUID representing the page that holds the file contents.
229241
let pageIdentifier: String
242+
/// The changeDate of the file at the time it was imported.
230243
let changeDate: Date
231244
}
232245

CommonplaceBookApp/TextSnippetArchive+ChallengeTemplate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import Foundation
44

5+
/// Supports serializing a challenge template into a TextSnippetArchive.
56
public struct ChallengeTemplateArchiveKey: LosslessStringConvertible {
67
/// Digest of the challenge template serialized data in the TextSnippetArchive
78
public let digest: String

0 commit comments

Comments
 (0)