Skip to content

Commit

Permalink
Fix external documentation link default values (#3812)
Browse files Browse the repository at this point in the history
KT-70908
  • Loading branch information
adam-enko authored Oct 1, 2024
1 parent 5b2fd99 commit 29593f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ constructor(
}

maybeCreate("jdk") {
enabled.convention(this@dss.enableJdkDocumentationLink)
enabled.set(this@dss.enableJdkDocumentationLink)
url(this@dss.jdkVersion.map { jdkVersion ->
when {
jdkVersion < 11 -> "https://docs.oracle.com/javase/${jdkVersion}/docs/api/"
Expand All @@ -245,17 +245,17 @@ constructor(
}

maybeCreate("kotlinStdlib") {
enabled.convention(this@dss.enableKotlinStdLibDocumentationLink)
enabled.set(this@dss.enableKotlinStdLibDocumentationLink)
url("https://kotlinlang.org/api/latest/jvm/stdlib/")
}

maybeCreate("androidSdk") {
enabled.convention(this@dss.enableAndroidDocumentationLink)
enabled.set(this@dss.enableAndroidDocumentationLink)
url("https://developer.android.com/reference/kotlin/")
}

maybeCreate("androidX") {
enabled.convention(this@dss.enableAndroidDocumentationLink)
enabled.set(this@dss.enableAndroidDocumentationLink)
url("https://developer.android.com/reference/kotlin/")
packageListUrl("https://developer.android.com/reference/kotlin/androidx/package-list")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,11 @@ constructor(
* Whether to generate external documentation links for Android SDK API reference when
* declarations from it are used.
*
* Only relevant in Android projects, ignored otherwise.
* Only relevant in Android projects, and will be automatically disabled otherwise.
*
* Default is `false`, meaning links will not be generated.
* The default value is automatically determined.
* If [analysisPlatform] is set to [KotlinPlatform.AndroidJVM], then the value will be `true`.
* Otherwise, the value defaults to `false`.
*
* @see externalDocumentationLinks
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,29 @@ class DokkaPluginTest : FunSpec({
gradleDocLink.packageListUrl.get()
.toString() shouldBe "https://docs.gradle.org/7.6.1/javadoc/package-list"
}

test("externalDocumentationLinks should be enabled by default") {
val fooLink = testSourceSet.externalDocumentationLinks.create("foo")
fooLink.enabled.orNull shouldBe true
}

test("kotlinStdlib externalDocumentationLink should be disabled when DokkaSourceSetSpec.enableKotlinStdLibDocumentationLink is disabled") {
testSourceSet.enableKotlinStdLibDocumentationLink.set(false)
val kotlinStdlib = testSourceSet.externalDocumentationLinks.getByName("kotlinStdlib")
kotlinStdlib.enabled.orNull shouldBe false
}

context("Android externalDocumentationLinks should be disabled when DokkaSourceSetSpec.enableAndroidDocumentationLink is disabled") {
testSourceSet.enableAndroidDocumentationLink.set(false)
test("androidSdk") {
val androidSdk = testSourceSet.externalDocumentationLinks.getByName("androidSdk")
androidSdk.enabled.orNull shouldBe false
}
test("androidX") {
val androidX = testSourceSet.externalDocumentationLinks.getByName("androidX")
androidX.enabled.orNull shouldBe false
}
}
}

context("perPackageOptions") {
Expand Down

0 comments on commit 29593f7

Please sign in to comment.