diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-08-24 14:18:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 14:18:26 +0200 |
commit | 97628db0d7622140158ed6679b67b4e2e4355194 (patch) | |
tree | c55a94399aaa9004c161b8b7da2c346f9697ad9c /plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt | |
parent | ee513880e09c011578d31922119073e3bda18453 (diff) | |
download | dokka-97628db0d7622140158ed6679b67b4e2e4355194.tar.gz dokka-97628db0d7622140158ed6679b67b4e2e4355194.tar.bz2 dokka-97628db0d7622140158ed6679b67b4e2e4355194.zip |
Fix incorrect handling of static members used within `@see` tag (#2627)
Diffstat (limited to 'plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt')
-rw-r--r-- | plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt | 121 |
1 files changed, 59 insertions, 62 deletions
diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt index 5c1fd054..5dee546f 100644 --- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt +++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt @@ -517,76 +517,73 @@ class ContentForSeeAlsoTest : BaseAbstractTest() { } @Test - fun `undocumented see also from java`(){ + fun `should prefix static function and property links with class name`() { testInline( """ - |/src/main/java/example/Source.java - |package example; + |/src/main/kotlin/com/example/package/CollectionExtensions.kt + |package com.example.util | - |public interface Source { - | String getProperty(String k, String v); - | - | /** - | * @see #getProperty(String, String) - | */ - | String getProperty(String k); + |object CollectionExtensions { + | val property = "Hi" + | fun emptyList() {} |} - """.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); + |/src/main/kotlin/com/example/foo.kt + |package com.example | - | /** - | * @see #getProperty(String, String) this is a reference to a method that is present on the same class. - | */ - | String getProperty(String k); - |} - """.trimIndent(), testConfiguration + |import com.example.util.CollectionExtensions.property + |import com.example.util.CollectionExtensions.emptyList + | + |/** + | * @see [property] static property + | * @see [emptyList] static emptyList + | */ + |fun function() {} + """.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")) - ) - ) + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "com.example" } + .children.single { it.name == "function" } as ContentPage - 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) + page.content.assertNode { + group { + header(1) { +"function" } + } + divergentGroup { + divergentInstance { + divergent { + bareSignature( + annotations = emptyMap(), + visibility = "", + modifier = "", + keywords = emptySet(), + name = "function", + returnType = null, + ) + } + after { + header(4) { +"See also" } + group { + table { + group { + link { +"CollectionExtensions.property" } + group { + group { +"static property" } + } + } + group { + link { +"CollectionExtensions.emptyList" } + group { + group { +"static emptyList" } + } + } + } + } + } + } + } + } } } } |