Skip to content

Commit

Permalink
Add new tests for KDoc links
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed Dec 4, 2024
1 parent d11819c commit 4a62823
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions dokka-subprojects/plugin-base/src/test/kotlin/markdown/LinkTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,78 @@ class LinkTest : BaseAbstractTest() {
}
}

@Test
fun `KDoc link should be unresolved to non-existed property with the name of Kotlin getter #3681`() {
testInline(
"""
|/src/main/kotlin/Testing.kt
|fun getProperty() = 0
|/**
|* [property] is unresolved
| */
| usage() = 0
|}
""".trimMargin(),
configuration
) {
documentablesMergingStage = { module ->
assertEquals(null, module.getLinkDRIFrom("usage"))
}
}
}

@Test
fun `KDoc link should be resolved to two extensions with the same name #3631`() {
testInline(
"""
|/src/main/kotlin/Testing.kt
|class C
|public fun C.ensureActive() {}
|/**
| * [C.ensureActive]
| */
|class B
|/**
| * [C.ensureActive]
| */
|public fun B.ensureActive() {}
""".trimMargin(),
configuration
) {
documentablesMergingStage = { module ->
val DRItoBensureActive = DRI(
"",
classNames = null,
callable = Callable(
name = "ensureActive",
receiver = TypeConstructor(fullyQualifiedName = "B", params = emptyList()),
params = emptyList()
)
)
val link1 = module.dfs {
it.dri == DRItoBensureActive
}?.documentation?.values?.single()?.firstMemberOfTypeOrNull<DocumentationLink>()?.dri
val link2 = module.getLinkDRIFrom("B")


assertEquals(
link1,
DRI(
"",
classNames = null,
callable = Callable(
name = "ensureActive",
receiver = TypeConstructor(fullyQualifiedName = "C", params = emptyList()),
params = emptyList()
)
)
)

assertEquals(link1, link2)
}
}
}

private fun DModule.getLinkDRIFrom(name: String): DRI? {
val link = this.dfs { it.name == name }?.documentation?.values?.single()?.firstMemberOfTypeOrNull<DocumentationLink>()
return link?.dri
Expand Down

0 comments on commit 4a62823

Please sign in to comment.