diff options
author | vmishenev <vad-mishenev@yandex.ru> | 2021-09-30 05:42:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 05:42:12 +0300 |
commit | 8f97b049f23b8a6950fc41badc544ad1b636636a (patch) | |
tree | ebb4552ef2c190e51e7b6c6226b78f2f50d613c0 /plugins/base/src/main/kotlin/resolvers | |
parent | 16552790069070c6a5435f37523173b1be6a4652 (diff) | |
download | dokka-8f97b049f23b8a6950fc41badc544ad1b636636a.tar.gz dokka-8f97b049f23b8a6950fc41badc544ad1b636636a.tar.bz2 dokka-8f97b049f23b8a6950fc41badc544ad1b636636a.zip |
Fix wrong path to root (#2130)
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers')
-rw-r--r-- | plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt index 2575c204..69a851ed 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt @@ -118,22 +118,25 @@ open class DokkaLocationProvider( "${page::class.simpleName}(${page.name}) does not belong to the current page graph so it is impossible to compute its path" ) - val contextNode = - if (context !is ClasslikePageNode && context?.children?.isEmpty() == true && context.parent() != null) context.parent() else context val nodePath = pathFor(node) - val contextPath = contextNode?.let { pathFor(it) }.orEmpty() + val contextPath = context?.let { pathFor(it) }.orEmpty() + val endedContextPath = if (context?.isIndexPage() == false) + contextPath.toMutableList().also { it.removeLastOrNull() } + else contextPath - val commonPathElements = nodePath.asSequence().zip(contextPath.asSequence()) + val commonPathElements = nodePath.asSequence().zip(endedContextPath.asSequence()) .takeWhile { (a, b) -> a == b }.count() - return (List(contextPath.size - commonPathElements) { ".." } + nodePath.drop(commonPathElements) + - if (node is ClasslikePageNode || node.children.isNotEmpty()) + return (List(endedContextPath.size - commonPathElements) { ".." } + nodePath.drop(commonPathElements) + + if (node.isIndexPage()) listOf(PAGE_WITH_CHILDREN_SUFFIX) else emptyList() ).joinToString("/") } + private fun PageNode.isIndexPage() = this is ClasslikePageNode || children.isNotEmpty() + private fun PageNode.parent() = pageGraphRoot.parentMap[this] private val PageNode.pathName: String |