Skip to content

Commit

Permalink
minor re-org on documentation (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
heckj authored Apr 7, 2024
1 parent 2465070 commit bb38954
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ Automerge Utilities extends Automerge's `Document` type to make it easier to par

## Topics

### Walking and Parsing Automerge documents
### Inspecting Automerge documents

- ``Automerge/Document/isEmpty()``
- ``Automerge/Document/parseToSchema(_:from:)``
- ``Automerge/Document/schema()``
- ``AutomergeUtilities/AutomergeValue``

### Parsing the contents of an Automerge document

- ``Automerge/Document/parseToSchema(_:from:)``

### Comparing the contents of Automerge documents

- ``Automerge/Document/equivalentContents(_:)``

### Debugging Methods

- ``Automerge/Document/walk()``
14 changes: 14 additions & 0 deletions Sources/AutomergeUtilities/Document+equivalentContents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Automerge

public extension Document {
/// Returns a Boolean value that indicates whether the latest contents another document are equivalent.
func equivalentContents(_ anotherDoc: Document) -> Bool {
do {
let doc1Contents = try self.parseToSchema(self, from: .ROOT)
let doc2Contents = try anotherDoc.parseToSchema(anotherDoc, from: .ROOT)
return doc1Contents == doc2Contents
} catch {
return false
}
}
}

0 comments on commit bb38954

Please sign in to comment.