From 8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 19 Jun 2020 14:08:49 +0200 Subject: Remove SourceSetDataCache, rename PassConfiguration to DokkaSourceSet and use it instead of SourceSetData --- .../kotlin/allModulePage/MultimodulePageCreator.kt | 10 +- .../src/main/kotlin/renderers/DefaultRenderer.kt | 28 ++-- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 60 +++++---- .../main/kotlin/renderers/html/NavigationPage.kt | 8 +- .../kotlin/renderers/html/htmlPreprocessors.kt | 2 +- .../resolvers/local/DefaultLocationProvider.kt | 16 +-- .../kotlin/resolvers/local/LocationProvider.kt | 4 +- .../resolvers/local/MultimoduleLocationProvider.kt | 6 +- .../main/kotlin/signatures/JvmSignatureUtils.kt | 12 +- .../kotlin/signatures/KotlinSignatureProvider.kt | 16 ++- .../DeprecatedDocumentableFilterTransformer.kt | 10 +- .../DocumentableVisibilityFilterTransformer.kt | 36 +++-- .../EmptyPackagesFilterTransformer.kt | 8 +- .../InheritorsExtractorTransformer.kt | 7 +- .../ModuleAndPackageDocumentationTransformer.kt | 9 +- .../documentables/ReportUndocumentedTransformer.kt | 38 ++---- .../pages/comments/CommentsToContentConverter.kt | 4 +- .../pages/comments/DocTagToContentConverter.kt | 4 +- .../pages/samples/SamplesTransformer.kt | 13 +- .../pages/sourcelinks/SourceLinksTransformer.kt | 18 +-- .../DefaultDescriptorToDocumentableTranslator.kt | 19 +-- .../documentables/DefaultPageCreator.kt | 147 +++++++++++++++------ .../documentables/PageContentBuilder.kt | 76 +++++------ .../psi/DefaultPsiToDocumentableTranslator.kt | 9 +- 24 files changed, 309 insertions(+), 251 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt index cdaa0274..e3da9ecc 100644 --- a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt +++ b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt @@ -1,11 +1,11 @@ package org.jetbrains.dokka.base.allModulePage +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.local.MultimoduleLocationProvider.Companion.MULTIMODULE_PACKAGE_PLACEHOLDER import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.doc.P import org.jetbrains.dokka.pages.* @@ -30,9 +30,13 @@ class MultimodulePageCreator( if (commentsConverter == null || signatureProvider == null) throw IllegalStateException("Both comments converter and signature provider must not be null") - val sourceSetData = emptySet() + val sourceSetData = emptySet() val builder = PageContentBuilder(commentsConverter, signatureProvider, context.logger) - val contentNode = builder.contentFor(dri = DRI(MULTIMODULE_PACKAGE_PLACEHOLDER), kind = ContentKind.Cover, sourceSets = sourceSetData) { + val contentNode = builder.contentFor( + dri = DRI(MULTIMODULE_PACKAGE_PLACEHOLDER), + kind = ContentKind.Cover, + sourceSets = sourceSetData + ) { header(2, "All modules:") table(styles = setOf(MultimoduleTable)) { modules.mapNotNull { module -> diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index 141a18e6..f4d547e3 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -1,10 +1,12 @@ package org.jetbrains.dokka.base.renderers -import kotlinx.coroutines.* -import kotlinx.html.FlowContent +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.local.LocationProvider -import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin @@ -28,7 +30,7 @@ abstract class DefaultRenderer( abstract fun T.buildList( node: ContentList, pageContext: ContentPage, - sourceSetRestriction: Set? = null + sourceSetRestriction: Set? = null ) abstract fun T.buildNewLine() @@ -36,7 +38,7 @@ abstract class DefaultRenderer( abstract fun T.buildTable( node: ContentTable, pageContext: ContentPage, - sourceSetRestriction: Set? = null + sourceSetRestriction: Set? = null ) abstract fun T.buildText(textNode: ContentText) @@ -48,18 +50,18 @@ abstract class DefaultRenderer( open fun T.buildPlatformDependent( content: PlatformHintedContent, pageContext: ContentPage, - sourceSetRestriction: Set? + sourceSetRestriction: Set? ) = buildContentNode(content.inner, pageContext) open fun T.buildGroup( node: ContentGroup, pageContext: ContentPage, - sourceSetRestriction: Set? = null + sourceSetRestriction: Set? = null ) = wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) = - node.children.forEach { it.build(this, pageContext) } + node.children.forEach { it.build(this, pageContext) } open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) = childrenCallback() @@ -67,7 +69,7 @@ abstract class DefaultRenderer( open fun T.buildLinkText( nodes: List, pageContext: ContentPage, - sourceSetRestriction: Set? = null + sourceSetRestriction: Set? = null ) { nodes.forEach { it.build(this, pageContext, sourceSetRestriction) } } @@ -79,7 +81,7 @@ abstract class DefaultRenderer( open fun T.buildHeader( node: ContentHeader, pageContext: ContentPage, - sourceSetRestriction: Set? = null + sourceSetRestriction: Set? = null ) { buildHeader(node.level, node) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } } @@ -87,16 +89,16 @@ abstract class DefaultRenderer( open fun ContentNode.build( builder: T, pageContext: ContentPage, - sourceSetRestriction: Set? = null + sourceSetRestriction: Set? = null ) = builder.buildContentNode(this, pageContext, sourceSetRestriction) open fun T.buildContentNode( node: ContentNode, pageContext: ContentPage, - sourceSetRestriction: Set? = null + sourceSetRestriction: Set? = null ) { - if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction } ) { + if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction }) { when (node) { is ContentText -> buildText(node) is ContentHeader -> buildHeader(node, pageContext, sourceSetRestriction) diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 43722888..ee6f1e1f 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -1,13 +1,15 @@ package org.jetbrains.dokka.base.renderers.html -import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking import kotlinx.html.* import kotlinx.html.stream.createHTML +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext @@ -20,11 +22,10 @@ open class HtmlRenderer( context: DokkaContext ) : DefaultRenderer(context) { - private val sourceSetDependencyMap = with(context.sourceSetCache) { - allSourceSets.map { sourceSet -> - sourceSet to allSourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID) } - }.toMap() - } + private val sourceSetDependencyMap = context.configuration.sourceSets.map { sourceSet -> + sourceSet to context.configuration.sourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID) } + }.toMap() + private val pageList = mutableMapOf>() @@ -94,7 +95,7 @@ open class HtmlRenderer( button(classes = "platform-tag platform-selector") { attributes["data-active"] = "" attributes["data-filter"] = it.sourceSetID - when (it.platform.key) { + when (it.analysisPlatform.key) { "common" -> classes = classes + "common-like" "native" -> classes = classes + "native-like" "jvm" -> classes = classes + "jvm-like" @@ -138,7 +139,7 @@ open class HtmlRenderer( override fun FlowContent.buildPlatformDependent( content: PlatformHintedContent, pageContext: ContentPage, - sourceSetRestriction: Set? + sourceSetRestriction: Set? ) = buildPlatformDependent( content.sourceSets.filter { @@ -150,7 +151,7 @@ open class HtmlRenderer( ) private fun FlowContent.buildPlatformDependent( - nodes: Map>, + nodes: Map>, pageContext: ContentPage, extra: PropertyContainer = PropertyContainer.empty(), styles: Set