aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2024-04-25 23:11:33 +0300
committerGitHub <noreply@github.com>2024-04-25 23:11:33 +0300
commitd6c9fc8b434d01d61077e8eba464196cf04a94ef (patch)
tree1e09323b75939cf4bb0993c2d2f94aa30c9493c8
parent17ea9945f934ea54a68f6debb8d2a03839d5fac5 (diff)
downloaddokka-upstream-master.tar.gz
Add unit tests for KDoc links to Java (#3584)upstream-master
Two new tests have been added in `LinkTest.kt`. One is to verify that a KDoc link correctly points to Java annotation methods, and the second test is for Java synthetic properties.
-rw-r--r--dokka-subprojects/plugin-base/src/test/kotlin/markdown/LinkTest.kt59
1 files changed, 59 insertions, 0 deletions
diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/markdown/LinkTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/markdown/LinkTest.kt
index f70e6aa7d..83c0ab953 100644
--- a/dokka-subprojects/plugin-base/src/test/kotlin/markdown/LinkTest.kt
+++ b/dokka-subprojects/plugin-base/src/test/kotlin/markdown/LinkTest.kt
@@ -1040,6 +1040,65 @@ class LinkTest : BaseAbstractTest() {
}
}
+ @Test
+ fun `KDoc link should lead to java annotation methods`() {
+ testInline(
+ """
+ |/src/main/kotlin/Testing.kt
+ |package example
+ |
+ |/**
+ | * [Storage.value]
+ | */
+ |val usage = 0
+ |/src/example/Storage.java
+ |package example;
+ |@interface Storage {
+ | String value() default "";
+ |}
+ """.trimMargin(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ assertEquals(DRI("example", "Storage", Callable("value", null, emptyList())), module.getLinkDRIFrom("usage"))
+ }
+ }
+ }
+
+ @Test
+ fun `KDoc link should lead to java synthetic properties`() {
+ testInline(
+ """
+ |/src/main/kotlin/Testing.kt
+ |package example
+ |
+ |/**
+ | * value: [Storage.value] is unresolved
+ | * setValue: [Storage.setValue]
+ | * prop: [Storage.prop]
+ | */
+ |val usage = 0
+ |/src/example/Storage.java
+ |package example;
+ |class Storage {
+ | void prop() {}
+ | void setValue(String value) {}
+ | String getProp() { return null; }
+ |}
+ """.trimMargin(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ assertEquals(
+ listOf(
+ "Storage.setValue" to DRI("example", "Storage", Callable("setValue", null, listOf(TypeConstructor("kotlin.String", emptyList())))),
+ "Storage.prop" to DRI("example", "Storage", Callable("prop", null, emptyList()))
+ ),
+ module.getAllLinkDRIFrom("usage"))
+ }
+ }
+ }
+
private fun DModule.getLinkDRIFrom(name: String): DRI? {
val link = this.dfs { it.name == name }?.documentation?.values?.single()?.firstMemberOfTypeOrNull<DocumentationLink>()
return link?.dri