aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-03-26 17:17:17 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-03-31 14:45:37 +0200
commitc29d660242027eb23ff9c5d7c176eb188abcef74 (patch)
treee1189c600012f98f93815ee196f0e21498c50c7a /plugins/base/src/main/kotlin/renderers
parenta8f8ac319de698528c04db9ebeceb986a8ced7f0 (diff)
downloaddokka-c29d660242027eb23ff9c5d7c176eb188abcef74.tar.gz
dokka-c29d660242027eb23ff9c5d7c176eb188abcef74.tar.bz2
dokka-c29d660242027eb23ff9c5d7c176eb188abcef74.zip
Added platformTags rendering. Provided simple css classes. TODO adjust css, add onHover
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt36
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 53222325..439a8fbe 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -27,6 +27,7 @@ open class HtmlRenderer(
) {
val additionalClasses = node.style.joinToString(" ") { it.toString().toLowerCase() }
return when {
+ ContentKind.shouldBePlatformTagged(node.dci.kind) -> wrapPlatformTagged(node, pageContext) { childrenCallback() }
node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() }
node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() }
node.style.contains(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() }
@@ -35,6 +36,23 @@ open class HtmlRenderer(
}
}
+ private fun FlowContent.wrapPlatformTagged(
+ node: ContentGroup,
+ pageContext: ContentPage,
+ childrenCallback: FlowContent.() -> Unit
+ ) {
+ div("platform-tagged"){
+ node.platforms.forEach {
+ div("platform-tag ${it.platformType.name}"){
+ text(it.platformType.key.toUpperCase())
+ }
+ }
+ div("content"){
+ childrenCallback()
+ }
+ }
+ }
+
override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) {
val distinct = content.platforms.map {
it to createHTML(prettyPrint = false).div {
@@ -97,6 +115,22 @@ open class HtmlRenderer(
}
}
+ private fun TR.buildPlatformTags(
+ node: ContentGroup
+ ) {
+ if(ContentKind.shouldBePlatformTagged(node.dci.kind)) {
+ td {
+ div("platform-tagged"){
+ node.platforms.forEach {
+ div(("platform-tag ${it.platformType.key}")) {
+ text(it.platformType.key.toUpperCase())
+ }
+ }
+ }
+ }
+ }
+ }
+
override fun FlowContent.buildTable(
node: ContentTable,
pageContext: ContentPage,
@@ -122,12 +156,14 @@ open class HtmlRenderer(
it.build(this, pageContext, platformRestriction)
}
}
+ buildPlatformTags(it)
}
}
}
}
}
+
override fun FlowContent.buildHeader(level: Int, content: FlowContent.() -> Unit) {
when (level) {
1 -> h1(block = content)