aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/utilities
diff options
context:
space:
mode:
authorVsevolod Tolstopyatov <qwwdfsad@gmail.com>2023-03-27 03:01:34 -0700
committerGitHub <noreply@github.com>2023-03-27 13:01:34 +0300
commit9af0b307a14253a21d11d340a78dd9061abee359 (patch)
treecbd2af142d1833b32f657a2eb6b8ed7b6ba0e510 /core/src/main/kotlin/utilities
parentb9e9962f75bfd6b19c16eccf7d4d6608b8f5db1e (diff)
downloaddokka-9af0b307a14253a21d11d340a78dd9061abee359.tar.gz
dokka-9af0b307a14253a21d11d340a78dd9061abee359.tar.bz2
dokka-9af0b307a14253a21d11d340a78dd9061abee359.zip
Mark utilities.* API as Dokka-internal (#2937)
* Deprecate unused declaration, remove inline declaration (as it's binary compatible), opt-in into internal API at project level * Opt-in into DokkaInternalApi where applicable * Get rid of intermediate test-utils module
Diffstat (limited to 'core/src/main/kotlin/utilities')
-rw-r--r--core/src/main/kotlin/utilities/DokkaLogging.kt2
-rw-r--r--core/src/main/kotlin/utilities/Html.kt4
-rw-r--r--core/src/main/kotlin/utilities/ServiceLocator.kt7
-rw-r--r--core/src/main/kotlin/utilities/Uri.kt6
-rw-r--r--core/src/main/kotlin/utilities/associateWithNotNull.kt3
-rw-r--r--core/src/main/kotlin/utilities/cast.kt3
-rw-r--r--core/src/main/kotlin/utilities/parallelCollectionOperations.kt4
7 files changed, 23 insertions, 6 deletions
diff --git a/core/src/main/kotlin/utilities/DokkaLogging.kt b/core/src/main/kotlin/utilities/DokkaLogging.kt
index 39529324..5cca6d53 100644
--- a/core/src/main/kotlin/utilities/DokkaLogging.kt
+++ b/core/src/main/kotlin/utilities/DokkaLogging.kt
@@ -39,7 +39,7 @@ fun interface MessageEmitter : (String) -> Unit {
}
class DokkaConsoleLogger(
- val minLevel: LoggingLevel = LoggingLevel.PROGRESS,
+ private val minLevel: LoggingLevel = LoggingLevel.PROGRESS,
private val emitter: MessageEmitter = MessageEmitter.consoleEmitter
) : DokkaLogger {
private val warningsCounter = AtomicInteger()
diff --git a/core/src/main/kotlin/utilities/Html.kt b/core/src/main/kotlin/utilities/Html.kt
index 874c9fb1..a1d8ecec 100644
--- a/core/src/main/kotlin/utilities/Html.kt
+++ b/core/src/main/kotlin/utilities/Html.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.utilities
+import org.jetbrains.dokka.*
import java.net.URLEncoder
@@ -7,9 +8,12 @@ import java.net.URLEncoder
* Replaces symbols reserved in HTML with their respective entities.
* Replaces & with &amp;, < with &lt; and > with &gt;
*/
+@InternalDokkaApi
fun String.htmlEscape(): String = replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot;")
+@InternalDokkaApi
fun String.urlEncoded(): String = URLEncoder.encode(this, "UTF-8")
+@InternalDokkaApi
fun String.formatToEndWithHtml() =
if (endsWith(".html") || contains(Regex("\\.html#"))) this else "$this.html"
diff --git a/core/src/main/kotlin/utilities/ServiceLocator.kt b/core/src/main/kotlin/utilities/ServiceLocator.kt
index 3e515348..f86960ec 100644
--- a/core/src/main/kotlin/utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/utilities/ServiceLocator.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.utilities
+import org.jetbrains.dokka.*
import java.io.File
import java.net.URISyntaxException
import java.net.URL
@@ -7,10 +8,13 @@ import java.util.*
import java.util.jar.JarFile
import java.util.zip.ZipEntry
+@InternalDokkaApi
data class ServiceDescriptor(val name: String, val category: String, val description: String?, val className: String)
+@InternalDokkaApi
class ServiceLookupException(message: String) : Exception(message)
+@InternalDokkaApi
object ServiceLocator {
fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T {
val descriptor = lookupDescriptor(category, implementationName)
@@ -81,9 +85,6 @@ object ServiceLocator {
}
}
-inline fun <reified T : Any> ServiceLocator.lookup(category: String, implementationName: String): T = lookup(T::class.java, category, implementationName)
-inline fun <reified T : Any> ServiceLocator.lookup(desc: ServiceDescriptor): T = lookup(T::class.java, desc)
-
private val ZipEntry.fileName: String
get() = name.substringAfterLast("/", name)
diff --git a/core/src/main/kotlin/utilities/Uri.kt b/core/src/main/kotlin/utilities/Uri.kt
index 089b3cff..67c81d98 100644
--- a/core/src/main/kotlin/utilities/Uri.kt
+++ b/core/src/main/kotlin/utilities/Uri.kt
@@ -1,8 +1,10 @@
package org.jetbrains.dokka.utilities
+import org.jetbrains.dokka.*
import java.net.URI
-
+@InternalDokkaApi
+@Deprecated("Deprecated for removal") // Unused in Dokka
fun URI.relativeTo(uri: URI): URI {
// Normalize paths to remove . and .. segments
val base = uri.normalize()
@@ -37,4 +39,4 @@ fun URI.relativeTo(uri: URI): URI {
append(it)
}
})
-} \ No newline at end of file
+}
diff --git a/core/src/main/kotlin/utilities/associateWithNotNull.kt b/core/src/main/kotlin/utilities/associateWithNotNull.kt
index ea2e8c3c..6c0bf4d8 100644
--- a/core/src/main/kotlin/utilities/associateWithNotNull.kt
+++ b/core/src/main/kotlin/utilities/associateWithNotNull.kt
@@ -1,5 +1,8 @@
package org.jetbrains.dokka.utilities
+import org.jetbrains.dokka.*
+
+@InternalDokkaApi
inline fun <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> {
@Suppress("UNCHECKED_CAST")
return associateWith { valueSelector(it) }.filterValues { it != null } as Map<K, V>
diff --git a/core/src/main/kotlin/utilities/cast.kt b/core/src/main/kotlin/utilities/cast.kt
index d4a8d73d..784b7e2a 100644
--- a/core/src/main/kotlin/utilities/cast.kt
+++ b/core/src/main/kotlin/utilities/cast.kt
@@ -1,5 +1,8 @@
package org.jetbrains.dokka.utilities
+import org.jetbrains.dokka.*
+
+@InternalDokkaApi
inline fun <reified T> Any.cast(): T {
return this as T
}
diff --git a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt
index 35ad48fd..d24aa7a6 100644
--- a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt
+++ b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt
@@ -1,15 +1,19 @@
package org.jetbrains.dokka.utilities
import kotlinx.coroutines.*
+import org.jetbrains.dokka.*
+@InternalDokkaApi
suspend inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> = coroutineScope {
map { async { f(it) } }.awaitAll()
}
+@InternalDokkaApi
suspend inline fun <A, B> Iterable<A>.parallelMapNotNull(crossinline f: suspend (A) -> B?): List<B> = coroutineScope {
map { async { f(it) } }.awaitAll().filterNotNull()
}
+@InternalDokkaApi
suspend inline fun <A> Iterable<A>.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope {
forEach { launch { f(it) } }
}