Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new tests for KDoc links #3947

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
vmishenev marked this conversation as resolved.
Show resolved Hide resolved
|}
""".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
Loading