diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-09-20 11:35:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 11:35:26 +0200 |
commit | e6dd88c0cce8d61aeed19b4f49c7cca3d95b72b1 (patch) | |
tree | 6a9212739f9838e31661b7d9de45400d8ca0697b /plugins/base/src/test/kotlin/content/seealso | |
parent | cdb88fb3c0cc796cf121b2ab6194091058ccc30c (diff) | |
download | dokka-e6dd88c0cce8d61aeed19b4f49c7cca3d95b72b1.tar.gz dokka-e6dd88c0cce8d61aeed19b4f49c7cca3d95b72b1.tar.bz2 dokka-e6dd88c0cce8d61aeed19b4f49c7cca3d95b72b1.zip |
Make see tag display as other tables (#2153)
Diffstat (limited to 'plugins/base/src/test/kotlin/content/seealso')
-rw-r--r-- | plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt index 911066fc..e9a54e87 100644 --- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt +++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt @@ -4,6 +4,11 @@ import matchers.content.* import org.jetbrains.dokka.pages.ContentDRILink import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.links.Callable +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.links.JavaClassReference +import org.jetbrains.dokka.model.doc.See +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import org.junit.jupiter.api.Test import utils.* import kotlin.test.assertEquals @@ -469,4 +474,79 @@ class ContentForSeeAlsoTest : BaseAbstractTest() { } } } + + @Test + fun `undocumented see also from java`(){ + testInline( + """ + |/src/main/java/example/Source.java + |package example; + | + |public interface Source { + | String getProperty(String k, String v); + | + | /** + | * @see #getProperty(String, String) + | */ + | String getProperty(String k); + |} + """.trimIndent(), testConfiguration + ) { + documentablesTransformationStage = { module -> + val functionWithSeeTag = module.packages.flatMap { it.classlikes }.flatMap { it.functions }.find { it.name == "getProperty" && it.parameters.count() == 1 } + val seeTag = functionWithSeeTag?.docs()?.firstIsInstanceOrNull<See>() + val expectedLinkDestinationDRI = DRI( + packageName = "example", + classNames = "Source", + callable = Callable( + name = "getProperty", + params = listOf(JavaClassReference("java.lang.String"), JavaClassReference("java.lang.String")) + ) + ) + + kotlin.test.assertNotNull(seeTag) + assertEquals("getProperty(String, String)", seeTag.name) + assertEquals(expectedLinkDestinationDRI, seeTag.address) + assertEquals(emptyList(), seeTag.children) + } + } + } + + @Test + fun `documented see also from java`(){ + testInline( + """ + |/src/main/java/example/Source.java + |package example; + | + |public interface Source { + | String getProperty(String k, String v); + | + | /** + | * @see #getProperty(String, String) this is a reference to a method that is present on the same class. + | */ + | String getProperty(String k); + |} + """.trimIndent(), testConfiguration + ) { + documentablesTransformationStage = { module -> + val functionWithSeeTag = module.packages.flatMap { it.classlikes }.flatMap { it.functions }.find { it.name == "getProperty" && it.parameters.size == 1 } + val seeTag = functionWithSeeTag?.docs()?.firstIsInstanceOrNull<See>() + val expectedLinkDestinationDRI = DRI( + packageName = "example", + classNames = "Source", + callable = Callable( + name = "getProperty", + params = listOf(JavaClassReference("java.lang.String"), JavaClassReference("java.lang.String")) + ) + ) + + kotlin.test.assertNotNull(seeTag) + assertEquals("getProperty(String, String)", seeTag.name) + assertEquals(expectedLinkDestinationDRI, seeTag.address) + assertEquals("this is a reference to a method that is present on the same class.", seeTag.children.first().text().trim()) + assertEquals(1, seeTag.children.size) + } + } + } } |