diff options
Diffstat (limited to 'plugins')
4 files changed, 23 insertions, 19 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index 57a3d8d1..ebfcf864 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -175,7 +175,7 @@ abstract class DefaultRenderer<T>( pageContext: ContentPage, beforeTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String, afterTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String - ): Map<Pair<String, String>, List<Pair<ContentDivergentInstance, DokkaSourceSet>>> = + ): Map<SerializedInstanceWithSource, List<InstanceWithSource>> = children.flatMap { instance -> instance.sourceSets.map { sourceSet -> Pair(instance, sourceSet) to Pair( @@ -189,4 +189,7 @@ abstract class DefaultRenderer<T>( ) } +internal typealias SerializedInstanceWithSource = Pair<String, String> +internal typealias InstanceWithSource = Pair<ContentDivergentInstance, DokkaSourceSet> + fun ContentPage.sourceSets() = this.content.sourceSets
\ No newline at end of file diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt index 7db06bb2..671b87f8 100644 --- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt @@ -149,7 +149,7 @@ open class CommonmarkRenderer( platforms.joinToString( prefix = " [", postfix = "] $text " - ) { "${it.moduleDisplayName}/${it.sourceSetID}" }) + ) { it.sourceSetID.toString() }) buildNewLine() } } @@ -166,7 +166,7 @@ open class CommonmarkRenderer( ) { if (node.dci.kind == ContentKind.Sample || node.dci.kind == ContentKind.Parameters) { node.sourceSets.forEach { sourcesetData -> - append("${sourcesetData.moduleDisplayName}/${sourcesetData.sourceSetID}") + append(sourcesetData.sourceSetID.toString()) buildNewLine() buildTable( node.copy( @@ -251,7 +251,7 @@ open class CommonmarkRenderer( distinct.values.forEach { entry -> val (instance, sourceSets) = entry.getInstanceAndSourceSets() - append(sourceSets.joinToString(prefix = "#### [", postfix = "]") { "${it.moduleName}/${it.sourceSetID}" }) + append(sourceSets.joinToString(prefix = "#### [", postfix = "]") { it.sourceSetID.toString() }) buildNewLine() instance.before?.let { append("##### Brief description") @@ -266,7 +266,7 @@ open class CommonmarkRenderer( .values.forEach { innerEntry -> val (innerInstance, innerSourceSets) = innerEntry.getInstanceAndSourceSets() if(sourceSets.size > 1) { - append(innerSourceSets.joinToString(prefix = "###### [", postfix = "]") { "${it.moduleName}/${it.sourceSetID}" }) + append(innerSourceSets.joinToString(prefix = "###### [", postfix = "]") { it.sourceSetID.toString() }) buildNewLine() } innerInstance.divergent.build(this@buildDivergent, pageContext) diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt index 64750ec6..035a9264 100644 --- a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt +++ b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt @@ -1,5 +1,6 @@ package renderers.gfm +import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.Platform import org.jetbrains.dokka.SourceRootImpl import org.jetbrains.dokka.gfm.CommonmarkRenderer @@ -13,22 +14,21 @@ class DivergentTest : GfmRenderingOnlyTestBase() { private val js = defaultSourceSet.copy( "root", "JS", - "js", + DokkaSourceSetID("root", "js"), analysisPlatform = Platform.js, sourceRoots = listOf(SourceRootImpl("pl1")) ) private val jvm = defaultSourceSet.copy( "root", "JVM", - "jvm", - + DokkaSourceSetID("root", "jvm"), analysisPlatform = Platform.jvm, sourceRoots = listOf(SourceRootImpl("pl1")) ) private val native = defaultSourceSet.copy( "root", "NATIVE", - "native", + DokkaSourceSetID("root", "native"), analysisPlatform = Platform.native, sourceRoots = listOf(SourceRootImpl("pl1")) ) diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt index 18260f0e..5807d025 100644 --- a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt +++ b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt @@ -1,5 +1,6 @@ package renderers.gfm +import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.Platform import org.jetbrains.dokka.SourceRootImpl import org.jetbrains.dokka.gfm.CommonmarkRenderer @@ -13,21 +14,21 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { private val pl1 = defaultSourceSet.copy( "root", "pl1", - "pl1", + DokkaSourceSetID("root", "pl1"), analysisPlatform = Platform.js, sourceRoots = listOf(SourceRootImpl("pl1")) ) private val pl2 = defaultSourceSet.copy( "root", "pl2", - "pl2", + DokkaSourceSetID("root", "pl2"), analysisPlatform = Platform.jvm, sourceRoots = listOf(SourceRootImpl("pl1")) ) private val pl3 = defaultSourceSet.copy( "root", "pl3", - "pl3", + DokkaSourceSetID("root", "pl3"), analysisPlatform = Platform.native, sourceRoots = listOf(SourceRootImpl("pl1")) ) @@ -43,7 +44,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { } CommonmarkRenderer(context).render(page) - assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2, root/pl3] abc \n ") + assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2, root/pl3] abc \n \n") } @Test @@ -57,7 +58,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { } CommonmarkRenderer(context).render(page) - assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1] a \n [root/pl2] b \n [root/pl3] c \n ") + assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1] a \n \n [root/pl2] b \n \n [root/pl3] c \n \n") } @Test @@ -71,7 +72,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { } CommonmarkRenderer(context).render(page) - assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1] ab \n [root/pl2] bc \n ") + assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1] ab \n \n [root/pl2] bc \n \n") } @Test @@ -85,7 +86,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { } CommonmarkRenderer(context).render(page) - assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2] ab \n ") + assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2] ab \n \n") } @Test @@ -101,7 +102,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { } CommonmarkRenderer(context).render(page) - assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1] ab \n \n [root/pl2] a \nb \n ") + assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1] ab \n \n \n [root/pl2] a \nb \n \n") } @Test @@ -117,7 +118,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { } CommonmarkRenderer(context).render(page) - assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2] ab ") + assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2] ab \n") } @Test @@ -131,6 +132,6 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() { } CommonmarkRenderer(context).render(page) - assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2] a \n [root/pl3] b \n ") + assert(renderedContent == "//[testPage](test-page.md)\n\n [root/pl1, root/pl2] a \n \n [root/pl3] b \n \n") } }
\ No newline at end of file |