diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-10-07 19:36:49 +0200 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-11-27 03:15:02 +0100 |
commit | d41965ca3cb180bc82bd5dd6fa747d2b83381b31 (patch) | |
tree | 5660f17f21fdf5871c8239f4d96c4521545292d1 /core/src | |
parent | dc179bf9a649d925e7e64dbcaf52a2187416a1d5 (diff) | |
download | dokka-d41965ca3cb180bc82bd5dd6fa747d2b83381b31.tar.gz dokka-d41965ca3cb180bc82bd5dd6fa747d2b83381b31.tar.bz2 dokka-d41965ca3cb180bc82bd5dd6fa747d2b83381b31.zip |
Implement immediate temaplates resolution
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/configuration.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/defaultConfiguration.kt | 1 | ||||
-rw-r--r-- | core/src/main/kotlin/generation/SingleModuleGeneration.kt | 90 | ||||
-rw-r--r-- | core/src/main/kotlin/pages/PageNodes.kt | 10 |
4 files changed, 42 insertions, 61 deletions
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index fa3bd6c1..a3989ebc 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -16,6 +16,7 @@ object DokkaDefaults { val cacheRoot: File? = null const val offlineMode: Boolean = false const val failOnWarning: Boolean = false + const val delayTemplateSubstitution: Boolean = false const val includeNonPublic: Boolean = false const val reportUndocumented: Boolean = false @@ -96,6 +97,7 @@ interface DokkaConfiguration : Serializable { val modules: List<DokkaModuleDescription> val pluginsClasspath: List<File> val pluginsConfiguration: List<PluginConfiguration> + val delayTemplateSubstitution: Boolean enum class SerializationFormat : Serializable { JSON, XML diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index c4dc1d00..869a99ed 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -15,6 +15,7 @@ data class DokkaConfigurationImpl( override val pluginsConfiguration: List<PluginConfigurationImpl> = DokkaDefaults.pluginsConfiguration, override val modules: List<DokkaModuleDescriptionImpl> = emptyList(), override val failOnWarning: Boolean = DokkaDefaults.failOnWarning, + override val delayTemplateSubstitution: Boolean = false, ) : DokkaConfiguration data class PluginConfigurationImpl( diff --git a/core/src/main/kotlin/generation/SingleModuleGeneration.kt b/core/src/main/kotlin/generation/SingleModuleGeneration.kt index 59514632..2eedc561 100644 --- a/core/src/main/kotlin/generation/SingleModuleGeneration.kt +++ b/core/src/main/kotlin/generation/SingleModuleGeneration.kt @@ -1,8 +1,12 @@ + package org.jetbrains.dokka.generation import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking -import org.jetbrains.dokka.* +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 @@ -10,85 +14,59 @@ import org.jetbrains.dokka.transformers.sources.AsyncSourceToDocumentableTransla import org.jetbrains.dokka.utilities.parallelMap import org.jetbrains.dokka.utilities.report -class SingleModuleGeneration(private val context: DokkaContext): Generation { +class SingleModuleGeneration(private val context: DokkaContext) : Generation { override fun Timer.generate() { report("Validity check") validityCheck(context) report("Creating documentation models") - val modulesFromPlatforms = createDocumentationModels(context) + val modulesFromPlatforms = createDocumentationModels() report("Transforming documentation model before merging") - val transformedDocumentationBeforeMerge = transformDocumentationModelBeforeMerge(modulesFromPlatforms, context) + val transformedDocumentationBeforeMerge = transformDocumentationModelBeforeMerge(modulesFromPlatforms) report("Merging documentation models") - val documentationModel = mergeDocumentationModels(transformedDocumentationBeforeMerge, context) + val documentationModel = mergeDocumentationModels(transformedDocumentationBeforeMerge) report("Transforming documentation model after merging") - val transformedDocumentation = transformDocumentationModelAfterMerge(documentationModel, context) + val transformedDocumentation = transformDocumentationModelAfterMerge(documentationModel) report("Creating pages") - val pages = createPages(transformedDocumentation, context) + val pages = createPages(transformedDocumentation) report("Transforming pages") - val transformedPages = transformPages(pages, context) + val transformedPages = transformPages(pages) report("Rendering") - render(transformedPages, context) + render(transformedPages) - reportAfterRendering(context) + reportAfterRendering() } - override val generationName: String - get() = TODO("Not yet implemented") + override val generationName = " documentation for ${context.configuration.moduleName}" - fun createDocumentationModels( - context: DokkaContext - ) = runBlocking(Dispatchers.Default) { + 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: DokkaContext - ) = context[CoreExtensions.preMergeDocumentableTransformer].fold(modulesFromPlatforms) { acc, t -> t(acc) } - - fun mergeDocumentationModels( - modulesFromPlatforms: List<DModule>, - context: DokkaContext - ) = context.single(CoreExtensions.documentableMerger).invoke(modulesFromPlatforms) - - fun transformDocumentationModelAfterMerge( - documentationModel: DModule, - context: DokkaContext - ) = context[CoreExtensions.documentableTransformer].fold(documentationModel) { acc, t -> t(acc, context) } - - fun createPages( - transformedDocumentation: DModule, - context: DokkaContext - ) = context.single(CoreExtensions.documentableToPageTranslator).invoke(transformedDocumentation) - - fun createAllModulePage( - context: DokkaContext - ) = context.single(CoreExtensions.allModulePageCreator).invoke() - - fun transformPages( - pages: RootPageNode, - context: DokkaContext - ) = context[CoreExtensions.pageTransformer].fold(pages) { acc, t -> t(acc) } - - fun transformAllModulesPage( - pages: RootPageNode, - context: DokkaContext - ) = context[CoreExtensions.allModulePageTransformer].fold(pages) { acc, t -> t(acc) } - - fun render( - transformedPages: RootPageNode, - context: DokkaContext - ) { - val renderer = context.single(CoreExtensions.renderer) - renderer.render(transformedPages) + 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) { @@ -100,7 +78,7 @@ class SingleModuleGeneration(private val context: DokkaContext): Generation { ) } - fun reportAfterRendering(context: DokkaContext) { + fun reportAfterRendering() { context.unusedPoints.takeIf { it.isNotEmpty() }?.also { context.logger.info("Unused extension points found: ${it.joinToString(", ")}") } diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt index a91887b4..94ec8258 100644 --- a/core/src/main/kotlin/pages/PageNodes.kt +++ b/core/src/main/kotlin/pages/PageNodes.kt @@ -30,7 +30,7 @@ interface ContentPage : PageNode { ): ContentPage } -abstract class RootPageNode : PageNode { +abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode { val parentMap: Map<PageNode, PageNode> by lazy { IdentityHashMap<PageNode, PageNode>().apply { fun process(parent: PageNode) { @@ -157,18 +157,18 @@ class MemberPageNode( class MultimoduleRootPageNode( - override val name: String, override val dri: Set<DRI>, override val content: ContentNode, override val embeddedResources: List<String> = emptyList() -) : RootPageNode(), MultimoduleRootPage { +) : RootPageNode(forceTopLevelName = true), MultimoduleRootPage { + override val name = "" override val children: List<PageNode> = emptyList() override val documentable: Documentable? = null override fun modified(name: String, children: List<PageNode>): RootPageNode = - MultimoduleRootPageNode(name, dri, content, embeddedResources) + MultimoduleRootPageNode(dri, content, embeddedResources) override fun modified( name: String, @@ -178,7 +178,7 @@ class MultimoduleRootPageNode( children: List<PageNode> ) = if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this - else MultimoduleRootPageNode(name, dri, content, embeddedResources) + else MultimoduleRootPageNode(dri, content, embeddedResources) } inline fun <reified T : PageNode> PageNode.children() = children.filterIsInstance<T>() |