aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--core/src/test/kotlin/model/SourceLinksTest.kt8
-rw-r--r--runners/ant/src/main/kotlin/ant/dokka.kt4
-rw-r--r--runners/gradle-plugin/src/main/kotlin/main.kt4
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt7
5 files changed, 19 insertions, 8 deletions
diff --git a/README.md b/README.md
index f0cca532..92ea9e2a 100644
--- a/README.md
+++ b/README.md
@@ -100,7 +100,7 @@ dokka {
// If provided, Dokka generates "source" links for each declaration.
// Repeat for multiple mappings
linkMapping {
- // Directory relative to the root of the project (where you execute gradle respectively).
+ // Unix based directory relative path to the root of the project (where you execute gradle respectively).
dir = "src/main/kotlin" // or simply "./"
// URL showing where the source code can be accessed through the web browser
@@ -297,7 +297,7 @@ The available configuration options are shown below:
<!-- Source directory -->
<dir>${project.basedir}/src/main/kotlin</dir>
<!-- URL showing where the source code can be accessed through the web browser -->
- <url>https://github.com/me/myrepo</url>
+ <url>https://github.com/cy6erGn0m/vertx3-lang-kotlin/blob/master/src/main/kotlin</url> <!-- //remove src/main/kotlin if you use "./" above -->
<!--Suffix which is used to append the line number to the URL. Use #L for GitHub -->
<urlSuffix>#L</urlSuffix>
</link>
diff --git a/core/src/test/kotlin/model/SourceLinksTest.kt b/core/src/test/kotlin/model/SourceLinksTest.kt
index 1a74506f..0e9b666c 100644
--- a/core/src/test/kotlin/model/SourceLinksTest.kt
+++ b/core/src/test/kotlin/model/SourceLinksTest.kt
@@ -40,7 +40,7 @@ class SourceLinksTest(
private const val sourceLinks = "sourceLinks"
private const val dummy = "dummy.kt"
private const val pathSuffix = "$sourceLinks/$dummy"
- private const val filePath = "$testdata/$pathSuffix/../dummy.kt"
+ private const val filePath = "$testdata/$pathSuffix"
private const val url = "https://example.com"
@Parameterized.Parameters(name = "{index}: {0}, {1}, {2} = {3}")
@@ -59,10 +59,8 @@ class SourceLinksTest(
arrayOf("$testdata/$sourceLinks", "$url/$dummy"),
arrayOf("./$testdata/../$testdata/$sourceLinks", "$url/$dummy")
)
- val allPaths = list +
- // we want to be sure Windows paths work as well
- list.map { arrayOf(it[0].replace('/', '\\'), it[1]) }
- return allPaths.map { arrayOf(it[0].padEnd(maxLength, '_'), url, null, it[1]) } +
+
+ return list.map { arrayOf(it[0].padEnd(maxLength, '_'), url, null, it[1]) } +
listOf(
// check that it also works if url ends with /
arrayOf((File(testdata).absolutePath.removeSuffix("/") + "/").padEnd(maxLength, '_'), "$url/", null, "$url/$pathSuffix"),
diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt
index 79583a1f..b23328e0 100644
--- a/runners/ant/src/main/kotlin/ant/dokka.kt
+++ b/runners/ant/src/main/kotlin/ant/dokka.kt
@@ -111,6 +111,10 @@ class DokkaAntTask: Task() {
}
val sourceLinks = antSourceLinks.map {
val path = it.path ?: throw BuildException("'path' attribute of a <sourceLink> element is required")
+ if (path.contains("\\")) {
+ throw BuildException("'dir' attribute of a <sourceLink> - incorrect value, only Unix based path allowed.")
+ }
+
val url = it.url ?: throw BuildException("'url' attribute of a <sourceLink> element is required")
SourceLinkDefinitionImpl(File(path).canonicalFile.absolutePath, url, it.lineSuffix)
}
diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt
index c0b74695..f4adc1c3 100644
--- a/runners/gradle-plugin/src/main/kotlin/main.kt
+++ b/runners/gradle-plugin/src/main/kotlin/main.kt
@@ -448,7 +448,9 @@ open class LinkMapping : Serializable, DokkaConfiguration.SourceLinkDefinition {
var dir: String
get() = path
set(value) {
- path = value
+ if (value.contains("\\"))
+ throw java.lang.IllegalArgumentException("Incorrect dir property, only Unix based path allowed.")
+ else path = value
}
override var path: String = ""
diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
index 41521388..324703a0 100644
--- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
+++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
@@ -4,6 +4,7 @@ import org.apache.maven.archiver.MavenArchiveConfiguration
import org.apache.maven.archiver.MavenArchiver
import org.apache.maven.execution.MavenSession
import org.apache.maven.plugin.AbstractMojo
+import org.apache.maven.plugin.MojoExecutionException
import org.apache.maven.plugins.annotations.*
import org.apache.maven.project.MavenProject
import org.apache.maven.project.MavenProjectHelper
@@ -125,6 +126,12 @@ abstract class AbstractDokkaMojo : AbstractMojo() {
return
}
+ sourceLinks.forEach {
+ if (it.dir.contains("\\")) {
+ throw MojoExecutionException("Incorrect dir property, only Unix based path allowed.")
+ }
+ }
+
val gen = DokkaGenerator(
MavenDokkaLogger(log),
classpath,