aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/configuration.kt2
-rw-r--r--core/src/main/kotlin/defaultConfiguration.kt4
-rw-r--r--integration-tests/gradle/projects/it-basic/build.gradle.kts7
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt9
-rw-r--r--plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt5
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt6
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt12
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt2
8 files changed, 27 insertions, 20 deletions
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt
index 4c722a37..2aa252e1 100644
--- a/core/src/main/kotlin/configuration.kt
+++ b/core/src/main/kotlin/configuration.kt
@@ -108,7 +108,7 @@ interface DokkaConfiguration : Serializable {
interface SourceLinkDefinition : Serializable {
val localDirectory: String
- val remoteUrl: String
+ val remoteUrl: URL
val remoteLineSuffix: String?
}
diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt
index f37c1add..8bd2d976 100644
--- a/core/src/main/kotlin/defaultConfiguration.kt
+++ b/core/src/main/kotlin/defaultConfiguration.kt
@@ -49,7 +49,7 @@ data class DokkaModuleDescriptionImpl(
data class SourceLinkDefinitionImpl(
override val localDirectory: String,
- override val remoteUrl: String,
+ override val remoteUrl: URL,
override val remoteLineSuffix: String?
) : DokkaConfiguration.SourceLinkDefinition {
companion object {
@@ -57,7 +57,7 @@ data class SourceLinkDefinitionImpl(
val (path, urlAndLine) = srcLink.split('=')
return SourceLinkDefinitionImpl(
File(path).canonicalPath,
- urlAndLine.substringBefore("#"),
+ URL(urlAndLine.substringBefore("#")),
urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" })
}
}
diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts
index 081197ad..2ef81a6c 100644
--- a/integration-tests/gradle/projects/it-basic/build.gradle.kts
+++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts
@@ -1,4 +1,5 @@
import org.jetbrains.dokka.gradle.DokkaTask
+import java.net.URL
plugins {
kotlin("jvm")
@@ -24,8 +25,10 @@ tasks.withType<DokkaTask> {
sourceLink {
localDirectory.set(file("src/main"))
remoteUrl.set(
- "https://github.com/Kotlin/dokka/tree/master/" +
- "integration-tests/gradle/projects/it-basic/src/main"
+ URL(
+ "https://github.com/Kotlin/dokka/tree/master/" +
+ "integration-tests/gradle/projects/it-basic/src/main"
+ )
)
}
}
diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index c8ef7cbc..da2859d9 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -90,10 +90,10 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
private fun ContentNode.addTable(table: ContentGroup): ContentNode =
when (this) {
is ContentGroup -> {
- if(hasTabbedContent()){
+ if (hasTabbedContent()) {
copy(
children = children.map {
- if(it.hasStyle(ContentStyle.TabbedContent) && it is ContentGroup){
+ if (it.hasStyle(ContentStyle.TabbedContent) && it is ContentGroup) {
it.copy(children = it.children + table)
} else {
it
@@ -123,7 +123,10 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
data class SourceLink(val path: String, val url: String, val lineSuffix: String?, val sourceSetData: DokkaSourceSet) {
constructor(sourceLinkDefinition: DokkaConfiguration.SourceLinkDefinition, sourceSetData: DokkaSourceSet) : this(
- sourceLinkDefinition.localDirectory, sourceLinkDefinition.remoteUrl, sourceLinkDefinition.remoteLineSuffix, sourceSetData
+ sourceLinkDefinition.localDirectory,
+ sourceLinkDefinition.remoteUrl.toExternalForm(),
+ sourceLinkDefinition.remoteLineSuffix,
+ sourceSetData
)
}
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index 40c87b75..f93678a4 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
+import java.net.URL
import java.nio.file.Paths
class LinkableContentTest : AbstractCoreTest() {
@@ -70,7 +71,7 @@ class LinkableContentTest : AbstractCoreTest() {
sourceLinks = listOf(
SourceLinkDefinitionImpl(
localDirectory = "jsMain/kotlin",
- remoteUrl = "https://github.com/user/repo/tree/master/src/jsMain/kotlin",
+ remoteUrl = URL("https://github.com/user/repo/tree/master/src/jsMain/kotlin"),
remoteLineSuffix = "#L"
)
)
@@ -83,7 +84,7 @@ class LinkableContentTest : AbstractCoreTest() {
sourceLinks = listOf(
SourceLinkDefinitionImpl(
localDirectory = "jvmMain/kotlin",
- remoteUrl = "https://github.com/user/repo/tree/master/src/jvmMain/kotlin",
+ remoteUrl = URL("https://github.com/user/repo/tree/master/src/jvmMain/kotlin"),
remoteLineSuffix = "#L"
)
)
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt
index 89ecb5e7..a271e810 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt
@@ -8,6 +8,7 @@ import org.gradle.api.tasks.Optional
import org.jetbrains.dokka.DokkaConfigurationBuilder
import org.jetbrains.dokka.SourceLinkDefinitionImpl
import java.io.File
+import java.net.URL
class GradleSourceLinkBuilder(
@Transient @get:Internal internal val project: Project
@@ -17,8 +18,7 @@ class GradleSourceLinkBuilder(
val localDirectory: Property<File?> = project.objects.safeProperty()
@Input
- val remoteUrl: Property<String> = project.objects.safeProperty<String>()
- .safeConvention("")
+ val remoteUrl: Property<URL?> = project.objects.safeProperty<URL>()
@Optional
@Input
@@ -28,7 +28,7 @@ class GradleSourceLinkBuilder(
override fun build(): SourceLinkDefinitionImpl {
return SourceLinkDefinitionImpl(
localDirectory = localDirectory.getSafe()?.absolutePath ?: project.projectDir.absolutePath,
- remoteUrl = remoteUrl.getSafe(),
+ remoteUrl = checkNotNull(remoteUrl.getSafe()) { "missing remoteUrl on source link" },
remoteLineSuffix = remoteLineSuffix.getSafe()
)
}
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
index 4ab644e7..e48eb0a4 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
@@ -221,19 +221,19 @@ class GradleDokkaSourceSetBuilderTest {
GradleSourceLinkBuilder(project).apply {
this.remoteLineSuffix by "ls1"
this.localDirectory by project.file("p1")
- this.remoteUrl by "u1"
+ this.remoteUrl by URL("https://u1")
})
sourceSet.sourceLink {
it.remoteLineSuffix by "ls2"
it.localDirectory by project.file("p2")
- it.remoteUrl by "u2"
+ it.remoteUrl by URL("https://u2")
}
sourceSet.sourceLink(project.closureOf<GradleSourceLinkBuilder> {
this.remoteLineSuffix by "ls3"
this.localDirectory by project.file("p3")
- this.remoteUrl by "u3"
+ this.remoteUrl by URL("https://u3")
})
assertEquals(
@@ -241,17 +241,17 @@ class GradleDokkaSourceSetBuilderTest {
SourceLinkDefinitionImpl(
remoteLineSuffix = "ls1",
localDirectory = project.file("p1").absolutePath,
- remoteUrl = "u1"
+ remoteUrl = URL("https://u1")
),
SourceLinkDefinitionImpl(
remoteLineSuffix = "ls2",
localDirectory = project.file("p2").absolutePath,
- remoteUrl = "u2"
+ remoteUrl = URL("https://u2")
),
SourceLinkDefinitionImpl(
remoteLineSuffix = "ls3",
localDirectory = project.file("p3").absolutePath,
- remoteUrl = "u3"
+ remoteUrl = URL("https://u3")
)
),
sourceSet.build().sourceLinks,
diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
index 781f7cf2..b95b94c0 100644
--- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
+++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
@@ -203,7 +203,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependenc
skipEmptyPackages = skipEmptyPackages,
skipDeprecated = skipDeprecated,
jdkVersion = jdkVersion,
- sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.path, it.url, it.lineSuffix) }.toSet(),
+ sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.path, URL(it.url), it.lineSuffix) }.toSet(),
perPackageOptions = perPackageOptions.map {
PackageOptionsImpl(
prefix = it.prefix,