From 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 10 Nov 2023 11:46:54 +0100 Subject: 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 --- .../renderers/gfm/SourceSetDependentHintTest.kt | 184 +++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt (limited to 'dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt') diff --git a/dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt b/dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt new file mode 100644 index 00000000..3f0129af --- /dev/null +++ b/dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt @@ -0,0 +1,184 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package renderers.gfm + +import org.jetbrains.dokka.DokkaSourceSetID +import org.jetbrains.dokka.Platform +import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer +import org.jetbrains.dokka.pages.TextStyle +import renderers.testPage +import testApi.testRunner.defaultSourceSet +import java.io.File +import kotlin.test.Test +import kotlin.test.assertEquals + +class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { + + private val pl1 = defaultSourceSet.copy( + "pl1", + DokkaSourceSetID("root", "pl1"), + analysisPlatform = Platform.js, + sourceRoots = setOf(File("pl1")) + ) + private val pl2 = defaultSourceSet.copy( + "pl2", + DokkaSourceSetID("root", "pl2"), + analysisPlatform = Platform.jvm, + sourceRoots = setOf(File("pl1")) + ) + private val pl3 = defaultSourceSet.copy( + "pl3", + DokkaSourceSetID("root", "pl3"), + analysisPlatform = Platform.native, + sourceRoots = setOf(File("pl1")) + ) + + @Test + fun platformIndependentCase() { + val page = testPage { + sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) { + text("a") + text("b") + text("c") + } + } + val expect = """|//[testPage](test-page.md) + | + |[pl1, pl2, pl3]\ + |abc""".trimMargin() + + CommonmarkRenderer(context).render(page) + assertEquals(expect, renderedContent) + } + + @Test + fun completelyDivergentCase() { + val page = testPage { + sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) { + text("a", sourceSets = setOf(pl1)) + text("b", sourceSets = setOf(pl2)) + text("c", sourceSets = setOf(pl3)) + } + } + val expect = """|//[testPage](test-page.md) + | + |[pl1]\ + |a + | + |[pl2]\ + |b + | + |[pl3]\ + |c""".trimMargin() + + CommonmarkRenderer(context).render(page) + assertEquals(expect, renderedContent) + } + + @Test + fun overlappingCase() { + val page = testPage { + sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) { + text("a", sourceSets = setOf(pl1)) + text("b", sourceSets = setOf(pl1, pl2)) + text("c", sourceSets = setOf(pl2)) + } + } + val expect = """|//[testPage](test-page.md) + | + |[pl1]\ + |ab + | + |[pl2]\ + |bc""".trimMargin() + + CommonmarkRenderer(context).render(page) + assertEquals(expect, renderedContent) + } + + @Test + fun caseThatCanBeSimplified() { + val page = testPage { + sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) { + text("a", sourceSets = setOf(pl1, pl2)) + text("b", sourceSets = setOf(pl1)) + text("b", sourceSets = setOf(pl2)) + } + } + val expect = """|//[testPage](test-page.md) + | + |[pl1, pl2]\ + |ab""".trimMargin() + + CommonmarkRenderer(context).render(page) + assertEquals(expect, renderedContent) + } + + @Test + fun caseWithGroupBreakingSimplification() { + val page = testPage { + sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) { + group(styles = setOf(TextStyle.Block)) { + text("a", sourceSets = setOf(pl1, pl2)) + text("b", sourceSets = setOf(pl1)) + } + text("b", sourceSets = setOf(pl2)) + } + } + val expect = """|//[testPage](test-page.md) + | + |[pl1]\ + |ab + | + |[pl2]\ + |a + | + |b""".trimMargin() + + CommonmarkRenderer(context).render(page) + assertEquals(expect, renderedContent) + } + + @Test + fun caseWithGroupNotBreakingSimplification() { + val page = testPage { + sourceSetDependentHint(sourceSets = setOf(pl1, pl2)) { + group { + text("a", sourceSets = setOf(pl1, pl2)) + text("b", sourceSets = setOf(pl1)) + } + text("b", sourceSets = setOf(pl2)) + } + } + val expect = """|//[testPage](test-page.md) + | + |[pl1, pl2]\ + |ab""".trimMargin() + + CommonmarkRenderer(context).render(page) + assertEquals(expect, renderedContent) + } + + @Test + fun partiallyUnifiedCase() { + val page = testPage { + sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) { + text("a", sourceSets = setOf(pl1)) + text("a", sourceSets = setOf(pl2)) + text("b", sourceSets = setOf(pl3)) + } + } + val expect = """|//[testPage](test-page.md) + | + |[pl1, pl2]\ + |a + | + |[pl3]\ + |b""".trimMargin() + + CommonmarkRenderer(context).render(page) + assertEquals(expect, renderedContent) + } +} -- cgit