diff options
5 files changed, 79 insertions, 81 deletions
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 4127796c..26bcdf77 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -171,7 +171,7 @@ interface Kind enum class ContentKind : Kind { Comment, Constructors, Functions, Parameters, Properties, Classlikes, Packages, Symbol, Sample, Main, BriefComment, - Empty, Source, TypeAliases, Cover, Inheritors; + Empty, Source, TypeAliases, Cover, Inheritors, PlatformDependantHint; companion object { private val platformTagged = @@ -185,6 +185,10 @@ enum class TextStyle : Style { Bold, Italic, Strong, Strikethrough, Paragraph, Block, Monospace, Indented } +enum class ContentStyle : Style { + KeyValue +} + object CommentTable: Style fun ContentNode.dfs(predicate: (ContentNode) -> Boolean): ContentNode? = if (predicate(this)) { diff --git a/core/src/main/resources/dokka/styles/style.css b/core/src/main/resources/dokka/styles/style.css index 687a14e1..da9e7d01 100644 --- a/core/src/main/resources/dokka/styles/style.css +++ b/core/src/main/resources/dokka/styles/style.css @@ -89,6 +89,7 @@ box-sizing: border-box; font-weight: bold; white-space: pre; + flex-wrap: wrap; } #nav-submenu > .sideMenuPart { @@ -214,10 +215,9 @@ td:first-child { } .brief { - width: 40vw; - white-space: nowrap; + white-space: pre-wrap; overflow: hidden; - text-overflow: ellipsis; + padding-top: 24px; } h1, h2, h3, h4, h5, h6 { @@ -424,6 +424,7 @@ footer { flex-direction: row; align-items: flex-start; justify-content: flex-end; + height: 24px; } .platform-tags > .platform-tag { @@ -462,7 +463,7 @@ td.content { flex-direction: column; } -.title > a { +.title-row > a { text-decoration: none; font-style: normal; font-weight: 600; @@ -470,7 +471,7 @@ td.content { color: #282E34; } -.title > a:hover { +.title-row > a:hover { color: #5B5DEF; } @@ -536,7 +537,6 @@ td.content { .table { display: flex; flex-direction: column; - flex-direction: column; } .table-row { @@ -547,42 +547,29 @@ td.content { padding: 16px 24px 16px 24px; } -.table-row > .main-subrow { - height: 24px; +.platform-dependant-row { display: grid; - grid-template-columns: 310px auto auto; + padding-top: 8px; } -.table-row > .signature-subrow { +.title-row { display: grid; - grid-template-columns: 310px auto; -} - -.main-subrow > .title { - order: 1; -} - -.main-subrow > .brief { - order: 2; -} - -.main-subrow > .platform-tags { - grid-column-start: 3; + grid-template-columns: auto auto 7em; + width: 100%; } -.main-subrow > * { - order: 4; +.keyValue { + display: grid; } -.signature-subrow > .signatures { - grid-column-start: 2; - display: flex; - flex-direction: column; - margin-top: 5px; -} +@media print, screen and (min-width: 960px) { + .keyValue { + grid-template-columns: 20% auto; + } -.signature-subrow > * { - order: 4; + .title-row { + grid-template-columns: 20% auto 7em; + } } @media print, screen and (max-width: 960px) { @@ -640,7 +627,7 @@ td.content { @media print, screen and (max-width: 480px) { body { - padding: 15px; + padding-right: 15px; } header ul { diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 4f0c1e55..c061cabf 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -128,22 +128,32 @@ open class HtmlRenderer( ?.let { div(classes = "table-row") { it.filter { it.dci.kind != ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let { - div("main-subrow") { + div("main-subrow ${node.style.joinToString { it.toString().decapitalize() }}") { it.filter { platformRestriction == null || platformRestriction in it.platforms } .forEach { when(it.dci.kind){ - ContentKind.Main -> div("title") { - it.build(this, pageContext, platformRestriction) + ContentKind.PlatformDependantHint -> { + div("platform-dependant-row keyValue"){ + div() + div("title"){ + it.build(this, pageContext, platformRestriction) + } + } } - ContentKind.BriefComment, ContentKind.Comment -> div("brief") { - it.build(this, pageContext, platformRestriction) + ContentKind.Main -> { + div("title-row"){ + it.build(this, pageContext, platformRestriction) + div() + if (ContentKind.shouldBePlatformTagged(node.dci.kind) && node.platforms.size == 1) { + createPlatformTags(node) + } else { + div() + } + } } else -> div { it.build(this, pageContext, platformRestriction) } } } - if (ContentKind.shouldBePlatformTagged(node.dci.kind) && node.platforms.size == 1) { - createPlatformTags(node) - } } } it.filter { it.dci.kind == ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let { diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 30ec38bb..313973bf 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -31,7 +31,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog ) } - private fun signature(e: DEnumEntry) = contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace)) + private fun signature(e: DEnumEntry) = contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace)){ + link(e.name, e.dri) + } private fun actualTypealiasedSignature(dri: DRI, name: String, aliasedTypes: PlatformDependent<Bound>) = aliasedTypes.entries.groupBy({ it.value }, { it.key }).map { (bound, platforms) -> diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 9c7abdd9..439da560 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -83,11 +83,9 @@ open class DefaultPageCreator( +contentForScope(p, p.dri, p.platformData) block("Type aliases", 2, ContentKind.TypeAliases, p.typealiases, p.platformData.toSet()) { link(it.name, it.dri, kind = ContentKind.Main) - platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) { + platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) { +buildSignature(it) - } - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) + contentForBrief(it) } } } @@ -99,29 +97,24 @@ open class DefaultPageCreator( ) = contentBuilder.contentFor(s as Documentable) { block("Types", 2, ContentKind.Classlikes, s.classlikes, platformData.toSet()) { link(it.name ?: "", it.dri, kind = ContentKind.Main) - platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) { + platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) { +buildSignature(it) - } - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) + contentForBrief(it) } } block("Functions", 2, ContentKind.Functions, s.functions, platformData.toSet()) { link(it.name, it.dri, kind = ContentKind.Main) - platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) { + platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) { +buildSignature(it) - } - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) + contentForBrief(it) } } block("Properties", 2, ContentKind.Properties, s.properties, platformData.toSet()) { link(it.name, it.dri, kind = ContentKind.Main) - platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) { + platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) { +buildSignature(it) - } - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) + + contentForBrief(it) } } s.safeAs<WithExtraProperties<Documentable>>()?.let { it.extra[InheritorsInfo] }?.let { inheritors -> @@ -174,19 +167,18 @@ open class DefaultPageCreator( c.platformData.toSet() ) { link(it.name, it.dri, kind = ContentKind.Main) - platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) { + platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) { +buildSignature(it) - } - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) + contentForBrief(it) } } } if (c is DEnum) { block("Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet()) { link(it.name, it.dri, kind = ContentKind.Main) - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) + platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) { + +buildSignature(it) + contentForBrief(it) } } } @@ -241,7 +233,7 @@ open class DefaultPageCreator( table(kind = ContentKind.Parameters) { platforms.flatMap { platform -> val receiverRow = receiver.getOrExpect(platform)?.let { - buildGroup(platformData = setOf(platform)) { + buildGroup(platformData = setOf(platform), kind = ContentKind.Parameters, styles = mainStyles + ContentStyle.KeyValue) { text("<receiver>") comment(it.root) } @@ -249,8 +241,8 @@ open class DefaultPageCreator( val paramRows = params.mapNotNull { (_, param) -> param.getOrExpect(platform)?.let { - buildGroup(platformData = setOf(platform)) { - text(it.name) + buildGroup(platformData = setOf(platform), kind = ContentKind.Parameters, styles = mainStyles + ContentStyle.KeyValue) { + text(it.name, kind = ContentKind.Parameters) comment(it.root) } } @@ -272,9 +264,9 @@ open class DefaultPageCreator( platforms.flatMap { platform -> seeAlsoTags.mapNotNull { (_, see) -> see.getOrExpect(platform)?.let { - buildGroup(platformData = setOf(platform)) { - if (it.address != null) link(it.name, it.address!!) - else text(it.name) + buildGroup(platformData = setOf(platform), kind = ContentKind.Comment, styles = mainStyles + ContentStyle.KeyValue) { + if (it.address != null) link(it.name, it.address!!, kind = ContentKind.Comment) + else text(it.name, kind = ContentKind.Comment) comment(it.root) } } @@ -331,6 +323,18 @@ open class DefaultPageCreator( }.children } + protected open fun DocumentableContentBuilder.contentForBrief(content: Documentable) { + content.platformData.forEach { platform -> + val root = content.documentation[platform]?.children?.firstOrNull()?.root + + root?.let { + group(platformData = setOf(platform), kind = ContentKind.BriefComment) { + text(it.docTagSummary(), kind = ContentKind.Comment) + } + } + } + } + protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) { group(kind = ContentKind.Cover) { header(1) { text(f.name) } @@ -350,13 +354,4 @@ open class DefaultPageCreator( } protected open fun TagWrapper.toHeaderString() = this.javaClass.toGenericString().split('.').last() - - //TODO: It isn't platform-aware and produces wrong docs Probably should use platformDependentHint - protected open fun Documentable.briefDocumentation() = " " -// documentation.values -// .firstOrNull() -// ?.children -// ?.firstOrNull() -// ?.root -// ?.docTagSummary() ?: "" } |