From 14ba5834fa3fff98672166dd24c05bd7aa13dc2a Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 5 Dec 2017 15:42:20 +0300 Subject: Fix overriding of default analysis services --- core/src/main/kotlin/Formats/AnalysisComponents.kt | 10 +++++----- core/src/main/kotlin/Formats/JavaLayoutHtmlFormat.kt | 2 +- core/src/main/kotlin/Formats/StandardFormats.kt | 18 ++++++++++++------ core/src/main/kotlin/javadoc/dokka-adapters.kt | 9 +++++---- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/core/src/main/kotlin/Formats/AnalysisComponents.kt b/core/src/main/kotlin/Formats/AnalysisComponents.kt index 97e1311e..c4d97dbb 100644 --- a/core/src/main/kotlin/Formats/AnalysisComponents.kt +++ b/core/src/main/kotlin/Formats/AnalysisComponents.kt @@ -12,14 +12,14 @@ import org.jetbrains.dokka.Utilities.toType import kotlin.reflect.KClass -interface FormatDescriptorAnalysisComponentProvider : FormatDescriptorAnalysisComponent { - +interface DefaultAnalysisComponentServices { val packageDocumentationBuilderClass: KClass val javaDocumentationBuilderClass: KClass val sampleProcessingService: KClass val descriptorSignatureProvider: KClass +} - +interface DefaultAnalysisComponent : FormatDescriptorAnalysisComponent, DefaultAnalysisComponentServices { override fun configureAnalysis(binder: Binder): Unit = with(binder) { bind() toType descriptorSignatureProvider bind() toType packageDocumentationBuilderClass @@ -29,7 +29,7 @@ interface FormatDescriptorAnalysisComponentProvider : FormatDescriptorAnalysisCo } -object KotlinAsJava: FormatDescriptorAnalysisComponentProvider { +object KotlinAsJava : DefaultAnalysisComponentServices { override val packageDocumentationBuilderClass = KotlinAsJavaDocumentationBuilder::class override val javaDocumentationBuilderClass = JavaPsiDocumentationBuilder::class override val sampleProcessingService = DefaultSampleProcessingService::class @@ -37,7 +37,7 @@ object KotlinAsJava: FormatDescriptorAnalysisComponentProvider { } -object KotlinAsKotlin: FormatDescriptorAnalysisComponentProvider { +object KotlinAsKotlin : DefaultAnalysisComponentServices { override val packageDocumentationBuilderClass = KotlinPackageDocumentationBuilder::class override val javaDocumentationBuilderClass = KotlinJavaDocumentationBuilder::class override val sampleProcessingService = DefaultSampleProcessingService::class diff --git a/core/src/main/kotlin/Formats/JavaLayoutHtmlFormat.kt b/core/src/main/kotlin/Formats/JavaLayoutHtmlFormat.kt index 9fb72e37..f73cd23e 100644 --- a/core/src/main/kotlin/Formats/JavaLayoutHtmlFormat.kt +++ b/core/src/main/kotlin/Formats/JavaLayoutHtmlFormat.kt @@ -13,7 +13,7 @@ import org.jetbrains.dokka.Utilities.toType import java.io.File -class JavaLayoutHtmlFormatDescriptor : FormatDescriptor, FormatDescriptorAnalysisComponentProvider { +class JavaLayoutHtmlFormatDescriptor : FormatDescriptor, DefaultAnalysisComponent { override val packageDocumentationBuilderClass = KotlinPackageDocumentationBuilder::class override val javaDocumentationBuilderClass = KotlinJavaDocumentationBuilder::class override val sampleProcessingService = DefaultSampleProcessingService::class diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt index 9de667ab..71af1991 100644 --- a/core/src/main/kotlin/Formats/StandardFormats.kt +++ b/core/src/main/kotlin/Formats/StandardFormats.kt @@ -1,19 +1,21 @@ package org.jetbrains.dokka.Formats import com.google.inject.Binder -import com.google.inject.Provider import org.jetbrains.dokka.* import org.jetbrains.dokka.Samples.KotlinWebsiteSampleProcessingService import org.jetbrains.dokka.Utilities.bind import kotlin.reflect.KClass -abstract class KotlinFormatDescriptorBase : FileGeneratorBasedFormatDescriptor(), FormatDescriptorAnalysisComponentProvider by KotlinAsKotlin { +abstract class KotlinFormatDescriptorBase + : FileGeneratorBasedFormatDescriptor(), + DefaultAnalysisComponent, + DefaultAnalysisComponentServices by KotlinAsKotlin { override val generatorServiceClass = FileGenerator::class override val outlineServiceClass: KClass? = null override val packageListServiceClass: KClass? = DefaultPackageListService::class } -abstract class HtmlFormatDescriptorBase : FileGeneratorBasedFormatDescriptor() { +abstract class HtmlFormatDescriptorBase : FileGeneratorBasedFormatDescriptor(), DefaultAnalysisComponent { override val formatServiceClass = HtmlFormatService::class override val outlineServiceClass = HtmlFormatService::class override val generatorServiceClass = FileGenerator::class @@ -21,13 +23,13 @@ abstract class HtmlFormatDescriptorBase : FileGeneratorBasedFormatDescriptor() { override fun configureOutput(binder: Binder): Unit = with(binder) { super.configureOutput(binder) - bind().toProvider(Provider { HtmlTemplateService.default("style.css") }) + bind().toProvider { HtmlTemplateService.default("style.css") } } } -class HtmlFormatDescriptor : HtmlFormatDescriptorBase(), FormatDescriptorAnalysisComponent by KotlinAsKotlin +class HtmlFormatDescriptor : HtmlFormatDescriptorBase(), DefaultAnalysisComponentServices by KotlinAsKotlin -class HtmlAsJavaFormatDescriptor : HtmlFormatDescriptorBase(), FormatDescriptorAnalysisComponent by KotlinAsJava +class HtmlAsJavaFormatDescriptor : HtmlFormatDescriptorBase(), DefaultAnalysisComponentServices by KotlinAsJava class KotlinWebsiteFormatDescriptor : KotlinFormatDescriptorBase() { override val formatServiceClass = KotlinWebsiteFormatService::class @@ -45,6 +47,10 @@ class KotlinWebsiteHtmlFormatDescriptor : KotlinFormatDescriptorBase() { override val sampleProcessingService = KotlinWebsiteSampleProcessingService::class override val outlineServiceClass = YamlOutlineService::class + override fun configureAnalysis(binder: Binder) { + super.configureAnalysis(binder) + } + override fun configureOutput(binder: Binder) = with(binder) { super.configureOutput(binder) bind().toInstance(EmptyHtmlTemplateService) diff --git a/core/src/main/kotlin/javadoc/dokka-adapters.kt b/core/src/main/kotlin/javadoc/dokka-adapters.kt index bed211f6..4676db18 100644 --- a/core/src/main/kotlin/javadoc/dokka-adapters.kt +++ b/core/src/main/kotlin/javadoc/dokka-adapters.kt @@ -4,9 +4,7 @@ import com.google.inject.Binder import com.google.inject.Inject import com.sun.tools.doclets.formats.html.HtmlDoclet import org.jetbrains.dokka.* -import org.jetbrains.dokka.Formats.FormatDescriptor -import org.jetbrains.dokka.Formats.FormatDescriptorAnalysisComponent -import org.jetbrains.dokka.Formats.KotlinAsJava +import org.jetbrains.dokka.Formats.* import org.jetbrains.dokka.Utilities.bind import org.jetbrains.dokka.Utilities.toType @@ -31,7 +29,10 @@ class JavadocGenerator @Inject constructor(val options: DocumentationOptions, va } } -class JavadocFormatDescriptor : FormatDescriptor, FormatDescriptorAnalysisComponent by KotlinAsJava { +class JavadocFormatDescriptor : + FormatDescriptor, + DefaultAnalysisComponent, + DefaultAnalysisComponentServices by KotlinAsJava { override fun configureOutput(binder: Binder): Unit = with(binder) { bind() toType JavadocGenerator::class -- cgit