@@ -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
168177public 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
0 commit comments