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 | |
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
24 files changed, 47 insertions, 28 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() } diff --git a/core/testdata/format/bracket.html b/core/testdata/format/bracket.html index 1cd8ccd1..f96c6459 100644 --- a/core/testdata/format/bracket.html +++ b/core/testdata/format/bracket.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / foo</title> +<title>foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/foo">foo</a><br/> diff --git a/core/testdata/format/brokenLink.html b/core/testdata/format/brokenLink.html index 2f6d65cc..860ffc26 100644 --- a/core/testdata/format/brokenLink.html +++ b/core/testdata/format/brokenLink.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / f</title> +<title>f - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/f">f</a><br/> diff --git a/core/testdata/format/classWithCompanionObject.html b/core/testdata/format/classWithCompanionObject.html index be9247ea..679420bd 100644 --- a/core/testdata/format/classWithCompanionObject.html +++ b/core/testdata/format/classWithCompanionObject.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Klass</title> +<title>Klass - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-klass/index">Klass</a><br/> diff --git a/core/testdata/format/codeSpan.html b/core/testdata/format/codeSpan.html index ce633e7c..216a15e9 100644 --- a/core/testdata/format/codeSpan.html +++ b/core/testdata/format/codeSpan.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / foo</title> +<title>foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/foo">foo</a><br/> diff --git a/core/testdata/format/crossLanguage/kotlinExtendsJava/Bar.html b/core/testdata/format/crossLanguage/kotlinExtendsJava/Bar.html index e7b139d8..295366b3 100644 --- a/core/testdata/format/crossLanguage/kotlinExtendsJava/Bar.html +++ b/core/testdata/format/crossLanguage/kotlinExtendsJava/Bar.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / test.Bar</title> +<title>Bar - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/test/index">test</a> / <a href="test/test/-bar/index">Bar</a><br/> diff --git a/core/testdata/format/deprecated.package.html b/core/testdata/format/deprecated.package.html index 7658b435..f12cb81e 100644 --- a/core/testdata/format/deprecated.package.html +++ b/core/testdata/format/deprecated.package.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / root package</title> +<title>root package - test</title> </HEAD> <BODY> <a href="test/index">test</a><br/> diff --git a/core/testdata/format/entity.html b/core/testdata/format/entity.html index a939faad..9c778020 100644 --- a/core/testdata/format/entity.html +++ b/core/testdata/format/entity.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Bar</title> +<title>Bar - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-bar/index">Bar</a><br/> diff --git a/core/testdata/format/htmlEscaping.html b/core/testdata/format/htmlEscaping.html index f5b97781..ad8a7bed 100644 --- a/core/testdata/format/htmlEscaping.html +++ b/core/testdata/format/htmlEscaping.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / x</title> +<title>x - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/x">x</a><br/> diff --git a/core/testdata/format/javaDeprecated.html b/core/testdata/format/javaDeprecated.html index b378bf4f..35c0b820 100644 --- a/core/testdata/format/javaDeprecated.html +++ b/core/testdata/format/javaDeprecated.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Foo.foo</title> +<title>Foo.foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-foo/index">Foo</a> / <a href="test/-foo/foo">foo</a><br/> diff --git a/core/testdata/format/javaLinkTag.html b/core/testdata/format/javaLinkTag.html index 1b6921ab..d2b956a1 100644 --- a/core/testdata/format/javaLinkTag.html +++ b/core/testdata/format/javaLinkTag.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Foo</title> +<title>Foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-foo/index">Foo</a><br/> diff --git a/core/testdata/format/javaLinkTagWithLabel.html b/core/testdata/format/javaLinkTagWithLabel.html index aabfbc58..c3685ad1 100644 --- a/core/testdata/format/javaLinkTagWithLabel.html +++ b/core/testdata/format/javaLinkTagWithLabel.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Foo</title> +<title>Foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-foo/index">Foo</a><br/> diff --git a/core/testdata/format/javaSeeTag.html b/core/testdata/format/javaSeeTag.html index a6813df3..e5e17f6d 100644 --- a/core/testdata/format/javaSeeTag.html +++ b/core/testdata/format/javaSeeTag.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Foo</title> +<title>Foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-foo/index">Foo</a><br/> diff --git a/core/testdata/format/javaSupertype.html b/core/testdata/format/javaSupertype.html index 8d626212..b2676459 100644 --- a/core/testdata/format/javaSupertype.html +++ b/core/testdata/format/javaSupertype.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / C.Bar</title> +<title>C.Bar - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-c/index">C</a> / <a href="test/-c/-bar/index">Bar</a><br/> diff --git a/core/testdata/format/linkWithLabel.html b/core/testdata/format/linkWithLabel.html index 75769ffd..32499d6f 100644 --- a/core/testdata/format/linkWithLabel.html +++ b/core/testdata/format/linkWithLabel.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Bar</title> +<title>Bar - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-bar/index">Bar</a><br/> diff --git a/core/testdata/format/orderedList.html b/core/testdata/format/orderedList.html index 9917568f..6b5fa007 100644 --- a/core/testdata/format/orderedList.html +++ b/core/testdata/format/orderedList.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Bar</title> +<title>Bar - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-bar/index">Bar</a><br/> diff --git a/core/testdata/format/overloads.html b/core/testdata/format/overloads.html index 3557f660..58241e56 100644 --- a/core/testdata/format/overloads.html +++ b/core/testdata/format/overloads.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / root package</title> +<title>root package - test</title> </HEAD> <BODY> <a href="test/index">test</a><br/> diff --git a/core/testdata/format/overloadsWithDescription.html b/core/testdata/format/overloadsWithDescription.html index 1ab62981..89bddaa4 100644 --- a/core/testdata/format/overloadsWithDescription.html +++ b/core/testdata/format/overloadsWithDescription.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / f</title> +<title>f - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/f">f</a><br/> diff --git a/core/testdata/format/overloadsWithDifferentDescriptions.html b/core/testdata/format/overloadsWithDifferentDescriptions.html index eba1e0fc..549adbfa 100644 --- a/core/testdata/format/overloadsWithDifferentDescriptions.html +++ b/core/testdata/format/overloadsWithDifferentDescriptions.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / f</title> +<title>f - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/f">f</a><br/> diff --git a/core/testdata/format/parameterAnchor.html b/core/testdata/format/parameterAnchor.html index 717bb0fd..ff9c9317 100644 --- a/core/testdata/format/parameterAnchor.html +++ b/core/testdata/format/parameterAnchor.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / processFiles</title> +<title>processFiles - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/process-files">processFiles</a><br/> diff --git a/core/testdata/format/parenthesis.html b/core/testdata/format/parenthesis.html index b1266fd4..3ae75ccb 100644 --- a/core/testdata/format/parenthesis.html +++ b/core/testdata/format/parenthesis.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / foo</title> +<title>foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/foo">foo</a><br/> diff --git a/core/testdata/format/tripleBackticks.html b/core/testdata/format/tripleBackticks.html index 4fe604c3..b085c67a 100644 --- a/core/testdata/format/tripleBackticks.html +++ b/core/testdata/format/tripleBackticks.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / f</title> +<title>f - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/f">f</a><br/> diff --git a/core/testdata/format/typeLink.html b/core/testdata/format/typeLink.html index ff99090a..23054c8d 100644 --- a/core/testdata/format/typeLink.html +++ b/core/testdata/format/typeLink.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / Bar</title> +<title>Bar - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/-bar/index">Bar</a><br/> diff --git a/core/testdata/format/uninterpretedEmphasisCharacters.html b/core/testdata/format/uninterpretedEmphasisCharacters.html index 00350140..70409577 100644 --- a/core/testdata/format/uninterpretedEmphasisCharacters.html +++ b/core/testdata/format/uninterpretedEmphasisCharacters.html @@ -1,6 +1,6 @@ <HTML> <HEAD> -<title>test / foo</title> +<title>foo - test</title> </HEAD> <BODY> <a href="test/index">test</a> / <a href="test/foo">foo</a><br/> |