aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-01-16 19:15:57 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-01-16 19:15:57 +0100
commit0f7f49d4828b618d0f5ea0475d15f7498b61f6de (patch)
treef6effbb2696cf8c4c79e7e3ce21cb36182c9db56
parent5eab453ea82634af9b876bff26227ec2d0e753ca (diff)
parent4591cbccbe3bd0afb9c89471c4753a7be80818d0 (diff)
downloaddokka-0f7f49d4828b618d0f5ea0475d15f7498b61f6de.tar.gz
dokka-0f7f49d4828b618d0f5ea0475d15f7498b61f6de.tar.bz2
dokka-0f7f49d4828b618d0f5ea0475d15f7498b61f6de.zip
Merge branch 'page-titles'
Conflicts: src/Formats/HtmlFormatService.kt
-rw-r--r--src/Formats/HtmlFormatService.kt24
-rw-r--r--src/Formats/HtmlTemplateService.kt7
-rw-r--r--src/Formats/JekyllFormatService.kt2
-rw-r--r--test/data/format/classWithClassObject.html1
-rw-r--r--test/data/format/deprecated.package.html1
-rw-r--r--test/data/format/htmlEscaping.html1
-rw-r--r--test/data/format/overloads.html1
7 files changed, 32 insertions, 5 deletions
diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt
index 859c07e0..9572dde0 100644
--- a/src/Formats/HtmlFormatService.kt
+++ b/src/Formats/HtmlFormatService.kt
@@ -11,12 +11,15 @@ public open class HtmlFormatService(locationService: LocationService,
override public fun formatText(text: String): String {
return text.htmlEscape()
}
+
override fun formatSymbol(text: String): String {
return "<span class=\"symbol\">${formatText(text)}</span>"
}
+
override fun formatKeyword(text: String): String {
return "<span class=\"keyword\">${formatText(text)}</span>"
}
+
override fun formatIdentifier(text: String): String {
return "<span class=\"identifier\">${formatText(text)}</span>"
}
@@ -117,7 +120,7 @@ public open class HtmlFormatService(locationService: LocationService,
override fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
- templateService.appendHeader(to)
+ templateService.appendHeader(to, getPageTitle(nodes))
super<StructuredFormatService>.appendNodes(location, to, nodes)
templateService.appendFooter(to)
}
@@ -144,4 +147,21 @@ public open class HtmlFormatService(locationService: LocationService,
body()
to.appendln("</ul>")
}
-} \ No newline at end of file
+}
+
+fun getPageTitle(nodes: Iterable<DocumentationNode>): String? {
+ val breakdownByLocation = nodes.groupBy { node -> formatPageTitle(node) }
+ return breakdownByLocation.keySet().singleOrNull()
+}
+
+fun formatPageTitle(node: DocumentationNode): String {
+ val path = node.path
+ if (path.size() == 1) {
+ return path.first().name
+ }
+ val qualifiedName = path.drop(1).map { it.name }.filter { it.length() > 0 }.join(".")
+ if (qualifiedName.length() == 0 && path.size() == 2) {
+ return path.first().name + " / root package"
+ }
+ return path.first().name + " / " + qualifiedName
+}
diff --git a/src/Formats/HtmlTemplateService.kt b/src/Formats/HtmlTemplateService.kt
index 5bb03fbd..54bfa300 100644
--- a/src/Formats/HtmlTemplateService.kt
+++ b/src/Formats/HtmlTemplateService.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka
public trait HtmlTemplateService {
- fun appendHeader(to: StringBuilder)
+ fun appendHeader(to: StringBuilder, title: String?)
fun appendFooter(to: StringBuilder)
class object {
@@ -11,9 +11,12 @@ public trait HtmlTemplateService {
to.appendln("</BODY>")
to.appendln("</HTML>")
}
- override fun appendHeader(to: StringBuilder) {
+ override fun appendHeader(to: StringBuilder, title: String?) {
to.appendln("<HTML>")
to.appendln("<HEAD>")
+ if (title != null) {
+ to.appendln("<title>$title</title>")
+ }
if (css != null) {
to.appendln("<link rel=\"stylesheet\" href=\"$css\">")
}
diff --git a/src/Formats/JekyllFormatService.kt b/src/Formats/JekyllFormatService.kt
index 93861113..93ba4704 100644
--- a/src/Formats/JekyllFormatService.kt
+++ b/src/Formats/JekyllFormatService.kt
@@ -15,6 +15,6 @@ public open class JekyllFormatService(locationService: LocationService,
}
protected open fun appendFrontMatter(nodes: Iterable<DocumentationNode>, to: StringBuilder) {
- to.appendln("title: ${nodes.first().name}")
+ to.appendln("title: ${getPageTitle(nodes)}")
}
} \ No newline at end of file
diff --git a/test/data/format/classWithClassObject.html b/test/data/format/classWithClassObject.html
index 79546418..5ccb5b7e 100644
--- a/test/data/format/classWithClassObject.html
+++ b/test/data/format/classWithClassObject.html
@@ -1,5 +1,6 @@
<HTML>
<HEAD>
+<title>test / Klass</title>
</HEAD>
<BODY>
<a href="out.html">test</a>&nbsp;/&nbsp;<a href="out.html"></a>&nbsp;/&nbsp;<a href="out.html">Klass</a><br/>
diff --git a/test/data/format/deprecated.package.html b/test/data/format/deprecated.package.html
index cf563a8b..13a5edb2 100644
--- a/test/data/format/deprecated.package.html
+++ b/test/data/format/deprecated.package.html
@@ -1,5 +1,6 @@
<HTML>
<HEAD>
+<title>test / root package</title>
</HEAD>
<BODY>
<a href="out.html">test</a>&nbsp;/&nbsp;<a href="out.html"></a><br/>
diff --git a/test/data/format/htmlEscaping.html b/test/data/format/htmlEscaping.html
index 4f1409c4..0767d642 100644
--- a/test/data/format/htmlEscaping.html
+++ b/test/data/format/htmlEscaping.html
@@ -1,5 +1,6 @@
<HTML>
<HEAD>
+<title>test / x</title>
</HEAD>
<BODY>
<a href="out.html">test</a>&nbsp;/&nbsp;<a href="out.html"></a>&nbsp;/&nbsp;<a href="out.html">x</a><br/>
diff --git a/test/data/format/overloads.html b/test/data/format/overloads.html
index 9ea88869..92296825 100644
--- a/test/data/format/overloads.html
+++ b/test/data/format/overloads.html
@@ -1,5 +1,6 @@
<HTML>
<HEAD>
+<title>test / root package</title>
</HEAD>
<BODY>
<a href="out.html">test</a>&nbsp;/&nbsp;<a href="out.html"></a><br/>