aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/DokkaGenerator.kt
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-09-22 11:08:16 +0200
committerAndrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com>2020-10-02 12:40:50 +0200
commit8de5296b18083361055d11acf6d522c1eef821a4 (patch)
tree5e4f4c42bf801f33c40c4efeb5601e0fc4523e36 /core/src/main/kotlin/DokkaGenerator.kt
parent71b03f6d311c6ebfdf67c593e97a7483a64844f4 (diff)
downloaddokka-8de5296b18083361055d11acf6d522c1eef821a4.tar.gz
dokka-8de5296b18083361055d11acf6d522c1eef821a4.tar.bz2
dokka-8de5296b18083361055d11acf6d522c1eef821a4.zip
Make translators run in parallel.
Diffstat (limited to 'core/src/main/kotlin/DokkaGenerator.kt')
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt13
1 files changed, 8 insertions, 5 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
index 6f42b259..bee85325 100644
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ b/core/src/main/kotlin/DokkaGenerator.kt
@@ -9,6 +9,8 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.DokkaPlugin
import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.dokka.utilities.report
+import kotlinx.coroutines.*
+import org.jetbrains.dokka.utilities.parallelMap
/**
@@ -73,9 +75,10 @@ class DokkaGenerator(
fun createDocumentationModels(
context: DokkaContext
- ) = context.configuration.sourceSets
- .flatMap { sourceSet -> translateSources(sourceSet, context) }
- .also { modules -> if (modules.isEmpty()) exitGenerationGracefully("Nothing to document") }
+ ) = runBlocking(Dispatchers.Default) {
+ context.configuration.sourceSets.parallelMap { sourceSet -> translateSources(sourceSet, context) }.flatten()
+ .also { modules -> if (modules.isEmpty()) exitGenerationGracefully("Nothing to document") }
+ }
fun transformDocumentationModelBeforeMerge(
modulesFromPlatforms: List<DModule>,
@@ -133,8 +136,8 @@ class DokkaGenerator(
}
}
- private fun translateSources(sourceSet: DokkaSourceSet, context: DokkaContext) =
- context[CoreExtensions.sourceToDocumentableTranslator].map {
+ private suspend fun translateSources(sourceSet: DokkaSourceSet, context: DokkaContext) =
+ context[CoreExtensions.sourceToDocumentableTranslator].parallelMap {
it.invoke(sourceSet, context)
}
}