diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-08-04 12:43:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-04 12:43:54 +0200 |
commit | 7b020f000aa7ea868d5d3037e68eaec621ef9972 (patch) | |
tree | cc041fa115272920472204492277b306bc5bcf6e /plugins/base/src/main/kotlin | |
parent | 01cc092fed1b4de81b6b39c147e162575b86dfd0 (diff) | |
download | dokka-7b020f000aa7ea868d5d3037e68eaec621ef9972.tar.gz dokka-7b020f000aa7ea868d5d3037e68eaec621ef9972.tar.bz2 dokka-7b020f000aa7ea868d5d3037e68eaec621ef9972.zip |
Render nested classlikes in navigation (#2597)
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt | 24 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt | 7 |
2 files changed, 18 insertions, 13 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt index 647ba687..958488ef 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt @@ -73,18 +73,28 @@ abstract class NavigationDataProvider { } private fun ContentPage.navigableChildren(): List<NavigationNode> { - return if (this !is ClasslikePageNode) { + return if (this is ClasslikePage) { + return this.navigableChildren() + } else { children .filterIsInstance<ContentPage>() .map { visit(it) } .sortedBy { it.name.toLowerCase() } - } else if (documentables.any { it is DEnum }) { - // no sorting for enum entries, should be the same as in source code - children - .filter { child -> child is WithDocumentables && child.documentables.any { it is DEnumEntry } } - .map { visit(it as ContentPage) } + } + } + + private fun ClasslikePage.navigableChildren(): List<NavigationNode> { + // Classlikes should only have other classlikes as navigable children + val navigableChildren = children + .filterIsInstance<ClasslikePage>() + .map { visit(it) } + + val isEnumPage = documentables.any { it is DEnum } + return if (isEnumPage) { + // no sorting for enum entries, should be the same order as in source code + navigableChildren } else { - emptyList() + navigableChildren.sortedBy { it.name.toLowerCase() } } } } diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index e5183699..87808add 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -49,8 +49,7 @@ class NavigationPage( } } buildLink(node.dri, node.sourceSets.toList()) { - // special condition for Enums as it has children enum entries in navigation - val withIcon = node.icon != null && (node.children.isEmpty() || node.isEnum()) + val withIcon = node.icon != null if (withIcon) { // in case link text is so long that it needs to have word breaks, // and it stretches to two or more lines, make sure the icon @@ -69,10 +68,6 @@ class NavigationPage( node.children.withIndex().forEach { (n, p) -> visit(p, "$navId-$n", renderer) } } } - - private fun NavigationNode.isEnum(): Boolean { - return icon == NavigationNodeIcon.ENUM_CLASS || icon == NavigationNodeIcon.ENUM_CLASS_KT - } } data class NavigationNode( |