diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-11-10 11:46:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 11:46:54 +0100 |
commit | 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch) | |
tree | 1b915207b2b9f61951ddbf0ff2e687efd053d555 /dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt | |
parent | a44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff) | |
download | dokka-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 'dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt')
-rw-r--r-- | dokka-subprojects/plugin-gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt | 184 |
1 files changed, 184 insertions, 0 deletions
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) + } +} |