diff options
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/Formats/HtmlFormatService.kt | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt index f0d7e6c8..6ac2a405 100644 --- a/core/src/main/kotlin/Formats/HtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt @@ -159,12 +159,31 @@ fun getPageTitle(nodes: Iterable<DocumentationNode>): String? { fun formatPageTitle(node: DocumentationNode): String { val path = node.path + val moduleName = path.first().name if (path.size == 1) { - return path.first().name + return moduleName } - val qualifiedName = node.qualifiedName() - if (qualifiedName.length == 0 && path.size == 2) { - return path.first().name + " / root package" + + val qName = qualifiedNameForPageTitle(node) + return qName + " - " + moduleName +} + +private fun qualifiedNameForPageTitle(node: DocumentationNode): String { + if (node.kind == NodeKind.Package) { + var packageName = node.qualifiedName() + if (packageName.isEmpty()) { + packageName = "root package" + } + return packageName + } + + val path = node.path + var pathFromToplevelMember = path.dropWhile { it.kind !in NodeKind.classLike } + if (pathFromToplevelMember.isEmpty()) { + pathFromToplevelMember = path.dropWhile { it.kind != NodeKind.Property && it.kind != NodeKind.Function } + } + if (pathFromToplevelMember.isNotEmpty()) { + return pathFromToplevelMember.map { it.name }.filter { it.length > 0 }.joinToString(".") } - return path.first().name + " / " + qualifiedName + return node.qualifiedName() } |