diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2019-11-05 15:23:39 +0100 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2019-11-05 16:14:08 +0100 |
commit | 81e93c295725f3a6ad3a112cf3dff1a6b931b621 (patch) | |
tree | 45d027588f49f814c0a66574b27835db62b9fad2 /core/src | |
parent | 26a7c54ccba7df51d0f8bb33277b8a366bfd28f5 (diff) | |
download | dokka-81e93c295725f3a6ad3a112cf3dff1a6b931b621.tar.gz dokka-81e93c295725f3a6ad3a112cf3dff1a6b931b621.tar.bz2 dokka-81e93c295725f3a6ad3a112cf3dff1a6b931b621.zip |
Fixing typo in location provider
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/resolvers/DefaultLocationProvider.kt | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt b/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt index 65b27779..c5243233 100644 --- a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt +++ b/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt @@ -21,29 +21,25 @@ open class DefaultLocationProvider(private val pageGraphRoot: PageNode, val conf protected open fun pathTo(node: PageNode, context: PageNode?): String { - fun getPath(pathNode: PageNode?, path: MutableList<String> = mutableListOf()): List<String> = - if (pathNode == null || pathNode == pageGraphRoot) - path - else - getPath(pathNode.parent, path.apply { - add(if (node is PackagePageNode) { - node.name - } else { - identifierToFilename(node.name) - }) - }) + fun PageNode.pathName(): String = + if (this is PackagePageNode) name + else identifierToFilename(name) + + fun getPath(pathNode: PageNode?, path: List<String> = mutableListOf()): List<String> = + if (pathNode == null) path + else getPath(pathNode.parent, path + pathNode.pathName() ) val nodePath = getPath(node).reversed() val contextPath = getPath(context).reversed() val commonPathElements = nodePath.zip(contextPath).takeWhile { (a, b) -> a == b }.size - return ( List(contextPath.size - commonPathElements) { ".." } + nodePath.drop(commonPathElements) ).joinToString("/") + - if(node.children.isNotEmpty()) PAGE_WITH_CHILDREN_SUFFIX else "" + return ( List(contextPath.size - commonPathElements) { ".." } + nodePath.drop(commonPathElements) + + if(node.children.isNotEmpty()) listOf(PAGE_WITH_CHILDREN_SUFFIX) else emptyList()).joinToString("/") } private companion object { - const val PAGE_WITH_CHILDREN_SUFFIX = "/index" + const val PAGE_WITH_CHILDREN_SUFFIX = "index" } } |