Skip to content

Commit

Permalink
Make renderer api nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
romanowski committed Sep 21, 2020
1 parent 8676797 commit 7ee2a72
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/kotlin/com/virtuslab/dokka/site/renderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ import java.net.URI
// this will be rewritten after PR is merged to dokka
open class SiteRenderer(context: DokkaContext) : org.jetbrains.dokka.base.renderers.html.HtmlRenderer(context) {

fun withHtml(context: FlowContent, content: String) {
when (context){
is HTMLTag -> context.unsafe { +content }
else -> context.div { unsafe { +content } }
}
}

override fun buildPageContent(context: FlowContent, page: ContentPage) {
when (page) {
is BaseStaticSiteProcessor.StaticPageNode ->
if (page.hasFrame()) context.buildNavigation(page)
else -> context.buildNavigation(page)
}

fun FlowContent.render(txt: String) {
div { unsafe { +txt } }
}
when (val content = page.content) {
is PartiallyRenderedContent ->
context.render(render(content, page))
withHtml(context, render(content, page))
else -> content.build(context, page)
}
}
Expand Down

0 comments on commit 7ee2a72

Please sign in to comment.