diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-20 14:08:30 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-20 14:08:30 +0100 |
commit | 85a3ae7626810113816fd31a0e26d44d48308ed2 (patch) | |
tree | 837eae154a30f139449f560d5e1afebf113041ee /src/Locations/LocationService.kt | |
parent | ea1f4cc2987536c3ed3df5899e6cec2df890f1e6 (diff) | |
download | dokka-85a3ae7626810113816fd31a0e26d44d48308ed2.tar.gz dokka-85a3ae7626810113816fd31a0e26d44d48308ed2.tar.bz2 dokka-85a3ae7626810113816fd31a0e26d44d48308ed2.zip |
support in-page anchors in locations
Diffstat (limited to 'src/Locations/LocationService.kt')
-rw-r--r-- | src/Locations/LocationService.kt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt index 96cd0c51..500b89f2 100644 --- a/src/Locations/LocationService.kt +++ b/src/Locations/LocationService.kt @@ -4,7 +4,7 @@ import java.io.File public trait Location { val path: String get - fun relativePathTo(other: Location): String + fun relativePathTo(other: Location, anchor: String? = null): String } /** @@ -19,12 +19,13 @@ public data class FileLocation(val file: File): Location { override val path : String get() = file.path - override fun relativePathTo(other: Location): String { + override fun relativePathTo(other: Location, anchor: String?): String { if (other !is FileLocation) { throw IllegalArgumentException("$other is not a FileLocation") } val ownerFolder = file.getParentFile()!! - return ownerFolder.getRelativePath(other.file).path + val relativePath = ownerFolder.getRelativePath(other.file).path + return if (anchor == null) relativePath else relativePath + "#" + anchor } } @@ -62,5 +63,5 @@ public fun identifierToFilename(path: String): String { * Returns relative location between two nodes. Used for relative links in documentation. */ fun LocationService.relativePathToLocation(owner: DocumentationNode, node: DocumentationNode): String { - return location(owner).relativePathTo(location(node)) + return location(owner).relativePathTo(location(node), null) } |