aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/transformerBuilders
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /plugins/base/src/test/kotlin/transformerBuilders
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'plugins/base/src/test/kotlin/transformerBuilders')
-rw-r--r--plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt195
1 files changed, 0 insertions, 195 deletions
diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
deleted file mode 100644
index 7ee67228..00000000
--- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package transformerBuilders
-
-import org.jetbrains.dokka.CoreExtensions
-import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
-import org.jetbrains.dokka.model.dfs
-import org.jetbrains.dokka.pages.*
-import org.jetbrains.dokka.plugability.DokkaPlugin
-import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
-import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
-import org.jetbrains.dokka.transformers.pages.PageTransformer
-import org.jetbrains.dokka.transformers.pages.pageMapper
-import org.jetbrains.dokka.transformers.pages.pageScanner
-import org.jetbrains.dokka.transformers.pages.pageStructureTransformer
-import utils.assertNotNull
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class PageTransformerBuilderTest : BaseAbstractTest() {
-
- class ProxyPlugin(transformer: PageTransformer) : DokkaPlugin() {
- val pageTransformer by extending { CoreExtensions.pageTransformer with transformer }
-
- @OptIn(DokkaPluginApiPreview::class)
- override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement =
- PluginApiPreviewAcknowledgement
- }
-
- @Test
- fun scannerTest() {
- val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/main/kotlin/transformerBuilder/Test.kt")
- }
- }
- }
- val list = mutableListOf<String>()
-
- var orig: PageNode? = null
-
- testInline(
- """
- |/src/main/kotlin/transformerBuilder/Test.kt
- |package transformerBuilder
- |
- |object Test {
- | fun test2(str: String): Unit {println(str)}
- |}
- """.trimMargin(),
- configuration,
- pluginOverrides = listOf(ProxyPlugin(pageScanner {
- list += name
- }))
- ) {
- pagesGenerationStage = {
- orig = it
- }
- pagesTransformationStage = { root ->
- list.assertCount(4, "Page list: ")
- orig?.let { root.assertTransform(it) }
- }
- }
- }
-
- @Test
- fun mapperTest() {
- val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/main/kotlin/transformerBuilder/Test.kt")
- }
- }
- }
-
- var orig: PageNode? = null
-
- testInline(
- """
- |/src/main/kotlin/transformerBuilder/Test.kt
- |package transformerBuilder
- |
- |object Test {
- | fun test2(str: String): Unit {println(str)}
- |}
- """.trimMargin(),
- configuration,
- pluginOverrides = listOf(ProxyPlugin(pageMapper {
- modified(name = name + "2")
- }))
- ) {
- pagesGenerationStage = {
- orig = it
- }
- pagesTransformationStage = {
- it.let { root ->
- root.name.assertEqual("root2", "Root name: ")
- orig?.let {
- root.assertTransform(it) { node -> node.modified(name = node.name + "2") }
- }
- }
- }
- }
- }
-
- @Test
- fun structureTransformerTest() {
- val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/main/kotlin/transformerBuilder/Test.kt")
- }
- }
- }
-
- testInline(
- """
- |/src/main/kotlin/transformerBuilder/Test.kt
- |package transformerBuilder
- |
- |object Test {
- | fun test2(str: String): Unit {println(str)}
- |}
- """.trimMargin(),
- configuration,
- pluginOverrides = listOf(ProxyPlugin(pageStructureTransformer {
- val ch = children.first()
- modified(
- children = listOf(
- ch,
- RendererSpecificResourcePage("test", emptyList(), RenderingStrategy.DoNothing)
- )
- )
- }))
- ) {
- pagesTransformationStage = { root ->
- root.children.assertCount(2, "Root children: ")
- root.children.first().name.assertEqual("transformerBuilder")
- root.children[1].name.assertEqual("test")
- }
- }
- }
-
- @Test
- fun `kotlin constructors tab should exist even though there is primary constructor only`() {
- val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/")
- }
- }
- }
- testInline(
- """
- |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt
- |package kotlinAsJavaPlugin
- |
- |class Test(val xd: Int)
- """.trimMargin(),
- configuration
- ) {
- pagesGenerationStage = { root ->
- val content = root.children
- .flatMap { it.children<ContentPage>() }
- .map { it.content }.single().children
- .filterIsInstance<ContentGroup>()
- .single { it.dci.kind == ContentKind.Main }.children
-
- val contentWithConstructorsHeader = content.find { tabContent -> tabContent.dfs { it is ContentText && (it as? ContentText)?.text == "Constructors"} != null }
-
- contentWithConstructorsHeader.assertNotNull("contentWithConstructorsHeader")
-
- contentWithConstructorsHeader?.dfs { it.dci.kind == ContentKind.Constructors && it is ContentGroup }
- .assertNotNull("constructor group")
- }
- }
- }
-
- private fun <T> Collection<T>.assertCount(n: Int, prefix: String = "") =
- assertEquals(n, count(), "${prefix}Expected $n, got ${count()}")
-
- private fun <T> T.assertEqual(expected: T, prefix: String = "") =
- assertEquals(expected, this, "${prefix}Expected $expected, got $this")
-
- private fun PageNode.assertTransform(expected: PageNode, block: (PageNode) -> PageNode = { it }): Unit = this.let {
- it.name.assertEqual(block(expected).name)
- it.children.zip(expected.children).forEach { (g, e) ->
- g.name.assertEqual(block(e).name)
- g.assertTransform(e, block)
- }
- }
-}