From a7a7696ea41a7d54808f6af38322c7ab7ed4ad55 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 28 Jan 2016 16:55:58 +0100 Subject: put the most important information required to identify an element in the beginning of the page title --- core/src/main/kotlin/Formats/HtmlFormatService.kt | 29 ++++++++++++++++++---- core/testdata/format/bracket.html | 2 +- core/testdata/format/brokenLink.html | 2 +- core/testdata/format/classWithCompanionObject.html | 2 +- core/testdata/format/codeSpan.html | 2 +- .../crossLanguage/kotlinExtendsJava/Bar.html | 2 +- core/testdata/format/deprecated.package.html | 2 +- core/testdata/format/entity.html | 2 +- core/testdata/format/htmlEscaping.html | 2 +- core/testdata/format/javaDeprecated.html | 2 +- core/testdata/format/javaLinkTag.html | 2 +- core/testdata/format/javaLinkTagWithLabel.html | 2 +- core/testdata/format/javaSeeTag.html | 2 +- core/testdata/format/javaSupertype.html | 2 +- core/testdata/format/linkWithLabel.html | 2 +- core/testdata/format/orderedList.html | 2 +- core/testdata/format/overloads.html | 2 +- core/testdata/format/overloadsWithDescription.html | 2 +- .../format/overloadsWithDifferentDescriptions.html | 2 +- core/testdata/format/parameterAnchor.html | 2 +- core/testdata/format/parenthesis.html | 2 +- core/testdata/format/tripleBackticks.html | 2 +- core/testdata/format/typeLink.html | 2 +- .../format/uninterpretedEmphasisCharacters.html | 2 +- 24 files changed, 47 insertions(+), 28 deletions(-) (limited to 'core') 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): 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 @@ -test / foo +foo - test test / foo
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 @@ -test / f +f - test test / f
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 @@ -test / Klass +Klass - test test / Klass
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 @@ -test / foo +foo - test test / foo
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 @@ -test / test.Bar +Bar - test test / test / Bar
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 @@ -test / root package +root package - test test
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 @@ -test / Bar +Bar - test test / Bar
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 @@ -test / x +x - test test / x
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 @@ -test / Foo.foo +Foo.foo - test test / Foo / foo
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 @@ -test / Foo +Foo - test test / Foo
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 @@ -test / Foo +Foo - test test / Foo
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 @@ -test / Foo +Foo - test test / Foo
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 @@ -test / C.Bar +C.Bar - test test / C / Bar
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 @@ -test / Bar +Bar - test test / Bar
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 @@ -test / Bar +Bar - test test / Bar
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 @@ -test / root package +root package - test test
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 @@ -test / f +f - test test / f
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 @@ -test / f +f - test test / f
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 @@ -test / processFiles +processFiles - test test / processFiles
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 @@ -test / foo +foo - test test / foo
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 @@ -test / f +f - test test / f
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 @@ -test / Bar +Bar - test test / Bar
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 @@ -test / foo +foo - test test / foo
-- cgit