diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2020-10-28 21:54:00 +0100 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-11-27 03:15:02 +0100 |
commit | ed56e7bcdceac7a13eae851e02f642c0762aaf40 (patch) | |
tree | 0f06aee6b251dfbecdc8ebf55a1af37e66b091ba /core/src | |
parent | d41965ca3cb180bc82bd5dd6fa747d2b83381b31 (diff) | |
download | dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.tar.gz dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.tar.bz2 dokka-ed56e7bcdceac7a13eae851e02f642c0762aaf40.zip |
Moving SingleGeneration to base pluing
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/CoreExtensions.kt | 22 | ||||
-rw-r--r-- | core/src/main/kotlin/generation/SingleModule.kt | 0 | ||||
-rw-r--r-- | core/src/main/kotlin/generation/SingleModuleGeneration.kt | 102 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DokkaContext.kt | 1 |
4 files changed, 0 insertions, 125 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index 0eea416a..66e717b4 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -1,51 +1,29 @@ package org.jetbrains.dokka import org.jetbrains.dokka.generation.Generation -import org.jetbrains.dokka.generation.SingleModuleGeneration import org.jetbrains.dokka.plugability.* -import org.jetbrains.dokka.plugability.LazyEvaluated import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.transformers.documentation.DocumentableMerger import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer -import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer -import org.jetbrains.dokka.transformers.pages.PageCreator import org.jetbrains.dokka.transformers.pages.PageTransformer import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator import org.jetbrains.dokka.validity.PreGenerationChecker import kotlin.reflect.KProperty object CoreExtensions { - private val extensionDelegates = mutableListOf<Lazy<Extension<*, *, *>>>() val preGenerationCheck by coreExtensionPoint<PreGenerationChecker>() val generation by coreExtensionPoint<Generation>() val sourceToDocumentableTranslator by coreExtensionPoint<SourceToDocumentableTranslator>() - val preMergeDocumentableTransformer by coreExtensionPoint<PreMergeDocumentableTransformer>() val documentableMerger by coreExtensionPoint<DocumentableMerger>() val documentableTransformer by coreExtensionPoint<DocumentableTransformer>() val documentableToPageTranslator by coreExtensionPoint<DocumentableToPageTranslator>() - val allModulePageCreator by coreExtensionPoint<PageCreator>() val pageTransformer by coreExtensionPoint<PageTransformer>() - val allModulePageTransformer by coreExtensionPoint<PageTransformer>() val renderer by coreExtensionPoint<Renderer>() - val singleGeneration by generation extendWith LazyEvaluated.fromRecipe(::SingleModuleGeneration) - private fun <T : Any> coreExtensionPoint() = object { operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<ExtensionPoint<T>> = lazy { ExtensionPoint<T>(thisRef::class.qualifiedName!!, property.name) } } - - private infix fun <T: Any> ExtensionPoint<T>.extendWith(action: LazyEvaluated<T>) = object { - operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<Extension<T, OrderingKind.None, OverrideKind.None>> = - lazy { Extension(this@extendWith, thisRef::class.qualifiedName!!, property.name, action) } - .also { extensionDelegates += it } - } - - internal fun installTo(context: DokkaContextConfiguration) { - extensionDelegates.forEach { - context.installExtension(it.value) - } - } }
\ No newline at end of file diff --git a/core/src/main/kotlin/generation/SingleModule.kt b/core/src/main/kotlin/generation/SingleModule.kt deleted file mode 100644 index e69de29b..00000000 --- a/core/src/main/kotlin/generation/SingleModule.kt +++ /dev/null diff --git a/core/src/main/kotlin/generation/SingleModuleGeneration.kt b/core/src/main/kotlin/generation/SingleModuleGeneration.kt deleted file mode 100644 index 2eedc561..00000000 --- a/core/src/main/kotlin/generation/SingleModuleGeneration.kt +++ /dev/null @@ -1,102 +0,0 @@ - -package org.jetbrains.dokka.generation - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.runBlocking -import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.DokkaException -import org.jetbrains.dokka.Timer -import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.pages.RootPageNode -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.transformers.sources.AsyncSourceToDocumentableTranslator -import org.jetbrains.dokka.utilities.parallelMap -import org.jetbrains.dokka.utilities.report - -class SingleModuleGeneration(private val context: DokkaContext) : Generation { - override fun Timer.generate() { - report("Validity check") - validityCheck(context) - - report("Creating documentation models") - val modulesFromPlatforms = createDocumentationModels() - - report("Transforming documentation model before merging") - val transformedDocumentationBeforeMerge = transformDocumentationModelBeforeMerge(modulesFromPlatforms) - - report("Merging documentation models") - val documentationModel = mergeDocumentationModels(transformedDocumentationBeforeMerge) - - report("Transforming documentation model after merging") - val transformedDocumentation = transformDocumentationModelAfterMerge(documentationModel) - - report("Creating pages") - val pages = createPages(transformedDocumentation) - - report("Transforming pages") - val transformedPages = transformPages(pages) - - report("Rendering") - render(transformedPages) - - reportAfterRendering() - } - - override val generationName = " documentation for ${context.configuration.moduleName}" - - fun createDocumentationModels() = runBlocking(Dispatchers.Default) { - context.configuration.sourceSets.parallelMap { sourceSet -> translateSources(sourceSet, context) }.flatten() - .also { modules -> if (modules.isEmpty()) exitGenerationGracefully("Nothing to document") } - } - - fun transformDocumentationModelBeforeMerge(modulesFromPlatforms: List<DModule>) = - context[CoreExtensions.preMergeDocumentableTransformer].fold(modulesFromPlatforms) { acc, t -> t(acc) } - - fun mergeDocumentationModels(modulesFromPlatforms: List<DModule>) = - context.single(CoreExtensions.documentableMerger).invoke(modulesFromPlatforms) - - fun transformDocumentationModelAfterMerge(documentationModel: DModule) = - context[CoreExtensions.documentableTransformer].fold(documentationModel) { acc, t -> t(acc, context) } - - fun createPages(transformedDocumentation: DModule) = - context.single(CoreExtensions.documentableToPageTranslator).invoke(transformedDocumentation) - - fun transformPages(pages: RootPageNode) = - context[CoreExtensions.pageTransformer].fold(pages) { acc, t -> t(acc) } - - fun render(transformedPages: RootPageNode) { - context.single(CoreExtensions.renderer).render(transformedPages) - } - - fun validityCheck(context: DokkaContext) { - val (preGenerationCheckResult, checkMessages) = context[CoreExtensions.preGenerationCheck].fold( - Pair(true, emptyList<String>()) - ) { acc, checker -> checker() + acc } - if (!preGenerationCheckResult) throw DokkaException( - "Pre-generation validity check failed: ${checkMessages.joinToString(",")}" - ) - } - - fun reportAfterRendering() { - context.unusedPoints.takeIf { it.isNotEmpty() }?.also { - context.logger.info("Unused extension points found: ${it.joinToString(", ")}") - } - - context.logger.report() - - if (context.configuration.failOnWarning && (context.logger.warningsCount > 0 || context.logger.errorsCount > 0)) { - throw DokkaException( - "Failed with warningCount=${context.logger.warningsCount} and errorCount=${context.logger.errorsCount}" - ) - } - } - - private suspend fun translateSources(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext) = - context[CoreExtensions.sourceToDocumentableTranslator].parallelMap { translator -> - when(translator){ - is AsyncSourceToDocumentableTranslator -> translator.invokeSuspending(sourceSet, context) - else -> translator.invoke(sourceSet, context) - } - } -}
\ No newline at end of file diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt index 1f5f6018..8703af4f 100644 --- a/core/src/main/kotlin/plugability/DokkaContext.kt +++ b/core/src/main/kotlin/plugability/DokkaContext.kt @@ -30,7 +30,6 @@ interface DokkaContext { pluginOverrides: List<DokkaPlugin> ): DokkaContext = DokkaContextConfigurationImpl(logger, configuration).apply { - CoreExtensions.installTo(this) // File(it.path) is a workaround for an incorrect filesystem in a File instance returned by Gradle. configuration.pluginsClasspath.map { File(it.path).toURI().toURL() } .toTypedArray() |