aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-04-30 11:42:30 +0200
committerKamil Doległo <kamilok1965@users.noreply.github.com>2020-05-07 14:00:13 +0200
commit652fd907f5bef6dfb87b545158c34d84f2902f06 (patch)
tree006bb4b97372b17745b0fa3ef67d93151b01bbcf /plugins/base/src/main/kotlin
parent31d6374cc7101d7dea24defcd1c03e909420ccb6 (diff)
downloaddokka-652fd907f5bef6dfb87b545158c34d84f2902f06.tar.gz
dokka-652fd907f5bef6dfb87b545158c34d84f2902f06.tar.bz2
dokka-652fd907f5bef6dfb87b545158c34d84f2902f06.zip
Changed html table to div's. Adjusted css to match figma.
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt110
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt86
2 files changed, 79 insertions, 117 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index fbab248a..c53b1b6d 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -30,10 +30,6 @@ 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.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { childrenCallback() }
@@ -43,25 +39,6 @@ open class HtmlRenderer(
}
}
- private fun FlowContent.wrapPlatformTagged(
- node: ContentGroup,
- pageContext: ContentPage,
- childrenCallback: FlowContent.() -> Unit
- ) {
- div("platform-tagged") {
- node.platforms.forEach {
- val targets = it.targets.joinToString(", ")
- div("platform-tag") {
- if( targets.equals("common", ignoreCase = true) ) classes = classes + "common"
- text(it.targets.joinToString(", "))
- }
- }
- div("content") {
- childrenCallback()
- }
- }
- }
-
override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) {
div("platform-hinted") {
attributes["data-platform-hinted"] = "data-platform-hinted"
@@ -85,7 +62,6 @@ open class HtmlRenderer(
}
}
}
-
contents.forEach {
consumer.onTagContentUnsafe { +it.second }
}
@@ -139,42 +115,55 @@ open class HtmlRenderer(
}
}
- private fun TBODY.buildPlatformTaggedRow(
- node: ContentTable,
+ private fun FlowContent.buildRow(
+ node: ContentGroup,
pageContext: ContentPage,
platformRestriction: PlatformData?
) {
- node.children.filter { platformRestriction == null || platformRestriction in it.platforms }.forEach {
- tr("platform-tagged") {
- it.children.forEach {
- td("content") {
- it.build(this, pageContext, platformRestriction)
+ node.children
+ .filter {
+ platformRestriction == null || platformRestriction in it.platforms
+ }
+ .takeIf { it.isNotEmpty() }
+ ?.let {
+ div(classes = "table-row") {
+ it.filter { it.dci.kind != ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let {
+ div("main-subrow") {
+ it.filter { platformRestriction == null || platformRestriction in it.platforms }
+ .forEach {
+ when(it.dci.kind){
+ ContentKind.Main -> div("title") {
+ it.build(this, pageContext, platformRestriction)
+ }
+ ContentKind.BriefComment, ContentKind.Comment -> div("brief") {
+ it.build(this, pageContext, platformRestriction)
+ }
+ else -> div { it.build(this, pageContext, platformRestriction) }
+ }
+ }
+ if (ContentKind.shouldBePlatformTagged(node.dci.kind)) {
+ createPlatformTags(node)
+ }
+ }
}
- }
- td("platform-tagged") {
- it.platforms.forEach {
- div(("platform-tag")) {
- val targets = it.targets.joinToString(", ")
- if( targets.equals("common", ignoreCase = true) ) classes = classes + "common"
- text(it.targets.joinToString(", "))
+ it.filter { it.dci.kind == ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let {
+ div("signature-subrow") {
+ div("signature"){
+ it.first().build(this, pageContext, platformRestriction)
+ }
}
}
}
}
- }
}
- private fun TBODY.buildRow(
- node: ContentTable,
- pageContext: ContentPage,
- platformRestriction: PlatformData?
- ) {
- node.children.filter { platformRestriction == null || platformRestriction in it.platforms }.forEach {
- tr {
- it.children.forEach {
- td {
- it.build(this, pageContext, platformRestriction)
- }
+ private fun FlowContent.createPlatformTags( node: ContentNode ) {
+ div("platform-tags") {
+ node.platforms.forEach {
+ div("platform-tag") {
+ val targets = it.targets.joinToString(", ")
+ if( targets.equals("common", ignoreCase = true) ) classes = classes + "common"
+ text(it.targets.joinToString(", "))
}
}
}
@@ -185,24 +174,9 @@ open class HtmlRenderer(
pageContext: ContentPage,
platformRestriction: PlatformData?
) {
- table(if (node.hasStyle(CommentTable)) "comment-table" else "") {
- thead {
- node.header.forEach {
- tr {
- it.children.forEach {
- th {
- it.build(this@table, pageContext, platformRestriction)
- }
- }
- }
- }
- }
- tbody {
- if (ContentKind.shouldBePlatformTagged(node.dci.kind)) {
- buildPlatformTaggedRow(node, pageContext, platformRestriction)
- } else {
- buildRow(node, pageContext, platformRestriction)
- }
+ div(classes = "table") {
+ node.children.forEach {
+ buildRow(it, pageContext, platformRestriction)
}
}
}
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index c3621d1b..61ec2acf 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -69,7 +69,7 @@ open class DefaultPageCreator(
}
+contentForComments(m)
block("Packages", 2, ContentKind.Packages, m.packages, m.platformData.toSet()) {
- link(it.name, it.dri)
+ link(it.name, it.dri, kind = ContentKind.Main)
}
// text("Index\n") TODO
// text("Link to allpage here")
@@ -82,14 +82,12 @@ open class DefaultPageCreator(
+contentForComments(p)
+contentForScope(p, p.dri, p.platformData)
block("Type aliases", 2, ContentKind.TypeAliases, p.typealiases, p.platformData.toSet()) {
- link(it.name, it.dri)
- group {
- platformDependentHint(it.dri, it.platformData.toSet()) {
- +buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ link(it.name, it.dri, kind = ContentKind.Main)
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ +buildSignature(it)
+ }
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
}
@@ -100,36 +98,30 @@ open class DefaultPageCreator(
platformData: List<PlatformData>
) = contentBuilder.contentFor(s as Documentable) {
block("Types", 2, ContentKind.Classlikes, s.classlikes, platformData.toSet()) {
- link(it.name.orEmpty(), it.dri)
- group {
- platformDependentHint(it.dri, it.platformData.toSet()) {
- +buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ link(it.name ?: "", it.dri, kind = ContentKind.Main)
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ +buildSignature(it)
+ }
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
block("Functions", 2, ContentKind.Functions, s.functions, platformData.toSet()) {
- link(it.name, it.dri)
- group {
- platformDependentHint(it.dri, it.platformData.toSet()) {
- +buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ link(it.name, it.dri, kind = ContentKind.Main)
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ +buildSignature(it)
+ }
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
block("Properties", 2, ContentKind.Properties, s.properties, platformData.toSet()) {
- link(it.name, it.dri)
- group {
- platformDependentHint(it.dri, it.platformData.toSet()) {
- +buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ link(it.name, it.dri, kind = ContentKind.Main)
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ +buildSignature(it)
+ }
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
s.safeAs<WithExtraProperties<Documentable>>()?.let { it.extra[InheritorsInfo] }?.let { inheritors ->
@@ -181,27 +173,23 @@ open class DefaultPageCreator(
c.constructors.filter { it.extra[PrimaryConstructorExtra] == null },
c.platformData.toSet()
) {
- link(it.name, it.dri)
- group {
- platformDependentHint(it.dri, it.platformData.toSet()) {
- +buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ link(it.name, it.dri, kind = ContentKind.Main)
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ +buildSignature(it)
+ }
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
}
if (c is DEnum) {
block("Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet()) {
- link(it.name.orEmpty(), it.dri)
- group {
- platformDependentHint(it.dri, it.platformData.toSet()) {
- +buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
- }
+ link(it.name.orEmpty(), it.dri, kind = ContentKind.Main)
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ +buildSignature(it)
+ }
+ group(kind = ContentKind.BriefComment) {
+ text(it.briefDocumentation())
}
}
}