From 8de5296b18083361055d11acf6d522c1eef821a4 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Tue, 22 Sep 2020 11:08:16 +0200 Subject: Make translators run in parallel. --- core/src/main/kotlin/DokkaGenerator.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'core/src/main/kotlin/DokkaGenerator.kt') 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, @@ -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) } } -- cgit