aboutsummaryrefslogtreecommitdiff
path: root/dokka-runners/dokkatoo/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'dokka-runners/dokkatoo/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt')
-rw-r--r--dokka-runners/dokkatoo/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt21
1 files changed, 21 insertions, 0 deletions
diff --git a/dokka-runners/dokkatoo/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt b/dokka-runners/dokkatoo/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt
new file mode 100644
index 00000000..eb8777e7
--- /dev/null
+++ b/dokka-runners/dokkatoo/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt
@@ -0,0 +1,21 @@
+package org.jetbrains.dokka.dokkatoo.utils
+
+
+fun String.splitToPair(delimiter: String): Pair<String, String> =
+ substringBefore(delimiter) to substringAfter(delimiter)
+
+
+/** Title case the first char of a string */
+fun String.uppercaseFirstChar(): String = mapFirstChar(Character::toTitleCase)
+
+
+private inline fun String.mapFirstChar(
+ transform: (Char) -> Char
+): String = if (isNotEmpty()) transform(this[0]) + substring(1) else this
+
+
+/** Split a string into lines, sort the lines, and re-join them (using [separator]). */
+fun String.sortLines(separator: String = "\n") =
+ lines()
+ .sorted()
+ .joinToString(separator)