From 7acc52ba723eab08fe796fcfd68755e7f0eb6a66 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Sat, 2 Dec 2017 00:50:08 +0300 Subject: WIP: Refactoring, remove LocationService, rework FormatDescriptor --- core/src/main/kotlin/Utilities/DokkaModules.kt | 46 ++++++++++++-------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'core/src/main/kotlin/Utilities') diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt index dfb114ec..9db08010 100644 --- a/core/src/main/kotlin/Utilities/DokkaModules.kt +++ b/core/src/main/kotlin/Utilities/DokkaModules.kt @@ -4,6 +4,7 @@ import com.google.inject.Binder import com.google.inject.Module import com.google.inject.Provider import com.google.inject.TypeLiteral +import com.google.inject.binder.AnnotatedBindingBuilder import com.google.inject.name.Names import org.jetbrains.dokka.* import org.jetbrains.dokka.Formats.FormatDescriptor @@ -11,6 +12,7 @@ import org.jetbrains.dokka.Model.DescriptorSignatureProvider import org.jetbrains.dokka.Samples.SampleProcessingService import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import java.io.File +import kotlin.reflect.KClass const val impliedPlatformsName = "impliedPlatforms" @@ -22,12 +24,7 @@ class DokkaAnalysisModule(val environment: AnalysisEnvironment, override fun configure(binder: Binder) { binder.bind().toInstance(logger) - val descriptor = ServiceLocator.lookup("format", options.outputFormat) - binder.bind().to(descriptor.descriptorSignatureProvider.java) binder.registerCategory("language") - binder.bind().to(descriptor.packageDocumentationBuilderClass.java) - binder.bind().to(descriptor.javaDocumentationBuilderClass.java) - binder.bind().to(descriptor.sampleProcessingService.java) val coreEnvironment = environment.createCoreEnvironment() binder.bind().toInstance(coreEnvironment) @@ -40,6 +37,9 @@ class DokkaAnalysisModule(val environment: AnalysisEnvironment, binder.bind().toInstance(defaultPlatformsProvider) binder.bind().toInstance(nodeReferenceGraph) + + val descriptor = ServiceLocator.lookup("format", options.outputFormat) + descriptor.configureAnalysis(binder) } } @@ -56,35 +56,26 @@ class DokkaOutputModule(val options: DocumentationOptions, binder.bind(File::class.java).annotatedWith(Names.named("outputDir")).toInstance(File(options.outputDir)) - binder.bindNameAnnotated("singleFolder") - binder.bindNameAnnotated("singleFolder") - binder.bindNameAnnotated("folders") - binder.bindNameAnnotated("folders") +// binder.bindNameAnnotated("singleFolder") +// binder.bindNameAnnotated("singleFolder") +// binder.bindNameAnnotated("folders") +// binder.bindNameAnnotated("folders") // defaults - binder.bind(LocationService::class.java).to(FoldersLocationService::class.java) - binder.bind(FileLocationService::class.java).to(FoldersLocationService::class.java) +// binder.bind(LocationService::class.java).to(FoldersLocationService::class.java) +// binder.bind(FileLocationService::class.java).to(FoldersLocationService::class.java) binder.registerCategory("outline") binder.registerCategory("format") binder.registerCategory("generator") - val descriptor = ServiceLocator.lookup("format", options.outputFormat) - - descriptor.outlineServiceClass?.let { clazz -> - binder.bind(OutlineFormatService::class.java).to(clazz.java) - } - descriptor.formatServiceClass?.let { clazz -> - binder.bind(FormatService::class.java).to(clazz.java) - } - - binder.bind().to(descriptor.generatorServiceClass.java) - - descriptor.packageListServiceClass?.let { binder.bind().to(it.java) } - binder.bind().toInstance(options) binder.bind().toInstance(logger) binder.bind(StringListType).annotatedWith(Names.named(impliedPlatformsName)).toInstance(options.impliedPlatforms) + + val descriptor = ServiceLocator.lookup("format", options.outputFormat) + + descriptor.configureOutput(binder) } } @@ -100,4 +91,9 @@ private inline fun Binder.bindNameAnnotat } -inline fun Binder.bind() = bind(T::class.java) +inline fun Binder.bind(): AnnotatedBindingBuilder = bind(T::class.java) + +inline infix fun > AnnotatedBindingBuilder.toOptional(kClass: TKClass?) = + kClass?.let { to(it.java) } + +inline infix fun > AnnotatedBindingBuilder.toType(kClass: TKClass) = to(kClass.java) -- cgit