diff options
Diffstat (limited to 'plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt')
-rw-r--r-- | plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt new file mode 100644 index 00000000..345dc9be --- /dev/null +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt @@ -0,0 +1,39 @@ +package org.jetbrains.dokka.kotlinAsJava + + +import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.pages.ModulePageNode +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.plugability.single +import org.jetbrains.dokka.transformers.documentation.DocumentationToPageTranslator +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor + +class KotlinAsJavaPlugin : DokkaPlugin() { + val kotlinAsJavaDescriptorToDocumentableTranslator by extending { CoreExtensions.descriptorToDocumentationTranslator with KotlinAsJavaDescriptorToDocumentationTranslator } + val kotlinAsJavaDocumentableToPageTranslator by extending { CoreExtensions.documentationToPageTranslator with KotlinAsJavaDocumentationToPageTranslator } +} + +object DescriptorCache { + private val cache: HashMap<DRI, DeclarationDescriptor> = HashMap() + + fun add(dri: DRI, descriptor: DeclarationDescriptor): Boolean = cache.putIfAbsent(dri, descriptor) == null + operator fun get(dri: DRI): DeclarationDescriptor? = cache[dri] +} + +object KotlinAsJavaDocumentationToPageTranslator : DocumentationToPageTranslator { + override fun invoke(module: Module, context: DokkaContext): ModulePageNode = + KotlinAsJavaPageBuilder { node, kind, operation -> + KotlinAsJavaPageContentBuilder.group( + setOf(node.dri), + node.platformData, + kind, + context.single(CoreExtensions.commentsToContentConverter), + context.logger, + operation + ) + }.pageForModule(module) + +}
\ No newline at end of file |