Skip to content

Commit

Permalink
fix appending package-list to external doc links (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy authored Apr 8, 2023
1 parent 8d54412 commit 7e33a1f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ idea {
"externals/kotlin-dokka",
)
)
// exclude .gradle dirs from nested projects (e.g. example/template projects)
// exclude .gradle dirs from nested projects (e.g. example & template projects)
addAll(
layout.projectDirectory.asFile.walk()
.filter { it.isDirectory && it.name == ".gradle" }
Expand Down
6 changes: 4 additions & 2 deletions modules/dokkatoo-plugin/src/main/kotlin/DokkatooBasePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ constructor(
externalDocumentationLinks {
configureEach {
enabled.convention(true)
packageListUrl.convention(url.map { URL(it, "package-list") })
packageListUrl.convention(url.map { it.appendPath("package-list") })
}

create("jdk") {
Expand Down Expand Up @@ -254,6 +254,9 @@ constructor(
@OptIn(ExperimentalSerializationApi::class)
prettyPrintIndent = " "
}

private fun URL.appendPath(value: String): URL =
toURI().resolve("$path/$value").normalize().toURL()
}

@DokkatooInternalApi
Expand Down Expand Up @@ -318,5 +321,4 @@ constructor(
val prepareParameters = "prepareDokkatooParameters".appendFormat()
val prepareModuleDescriptor = "prepareDokkatooModuleDescriptor".appendFormat()
}

}
19 changes: 14 additions & 5 deletions modules/dokkatoo-plugin/src/test/kotlin/DokkatooPluginTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import dev.adamko.dokkatoo.utils.create_
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldEndWith
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.hasPlugin
import org.gradle.kotlin.dsl.withType
import org.gradle.kotlin.dsl.*
import org.gradle.testfixtures.ProjectBuilder

class DokkatooPluginTest : FunSpec({
Expand Down Expand Up @@ -71,7 +68,11 @@ class DokkatooPluginTest : FunSpec({
val extension = project.extensions.getByType<DokkatooExtension>()

context("DokkatooSourceSets") {
val testSourceSet = extension.dokkatooSourceSets.create("Test")
val testSourceSet = extension.dokkatooSourceSets.create_("Test") {
externalDocumentationLinks.create_("gradle") {
url("https://docs.gradle.org/7.6.1/javadoc")
}
}

context("JDK external documentation link") {
val jdkLink = testSourceSet.externalDocumentationLinks.getByName("jdk")
Expand Down Expand Up @@ -100,6 +101,14 @@ class DokkatooPluginTest : FunSpec({
}
}
}

context("external doc links") {
test("package-list url should be appended to Javadoc URL") {
val gradleDocLink = testSourceSet.externalDocumentationLinks.getByName("gradle")
gradleDocLink.packageListUrl.get()
.toString() shouldBe "https://docs.gradle.org/7.6.1/javadoc/package-list"
}
}
}
}
})

0 comments on commit 7e33a1f

Please sign in to comment.