diff options
Diffstat (limited to 'plugins/base/src/test/kotlin')
5 files changed, 85 insertions, 23 deletions
diff --git a/plugins/base/src/test/kotlin/basic/DRITest.kt b/plugins/base/src/test/kotlin/basic/DRITest.kt index 1ac05177..b09932fe 100644 --- a/plugins/base/src/test/kotlin/basic/DRITest.kt +++ b/plugins/base/src/test/kotlin/basic/DRITest.kt @@ -4,6 +4,7 @@ import org.jetbrains.dokka.links.* import org.jetbrains.dokka.model.DClass import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.DParameter +import org.jetbrains.dokka.model.OtherParameter import org.jetbrains.dokka.pages.* import org.junit.jupiter.api.Assertions.assertEquals import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest @@ -212,7 +213,7 @@ class DRITest : AbstractCoreTest() { |package example | |class Sample<S>(first: S){ - | fun <T> genericFun(param1: String): Triple<S,T> = TODO() + | fun <T> genericFun(param1: String): Tuple<S,T> = TODO() |} | | @@ -239,6 +240,43 @@ class DRITest : AbstractCoreTest() { } @Test + fun driForFunctionNestedInsideInnerClass() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + classpath = listOfNotNull(jvmStdlibPath) + } + } + } + testInline( + """ + |/src/main/kotlin/Test.kt + |package example + | + |class Sample<S>(first: S){ + | inner class SampleInner { + | fun foo(): S = TODO() + | } + |} + | + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + val sampleClass = module.dfs { it.name == "Sample" } as ClasslikePageNode + val sampleInner = sampleClass.children.first { it.name == "SampleInner" } as ClasslikePageNode + val foo = sampleInner.children.first { it.name == "foo" } as MemberPageNode + val documentable = foo.documentable as DFunction + + assertEquals(sampleClass.dri.first().toString(), (documentable.type as OtherParameter).declarationDRI.toString()) + assertEquals(0, documentable.generics.size) + } + } + } + + @Test fun driForGenericExtensionFunction(){ val configuration = dokkaConfiguration { passes { diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt index c34fa909..33d3f64c 100644 --- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt +++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt @@ -11,7 +11,6 @@ import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.jetbrains.kotlin.utils.addToStdlib.cast import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import java.nio.file.Paths @@ -182,4 +181,46 @@ class LinkableContentTest : AbstractCoreTest() { } } } + + @Test + fun `Documenting return type for a function in inner class with generic parent`(){ + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |class Sample<S>(first: S){ + | inner class SampleInner { + | fun foo(): S = TODO() + | } + |} + | + """.trimIndent(), + dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + analysisPlatform = "jvm" + targets = listOf("jvm") + } + } + } + ) { + renderingStage = { module, _ -> + val sample = module.children.single { it.name == "test" } + .children.single { it.name == "Sample" }.cast<ClasslikePageNode>() + val foo = sample + .children.single { it.name == "SampleInner" }.cast<ClasslikePageNode>() + .children.single { it.name == "foo" }.cast<MemberPageNode>() + + val returnTypeNode = foo.content.dfs { + val link = it.safeAs<ContentDRILink>()?.children + val child = link?.first().safeAs<ContentText>() + child?.text == "S" + }?.safeAs<ContentDRILink>() + + Assertions.assertEquals(sample.dri.first(), returnTypeNode?.address) + } + } + } }
\ No newline at end of file diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt index bf234b6b..fe5b573a 100644 --- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt +++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt @@ -51,14 +51,14 @@ class LinkTest : AbstractCoreTest() { val configuration = dokkaConfiguration { passes { pass { - sourceRoots = listOf("src/main/kotlin/parser") + sourceRoots = listOf("src/main/kotlin") } } } + //This does not contain a package to check for situation when the package has to be artificially generated testInline( """ |/src/main/kotlin/parser/Test.kt - |package parser | |class Outer<OUTER> { | inner class Inner<INNER> { @@ -73,7 +73,8 @@ class LinkTest : AbstractCoreTest() { val innerClass = root.children.first { it is ClasslikePageNode } val foo = innerClass.children.first { it.name == "foo" } as MemberPageNode - assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == "parser/Outer///PointingToDeclaration/" } ) + assertEquals(root.dri.first().toString(), "[main root]/Outer///PointingToDeclaration/") + assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == root.dri.first().toString() } ) } } } diff --git a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt index dd4d1ee0..08d4a7b6 100644 --- a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt +++ b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt @@ -112,21 +112,4 @@ internal object EmptyCommentConverter : CommentsToContentConverter { styles: Set<Style>, extras: PropertyContainer<ContentNode> ): List<ContentNode> = emptyList() -} - -internal object EmptyLocationProviderFactory: LocationProviderFactory { - override fun getLocationProvider(pageNode: RootPageNode) = object : LocationProvider { - override fun resolve(dri: DRI, sourceSets: List<SourceSetData>, context: PageNode?): String = "" - - override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String = node.name - - override fun resolveRoot(node: PageNode): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun ancestors(node: PageNode): List<PageNode> { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - } }
\ No newline at end of file diff --git a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt index f774a09b..c1dc40a7 100644 --- a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt @@ -101,7 +101,6 @@ class SourceSetDependentHintTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - println(renderedContent) renderedContent.match(Div(Div("ab"))) } |