Skip to content

Commit 43e6081

Browse files
committed
Flag to enable experimental KDoc resolution
1 parent 6ef7e1d commit 43e6081

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/InternalConfiguration.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package org.jetbrains.dokka.analysis.kotlin.symbols.plugin
88
internal object InternalConfiguration {
99
private const val ALLOW_KOTLIN_PACKAGE_PROPERTY = "org.jetbrains.dokka.analysis.allowKotlinPackage"
1010

11+
private const val ENABLE_EXPERIMENTAL_KDOC_RESOLUTION = "org.jetbrains.dokka.analysis.enableExperimentalKDocResolution"
12+
1113
/**
1214
* Allow analysing code in the 'kotlin' package
1315
*
@@ -18,6 +20,14 @@ internal object InternalConfiguration {
1820
val allowKotlinPackage: Boolean
1921
get() = getBooleanProperty(ALLOW_KOTLIN_PACKAGE_PROPERTY)
2022

23+
/**
24+
* Enable experimental KDoc resolution
25+
*
26+
* Default: false
27+
*/
28+
val experimentalKDocResolutionEnabled: Boolean
29+
get() = getBooleanProperty(ENABLE_EXPERIMENTAL_KDOC_RESOLUTION)
30+
2131
private fun getBooleanProperty(propertyName: String): Boolean {
2232
return System.getProperty(propertyName) in setOf("1", "true")
2333
}

dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/KotlinAnalysis.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
2828
import org.jetbrains.kotlin.platform.konan.NativePlatforms
2929
import org.jetbrains.kotlin.platform.wasm.WasmPlatforms
3030
import java.io.File
31-
import java.io.IOException
32-
import java.nio.file.*
33-
import java.nio.file.attribute.BasicFileAttributes
34-
import kotlin.io.path.extension
3531

3632
internal fun Platform.toTargetPlatform() = when (this) {
3733
Platform.wasm -> WasmPlatforms.unspecifiedWasmPlatform
@@ -80,7 +76,9 @@ internal fun createAnalysisSession(
8076
projectDisposable: Disposable = Disposer.newDisposable("StandaloneAnalysisAPISession.project"),
8177
isSampleProject: Boolean = false
8278
): KotlinAnalysis {
83-
enableExperimentalKDocResolution()
79+
if (InternalConfiguration.experimentalKDocResolutionEnabled) {
80+
enableExperimentalKDocResolution()
81+
}
8482

8583
val sourcesModule = mutableMapOf<DokkaConfiguration.DokkaSourceSet, KaSourceModule>()
8684
val isMultiplatformProject = sourceSets.any { it.analysisPlatform != Platform.jvm }

dokka-subprojects/plugin-base/src/test/kotlin/content/kdoc/KDocAmbiguityResolutionTest.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.jetbrains.dokka.pages.ContentPage
2929
import org.jetbrains.dokka.pages.MemberPageNode
3030
import utils.OnlySymbols
3131
import utils.findTestType
32+
import utils.withExperimentalKDocResolution
3233
import kotlin.test.Ignore
3334
import kotlin.test.Test
3435
import kotlin.test.assertEquals
@@ -46,7 +47,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
4647
}
4748

4849
@Test
49-
fun `#3451 ambiguous link to the class`() {
50+
fun `#3451 ambiguous link to the class`() = withExperimentalKDocResolution {
5051
testInline(
5152
"""
5253
|/src/main/kotlin/test/source.kt
@@ -120,7 +121,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
120121
}
121122

122123
@Test
123-
fun `#3451 ambiguous link to function and property`() {
124+
fun `#3451 ambiguous link to function and property`() = withExperimentalKDocResolution {
124125
testInline(
125126
"""
126127
|/src/main/kotlin/test/source.kt
@@ -212,7 +213,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
212213
}
213214

214215
@Test
215-
fun `#3451 ambiguous link with factory functions`() {
216+
fun `#3451 ambiguous link with factory functions`() = withExperimentalKDocResolution {
216217
testInline(
217218
"""
218219
|/src/main/kotlin/test/source.kt
@@ -359,7 +360,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
359360
}
360361

361362
@Test
362-
fun `#3451 ambiguous link to inner class`() {
363+
fun `#3451 ambiguous link to inner class`() = withExperimentalKDocResolution {
363364
testInline(
364365
"""
365366
|/src/main/kotlin/test/source.kt
@@ -411,7 +412,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
411412
}
412413

413414
@Test
414-
fun `#3179 KDoc link to property`() {
415+
fun `#3179 KDoc link to property`() = withExperimentalKDocResolution {
415416
testInline(
416417
"""
417418
|/src/main/kotlin/test/source.kt
@@ -485,7 +486,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
485486
}
486487

487488
@Test
488-
fun `#3179 KDoc link to parameter`() {
489+
fun `#3179 KDoc link to parameter`() = withExperimentalKDocResolution {
489490
testInline(
490491
"""
491492
|/src/main/kotlin/test/source.kt
@@ -536,7 +537,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
536537

537538
@Test
538539
@Ignore("KT-83152 [Analysis API, KDoc] Make class name links on constructors point to the class")
539-
fun `#3604 KDoc reference to class from constructor`() {
540+
fun `#3604 KDoc reference to class from constructor`() = withExperimentalKDocResolution {
540541
testInline(
541542
"""
542543
|/src/main/kotlin/test/source.kt
@@ -604,7 +605,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
604605
}
605606

606607
@Test
607-
fun `#3632 KDoc reference to extension`() {
608+
fun `#3632 KDoc reference to extension`() = withExperimentalKDocResolution {
608609
testInline(
609610
"""
610611
|/src/main/kotlin/test/source.kt
@@ -666,7 +667,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
666667
}
667668

668669
@Test
669-
fun `#3632 KDoc reference to member in extension`() {
670+
fun `#3632 KDoc reference to member in extension`() = withExperimentalKDocResolution {
670671
testInline(
671672
"""
672673
|/src/main/kotlin/test/source.kt
@@ -726,7 +727,7 @@ class KDocAmbiguityResolutionTest : BaseAbstractTest() {
726727
}
727728

728729
@Test
729-
fun `#4327 KDoc reference to properties named the same as constructor parameters`() {
730+
fun `#4327 KDoc reference to properties named the same as constructor parameters`() = withExperimentalKDocResolution {
730731
testInline(
731732
"""
732733
|/src/main/kotlin/test/source.kt

dokka-subprojects/plugin-base/src/test/kotlin/utils/systemProperties.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ internal fun withSinceKotlin(block: () -> Unit): Unit =
2121
internal fun withAllowKotlinPackage(block: () -> Unit): Unit =
2222
DokkaBaseInternalConfiguration.withProperty("org.jetbrains.dokka.analysis.allowKotlinPackage", "true", block)
2323

24+
/**
25+
* This property works only for K2
26+
* Enable experimental KDoc resolution
27+
*/
28+
internal fun withExperimentalKDocResolution(block: () -> Unit): Unit =
29+
DokkaBaseInternalConfiguration.withProperty("org.jetbrains.dokka.analysis.enableExperimentalKDocResolution", "true", block)
30+
2431
internal fun DokkaBaseInternalConfiguration.withProperty(propertyName: String, value: String, block: () -> Unit) {
2532
setProperty(propertyName, value)
2633
try {

0 commit comments

Comments
 (0)