@@ -22,11 +22,9 @@ package io.github.petertrr.diffutils
2222
2323import io.github.petertrr.diffutils.algorithm.DiffAlgorithm
2424import io.github.petertrr.diffutils.algorithm.DiffAlgorithmListener
25- import io.github.petertrr.diffutils.algorithm.DiffEqualizer
2625import io.github.petertrr.diffutils.algorithm.NoopAlgorithmListener
2726import io.github.petertrr.diffutils.algorithm.myers.MyersDiff
2827import io.github.petertrr.diffutils.patch.Patch
29- import io.github.petertrr.diffutils.patch.PatchFailedException
3028import io.github.petertrr.diffutils.text.DiffRowGenerator
3129import kotlin.jvm.JvmName
3230import kotlin.jvm.JvmOverloads
@@ -35,16 +33,16 @@ import kotlin.jvm.JvmOverloads
3533private val lineBreak = Regex (" \r\n |\r |\n " )
3634
3735/* *
38- * Computes the difference between the source and target text .
36+ * Computes the difference between two strings .
3937 *
4038 * By default, uses the Myers algorithm.
4139 *
42- * @param sourceText The original text
43- * @param targetText The target text
40+ * @param sourceText A string representing the original text
41+ * @param targetText A string representing the revised text
4442 * @param algorithm The diff algorithm to use
4543 * @param progress The diff algorithm progress listener
4644 * @param includeEqualParts Whether to include equal data parts into the patch. `false` by default.
47- * @return The patch describing the difference between the original and target text
45+ * @return The patch describing the difference between the original and revised strings
4846 */
4947@JvmOverloads
5048public fun diff (
@@ -65,14 +63,14 @@ public fun diff(
6563/* *
6664 * Computes the difference between the original and target list of elements.
6765 *
68- * By default, uses the Meyers algorithm.
66+ * By default, uses the Myers algorithm.
6967 *
70- * @param source The original elements
71- * @param target The target elements
68+ * @param source A list representing the original sequence of elements
69+ * @param target A list representing the revised sequence of elements
7270 * @param algorithm The diff algorithm to use
7371 * @param progress The diff algorithm progress listener
74- * @param includeEqualParts Whether to include equal data parts into the patch. `false` by default.
75- * @return The patch describing the difference between the original and target sequences
72+ * @param includeEqualParts Whether to include equal parts in the resulting patch. `false` by default.
73+ * @return The patch describing the difference between the original and revised sequences
7674 */
7775@JvmOverloads
7876public fun <T > diff (
@@ -94,6 +92,10 @@ public fun <T> diff(
9492 *
9593 * This one uses the "trick" to make out of texts lists of characters,
9694 * like [DiffRowGenerator] does and merges those changes at the end together again.
95+ *
96+ * @param original A string representing the original text
97+ * @param revised A string representing the revised text
98+ * @return The patch describing the difference between the original and revised text
9799 */
98100public fun diffInline (original : String , revised : String ): Patch <String > {
99101 val origChars = original.toCharArray()
@@ -122,22 +124,21 @@ public fun diffInline(original: String, revised: String): Patch<String> {
122124}
123125
124126/* *
125- * Patch the original text with the given patch .
127+ * Applies the given patch to the original list and returns the revised list .
126128 *
127- * @param original The original text
129+ * @param original A list representing the original sequence of elements
128130 * @param patch The patch to apply
129- * @return The revised text
130- * @throws PatchFailedException If the patch cannot be applied
131+ * @return A list representing the revised sequence of elements
131132 */
132133public fun <T > patch (original : List <T >, patch : Patch <T >): List <T > =
133134 patch.applyTo(original)
134135
135136/* *
136- * Unpatch the revised text for a given patch
137+ * Applies the given patch to the revised list and returns the original list.
137138 *
138- * @param revised The revised text
139- * @param patch The given patch
140- * @return The original text
139+ * @param revised A list representing the revised sequence of elements
140+ * @param patch The patch to apply
141+ * @return A list representing the original sequence of elements
141142 */
142143public fun <T > unpatch (revised : List <T >, patch : Patch <T >): List <T > =
143144 patch.restore(revised)
0 commit comments