aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-11-05 15:02:35 +0100
committerKamil Doległo <kamilok1965@interia.pl>2019-11-05 18:15:17 +0100
commit00b314f12a05e3bbda805d0ae49c34f5542298b4 (patch)
tree5cea8950aa1a14cdbfa1ba3c99fdff8039be9a9c
parent51502a37aaedd97d92ad9f794c6918b18707d35d (diff)
downloaddokka-00b314f12a05e3bbda805d0ae49c34f5542298b4.tar.gz
dokka-00b314f12a05e3bbda805d0ae49c34f5542298b4.tar.bz2
dokka-00b314f12a05e3bbda805d0ae49c34f5542298b4.zip
Initial commit for navigation, rebase when locationProvider is fixed
-rw-r--r--core/src/main/kotlin/renderers/DefaultRenderer.kt5
-rw-r--r--core/src/main/kotlin/renderers/HtmlRenderer.kt8
2 files changed, 8 insertions, 5 deletions
diff --git a/core/src/main/kotlin/renderers/DefaultRenderer.kt b/core/src/main/kotlin/renderers/DefaultRenderer.kt
index c5c12598..a92273ef 100644
--- a/core/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/core/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -9,7 +9,7 @@ abstract class DefaultRenderer(val fileWriter: FileWriter, val locationProvider:
protected abstract fun buildNewLine(): String
protected abstract fun buildLink(text: String, address: String): String
protected abstract fun buildCode(code: String): String
- protected abstract fun buildNavigation(): String // TODO
+ protected abstract fun buildNavigation(page: PageNode): String
protected open fun buildText(text: String): String = text
protected open fun buildHeader(level: Int, content: List<ContentNode>, pageContext: PageNode): String = buildHeader(level, content.joinToString { it.build(pageContext) })
protected open fun buildGroup(children: List<ContentNode>, pageContext: PageNode): String = children.joinToString { it.build(pageContext) }
@@ -33,8 +33,7 @@ abstract class DefaultRenderer(val fileWriter: FileWriter, val locationProvider:
else -> ""
}
- protected open fun buildPageContent(page: PageNode): String =
- /*buildHeader(1, page.name) + */ page.content.joinToString("\n") { it.build(page) }
+ protected open fun buildPageContent(page: PageNode): String = buildNavigation(page) + page.content.joinToString("\n") { it.build(page) }
protected open fun renderPage(page: PageNode) = fileWriter.write(locationProvider.resolve(page), buildPageContent(page), "")
diff --git a/core/src/main/kotlin/renderers/HtmlRenderer.kt b/core/src/main/kotlin/renderers/HtmlRenderer.kt
index ce0e6b73..065b669a 100644
--- a/core/src/main/kotlin/renderers/HtmlRenderer.kt
+++ b/core/src/main/kotlin/renderers/HtmlRenderer.kt
@@ -23,8 +23,12 @@ open class HtmlRenderer(fileWriter: FileWriter, locationProvider: LocationProvid
override fun buildCode(code: String): String = "<code>$code</code>"
override fun buildText(text: String) = super.buildText(text).htmlEscape()
-
- override fun buildNavigation(): String = "" // TODO implement
+
+ override fun buildNavigation(page: PageNode): String {
+ fun buildNavigationWithContext(page: PageNode, context: PageNode): String =
+ page.parent?.let { buildNavigationWithContext(it, context) }.orEmpty() + "/" + buildLink(page.name, locationProvider.resolve(page, context))
+ return buildNavigationWithContext(page, page)
+ }
override fun buildGroup(children: List<ContentNode>, pageContext: PageNode): String =
children.find { it is ContentLink }?.build(pageContext) + "</td>\n" +