aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Locations
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-10-04 06:44:17 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-10-04 06:44:17 +0300
commit712bb8ba9b146c769b84503e332fc449ff942141 (patch)
tree5b9f75b38c9ff2743faf7bf225cd30f86e9b78a9 /core/src/main/kotlin/Locations
parentcbed7d1899481ec60256d9e26d47d75a3974f9ef (diff)
downloaddokka-712bb8ba9b146c769b84503e332fc449ff942141.tar.gz
dokka-712bb8ba9b146c769b84503e332fc449ff942141.tar.bz2
dokka-712bb8ba9b146c769b84503e332fc449ff942141.zip
Take GroupNodes into account when computing node location
Diffstat (limited to 'core/src/main/kotlin/Locations')
-rw-r--r--core/src/main/kotlin/Locations/Location.kt18
1 files changed, 16 insertions, 2 deletions
diff --git a/core/src/main/kotlin/Locations/Location.kt b/core/src/main/kotlin/Locations/Location.kt
index 4448fb99..ccefa6e3 100644
--- a/core/src/main/kotlin/Locations/Location.kt
+++ b/core/src/main/kotlin/Locations/Location.kt
@@ -26,7 +26,7 @@ data class FileLocation(val file: File) : Location {
}
val ownerFolder = file.parentFile!!
val relativePath = ownerFolder.toPath().relativize(other.file.toPath()).toString().replace(File.separatorChar, '/')
- return if (anchor == null) relativePath else relativePath + "#" + anchor
+ return if (anchor == null) relativePath else relativePath + "#" + anchor.urlEncoded()
}
}
@@ -40,8 +40,22 @@ fun relativePathToNode(qualifiedName: List<String>, hasMembers: Boolean): String
}
}
+fun nodeActualQualifier(node: DocumentationNode): List<DocumentationNode> {
+ val topLevelPage = node.references(RefKind.TopLevelPage).singleOrNull()?.to
+ if (topLevelPage != null) {
+ return nodeActualQualifier(topLevelPage)
+ }
+ return node.owner?.let { nodeActualQualifier(it) }.orEmpty() + node
+}
+
+fun relativePathToNode(node: DocumentationNode): String {
+ val qualifier = nodeActualQualifier(node)
+ return relativePathToNode(
+ qualifier.map { it.name },
+ qualifier.last().members.any()
+ )
+}
-fun relativePathToNode(node: DocumentationNode) = relativePathToNode(node.path.map { it.name }, node.members.any())
fun identifierToFilename(path: String): String {
if (path.isEmpty()) return "--root--"