Skip to content

Commit 7a21157

Browse files
committed
chore: improve the documentation
1 parent fce6648 commit 7a21157

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/commonMain/kotlin/io/github/petertrr/diffutils/DiffUtils.kt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ package io.github.petertrr.diffutils
2222

2323
import io.github.petertrr.diffutils.algorithm.DiffAlgorithm
2424
import io.github.petertrr.diffutils.algorithm.DiffAlgorithmListener
25-
import io.github.petertrr.diffutils.algorithm.DiffEqualizer
2625
import io.github.petertrr.diffutils.algorithm.NoopAlgorithmListener
2726
import io.github.petertrr.diffutils.algorithm.myers.MyersDiff
2827
import io.github.petertrr.diffutils.patch.Patch
29-
import io.github.petertrr.diffutils.patch.PatchFailedException
3028
import io.github.petertrr.diffutils.text.DiffRowGenerator
3129
import kotlin.jvm.JvmName
3230
import kotlin.jvm.JvmOverloads
@@ -35,16 +33,16 @@ import kotlin.jvm.JvmOverloads
3533
private 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
5048
public 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
7876
public 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
*/
98100
public 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
*/
132133
public 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
*/
142143
public fun <T> unpatch(revised: List<T>, patch: Patch<T>): List<T> =
143144
patch.restore(revised)

src/commonMain/kotlin/io/github/petertrr/diffutils/text/DiffRowGenerator.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ import kotlin.math.min
5858
* Default: `false`
5959
* @param newTag Generator for New-Text-Tags
6060
* @param oldTag Generator for Old-Text-Tags
61-
* @param reportLinesUnchanged Give the original old and new text lines to [DiffRow]
62-
* without any additional processing and without any tags to highlight the change.
61+
* @param reportLinesUnchanged Report all lines without markup on the old or new text.
6362
* Default: `false`
6463
* @param lineNormalizer By default, [DiffRowGenerator] preprocesses lines for HTML output.
6564
* Tabs and special HTML characters like "&lt;" are replaced with its encoded value.

0 commit comments

Comments
 (0)