@@ -1337,6 +1337,133 @@ class LinkTest : BaseAbstractTest() {
13371337 }
13381338 }
13391339
1340+ @Test
1341+ fun `should resolve KDoc links in the second line of @param tag` () {
1342+ testInline(
1343+ """
1344+ |/src/main/kotlin/Testing.kt
1345+ |package example
1346+ |interface Call
1347+ |/**
1348+ | * @param text some description with reference.
1349+ | * But with a few lines and indent [Call]
1350+ | */
1351+ |fun protocol(text: String) {}
1352+ """ .trimMargin(),
1353+ configuration
1354+ ) {
1355+ documentablesMergingStage = { module ->
1356+ assertEquals(
1357+ listOf (
1358+ " Call" to DRI (" example" , " Call" ),
1359+ ),
1360+ module.getAllLinkDRIFrom(" protocol" )
1361+ )
1362+ }
1363+ }
1364+ }
1365+
1366+ @Test
1367+ fun `should resolve KDoc links in the second line of @constructor tag` () {
1368+ testInline(
1369+ """
1370+ |/src/main/kotlin/Testing.kt
1371+ |package example
1372+ |interface Call
1373+ |/**
1374+ |* @constructor text some description with reference.
1375+ |* But with a few lines and indent [Call]
1376+ |*/
1377+ |class A(val text: String)
1378+ """ .trimMargin(),
1379+ configuration
1380+ ) {
1381+ documentablesMergingStage = { module ->
1382+ assertEquals(
1383+ listOf (
1384+ " Call" to DRI (" example" , " Call" ),
1385+ ),
1386+ module.getAllLinkDRIFrom(" A" )
1387+ )
1388+ }
1389+ }
1390+ }
1391+
1392+ @Test
1393+ fun `should resolve KDoc links in the second level of a list` () {
1394+ testInline(
1395+ """
1396+ |/src/main/kotlin/Testing.kt
1397+ |package example
1398+ |interface IllegalTimeZoneException
1399+ |interface UTC
1400+ |
1401+ |/**
1402+ | * ...
1403+ | * How exactly the time zone is acquired is system-dependent. The current implementation:
1404+ | * - JVM: `java.time.ZoneId.systemDefault()` is queried.
1405+ | * - Kotlin/Native:
1406+ | * - Darwin: first, `NSTimeZone.resetSystemTimeZone` is called to clear the cache of the system timezone.
1407+ | * Then, `NSTimeZone.systemTimeZone.name` is used to obtain the up-to-date timezone name.
1408+ | * - Linux: this function checks the `/etc/localtime` symbolic link.
1409+ | * If the link is missing, [UTC] is used.
1410+ | * If the file is not a link but a plain file,
1411+ | * the contents of `/etc/timezone` are additionally checked for the timezone name.
1412+ | * [IllegalTimeZoneException] is thrown if the timezone name cannot be determined
1413+ | * or is invalid.
1414+ | * ...
1415+ | */
1416+ |fun currentSystemDefault(g) {}
1417+ """ .trimMargin(),
1418+ configuration
1419+ ) {
1420+ documentablesMergingStage = { module ->
1421+ assertEquals(
1422+ listOf (
1423+ " UTC" to DRI (" example" , " UTC" ),
1424+ " IllegalTimeZoneException" to DRI (" example" , " IllegalTimeZoneException" ),
1425+ ),
1426+ module.getAllLinkDRIFrom(" currentSystemDefault" )
1427+ )
1428+ }
1429+ }
1430+ }
1431+
1432+ @Test
1433+ @OnlyDescriptors(" #3385" )
1434+ fun `should resolve KDoc links that goes after markdown blocks` () {
1435+ testInline(
1436+ """
1437+ |/src/main/kotlin/Testing.kt
1438+ |package example
1439+ |interface JavaNetCookieJar
1440+ |
1441+ |/**
1442+ | * Markdown syntax ```code```
1443+ | * This references doesn't work: [System.currentTimeMillis] and [JavaNetCookieJar].
1444+ | */
1445+ |fun saveFromResponse(url: String)
1446+ """ .trimMargin(),
1447+ configuration
1448+ ) {
1449+ documentablesMergingStage = { module ->
1450+ assertEquals(
1451+ listOf (
1452+ " System.currentTimeMillis" to DRI (
1453+ " java.lang" , " System" , Callable (
1454+ " currentTimeMillis" ,
1455+ receiver = null ,
1456+ params = emptyList()
1457+ )
1458+ ),
1459+ " JavaNetCookieJar" to DRI (" example" , " JavaNetCookieJar" ),
1460+ ),
1461+ module.getAllLinkDRIFrom(" saveFromResponse" )
1462+ )
1463+ }
1464+ }
1465+ }
1466+
13401467 private fun DModule.getLinkDRIFrom (name : String ): DRI ? {
13411468 val doc = this .dfs { it.name == name }?.documentation?.values?.single()
13421469 ? : throw IllegalStateException (" Can't find documentation for declaration '$name '" )
0 commit comments