diff options
author | Kamil Doległo <9080183+kamildoleglo@users.noreply.github.com> | 2020-11-25 13:17:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 13:17:51 +0100 |
commit | 3fe3a934092cd844a6e0b691c87c367b9fc4d5b3 (patch) | |
tree | 0ba15c94e832657be1c5a12ed5c00287a6a0bc5f /core/src/main | |
parent | 78850b5786b7b2a767db1dbd7132a374b2f4f227 (diff) | |
download | dokka-3fe3a934092cd844a6e0b691c87c367b9fc4d5b3.tar.gz dokka-3fe3a934092cd844a6e0b691c87c367b9fc4d5b3.tar.bz2 dokka-3fe3a934092cd844a6e0b691c87c367b9fc4d5b3.zip |
Remove suspend from SourceToDocumentableTranslator (#1622)
* Remove suspend from SourceToDocumentableTranslator
* Introduce AsyncSourceToDocumentableTranslator
Co-authored-by: Marcin Aman <marcin.aman@gmail.com>
Diffstat (limited to 'core/src/main')
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 } |