aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
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
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')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt36
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt46
2 files changed, 59 insertions, 23 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)
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 11f57696..349d9970 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -63,7 +63,9 @@ open class DefaultPageCreator(
}
protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) {
- header(1) { text("Package ${p.name}") }
+ group(p.dri, p.platformData.toSet(), ContentKind.Packages){
+ header(1) { text("Package ${p.name}") }
+ }
+contentForScope(p, p.dri, p.platformData)
}
@@ -99,6 +101,7 @@ open class DefaultPageCreator(
platformDependentHint(it.dri, it.platformData.toSet()) {
+buildSignature(it)
}
+ breakLine()
group(kind = ContentKind.BriefComment) {
text(it.briefDocumentation())
}
@@ -124,11 +127,12 @@ open class DefaultPageCreator(
}
protected open fun contentForClasslike(c: DClasslike) = contentBuilder.contentFor(c) {
- header(1) { text(c.name.orEmpty()) }
- platformDependentHint(c.dri, c.platformData.toSet()) {
- +buildSignature(c)
+ group(c.dri, c.platformData.toSet(), ContentKind.Classlikes){
+ header(1) { text(c.name.orEmpty()) }
+ platformDependentHint(c.dri, c.platformData.toSet()) {
+ +buildSignature(c)
+ }
}
- breakLine()
+contentForComments(c) { it !is Property }
if (c is WithConstructors) {
@@ -140,26 +144,20 @@ open class DefaultPageCreator(
c.platformData.toSet()
) {
link(it.name, it.dri)
- group {
- platformDependentHint(it.dri, it.platformData.toSet()) {
- +buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ platformDependentHint(it.dri, it.platformData.toSet()) {
+ +buildSignature(it)
+ }
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
}
if (c is DEnum) {
- block(
- "Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet()
- ) {
+ block("Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet()) {
link(it.name.orEmpty(), it.dri)
- group {
- +buildSignature(it)
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ +buildSignature(it)
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
}
@@ -196,9 +194,11 @@ open class DefaultPageCreator(
}.children
protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) {
- header(1) { text(f.name) }
- platformDependentHint(f.dri, f.platformData.toSet()) {
- +buildSignature(f)
+ group(f.dri, f.platformData.toSet(), ContentKind.Functions) {
+ header(1) { text(f.name) }
+ platformDependentHint(f.dri, f.platformData.toSet()) {
+ +buildSignature(f)
+ }
}
+contentForComments(f)
}