aboutsummaryrefslogtreecommitdiff
path: root/src/Locations
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-26 21:17:13 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-26 21:17:13 +0100
commit4b61be354510cf88fed33860c987bd210502e91d (patch)
tree7b7bb9f317cf0edfe1cdee404b6b34ff02e39054 /src/Locations
parent11bc0b1ceef4340e7587b85b647010faf171131b (diff)
downloaddokka-4b61be354510cf88fed33860c987bd210502e91d.tar.gz
dokka-4b61be354510cf88fed33860c987bd210502e91d.tar.bz2
dokka-4b61be354510cf88fed33860c987bd210502e91d.zip
don't generate redundant links that lead to the same page with no anchor (e.g. receiver type in extension functions)
Diffstat (limited to 'src/Locations')
-rw-r--r--src/Locations/FoldersLocationService.kt2
-rw-r--r--src/Locations/LocationService.kt3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/Locations/FoldersLocationService.kt b/src/Locations/FoldersLocationService.kt
index 2e9a9cd5..e85c2c98 100644
--- a/src/Locations/FoldersLocationService.kt
+++ b/src/Locations/FoldersLocationService.kt
@@ -4,7 +4,7 @@ import java.io.File
public fun FoldersLocationService(root: String): FoldersLocationService = FoldersLocationService(File(root), "")
public class FoldersLocationService(val root: File, val extension: String) : FileLocationService {
- override fun withExtension(newExtension: String): LocationService {
+ override fun withExtension(newExtension: String): FileLocationService {
return if (extension.isEmpty()) FoldersLocationService(root, newExtension) else this
}
diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt
index cb05535a..2c93ba8f 100644
--- a/src/Locations/LocationService.kt
+++ b/src/Locations/LocationService.kt
@@ -23,6 +23,9 @@ public data class FileLocation(val file: File): Location {
if (other !is FileLocation) {
throw IllegalArgumentException("$other is not a FileLocation")
}
+ if (file.path.substringBeforeLast(".") == other.file.path.substringBeforeLast(".") && anchor == null) {
+ return "."
+ }
val ownerFolder = file.getParentFile()!!
val relativePath = ownerFolder.getRelativePath(other.file).path
return if (anchor == null) relativePath else relativePath + "#" + anchor