diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-28 16:55:58 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-28 16:55:58 +0100 |
commit | a7a7696ea41a7d54808f6af38322c7ab7ed4ad55 (patch) | |
tree | 333a8069d6b7cc62f3def48debd4dc98e4b9e1c5 /core/src/main/kotlin/Formats | |
parent | 63061739c0a76ce5e7ee75a66af227c7413aa24b (diff) | |
download | dokka-a7a7696ea41a7d54808f6af38322c7ab7ed4ad55.tar.gz dokka-a7a7696ea41a7d54808f6af38322c7ab7ed4ad55.tar.bz2 dokka-a7a7696ea41a7d54808f6af38322c7ab7ed4ad55.zip |
put the most important information required to identify an element in the beginning of the page title
Diffstat (limited to 'core/src/main/kotlin/Formats')
-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() } |