Skip to content

Commit

Permalink
Add overload divider between property overloads as well
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Jul 28, 2022
1 parent 4ce210b commit 888676a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
Expand Up @@ -281,8 +281,7 @@ open class HtmlRenderer(
}.stripDiv()
})

val isPageWithOverloadedFunctions = pageContext is MemberPage
&& pageContext.documentables().let { it.isNotEmpty() && it.all { d -> d is DFunction } }
val isPageWithOverloadedMembers = pageContext is MemberPage && pageContext.documentables().size > 1

val contentOfSourceSet = mutableListOf<ContentNode>()
distinct.onEachIndexed{ index, (_, distinctInstances) ->
Expand All @@ -295,9 +294,9 @@ open class HtmlRenderer(

// content kind main is important for declarations list to avoid double line breaks
if (node.dci.kind == ContentKind.Main && index != distinct.size - 1) {
if (isPageWithOverloadedFunctions) {
// hacky, but there's no other place to modify overloads page atm;
// add some spacing and distinction between function overloads
if (isPageWithOverloadedMembers) {
// add some spacing and distinction between function/property overloads.
// hacky, but there's no other place to modify overloads page atm
contentOfSourceSet.add(createOverloadHeader(it.key))
} else {
contentOfSourceSet.add(ContentBreakLine(it.key))
Expand Down
Expand Up @@ -6,6 +6,10 @@ import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.DokkaLogger

/**
* Merges [MemberPage] elements that have the same name.
* That includes **both** properties and functions.
*/
class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStrategy {
override fun tryMerge(pages: List<PageNode>, path: List<String>): List<PageNode> {
val members = pages.filterIsInstance<MemberPageNode>().takeIf { it.isNotEmpty() } ?: return pages
Expand Down

0 comments on commit 888676a

Please sign in to comment.