diff options
Diffstat (limited to 'core/src')
3 files changed, 22 insertions, 3 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index b6216bdb..b3d58439 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -10,6 +10,7 @@ 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.transformers.sources.AsyncSourceToDocumentableTranslator import org.jetbrains.dokka.utilities.parallelMap @@ -149,8 +150,11 @@ class DokkaGenerator( } private suspend fun translateSources(sourceSet: DokkaSourceSet, context: DokkaContext) = - context[CoreExtensions.sourceToDocumentableTranslator].parallelMap { - it.invoke(sourceSet, context) + context[CoreExtensions.sourceToDocumentableTranslator].parallelMap { translator -> + when(translator){ + is AsyncSourceToDocumentableTranslator -> translator.invokeSuspending(sourceSet, context) + else -> translator.invoke(sourceSet, context) + } } } diff --git a/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt new file mode 100644 index 00000000..19113446 --- /dev/null +++ b/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt @@ -0,0 +1,15 @@ +package org.jetbrains.dokka.transformers.sources + +import kotlinx.coroutines.runBlocking +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.model.DModule +import org.jetbrains.dokka.plugability.DokkaContext + +interface AsyncSourceToDocumentableTranslator : SourceToDocumentableTranslator { + suspend fun invokeSuspending(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule + + override fun invoke(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule = + runBlocking { + invokeSuspending(sourceSet, context) + } +}
\ No newline at end of file diff --git a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt index 8ac59a15..2252dde3 100644 --- a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt @@ -5,5 +5,5 @@ import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext interface SourceToDocumentableTranslator { - suspend fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule + fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule } |