aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-01-16 18:45:55 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-01-16 18:45:55 +0100
commit4591cbccbe3bd0afb9c89471c4753a7be80818d0 (patch)
tree48a72393770d090b82c57db7df69843c8e1ef6dd
parent4b75751845b6d63a642cac1017ada30f2549bf14 (diff)
downloaddokka-4591cbccbe3bd0afb9c89471c4753a7be80818d0.tar.gz
dokka-4591cbccbe3bd0afb9c89471c4753a7be80818d0.tar.bz2
dokka-4591cbccbe3bd0afb9c89471c4753a7be80818d0.zip
use same code for calculating page titles in HTML and Jekyll
-rw-r--r--src/Formats/HtmlFormatService.kt34
-rw-r--r--src/Formats/JekyllFormatService.kt2
2 files changed, 20 insertions, 16 deletions
diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt
index a50f2c8b..1ae6a81b 100644
--- a/src/Formats/HtmlFormatService.kt
+++ b/src/Formats/HtmlFormatService.kt
@@ -9,12 +9,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>"
}
@@ -122,23 +125,24 @@ public open class HtmlFormatService(locationService: LocationService,
override fun appendOutlineChildren(to: StringBuilder, nodes: Iterable<DocumentationNode>) {
}
+
override fun appendOutlineHeader(to: StringBuilder, node: DocumentationNode) {
}
+}
- fun getPageTitle(nodes: Iterable<DocumentationNode>): String? {
- val breakdownByLocation = nodes.groupBy { node -> formatPageTitle(node) }
- return breakdownByLocation.keySet().singleOrNull()
- }
+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
+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"
}
-} \ No newline at end of file
+ return path.first().name + " / " + qualifiedName
+}
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