From 18bada290ab8ebdbf6f5e43d9c3415dd5225227d Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 11 Mar 2020 22:01:04 +0100 Subject: Fix nested monospace spans in signature --- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 1 - .../main/kotlin/signatures/KotlinSignatureProvider.kt | 2 +- .../translators/documentables/DefaultPageCreator.kt | 19 +++++++------------ .../main/kotlin/signatures/JavaSignatureProvider.kt | 8 ++++---- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index e687999b..d7b2a912 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -34,7 +34,6 @@ open class HtmlRenderer( node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } node.style.contains(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() } node.style.contains(TextStyle.Block) -> div(additionalClasses) { childrenCallback() } - additionalClasses.isNotBlank() -> span(additionalClasses) { childrenCallback() } else -> childrenCallback() } } diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 98394872..79a398cc 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -77,7 +77,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } } - private fun signature(t: TypeParameter) = contentBuilder.contentFor(t, ContentKind.Main) { + private fun signature(t: TypeParameter) = contentBuilder.contentFor(t) { link(t.name, t.dri) list(t.bounds, prefix = " : ") { signatureForProjection(it) diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 401802eb..79f876bf 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -61,9 +61,7 @@ open class DefaultPageCreator( block("Types", 2, ContentKind.Classlikes, s.classlikes, platformData.toSet()) { link(it.name.orEmpty(), it.dri) group { - group(kind = ContentKind.Symbol) { - +buildSignature(it) - } + +buildSignature(it) group(kind = ContentKind.BriefComment) { text(it.briefDocumentation()) } @@ -72,9 +70,8 @@ open class DefaultPageCreator( block("Functions", 2, ContentKind.Functions, s.functions, platformData.toSet()) { link(it.name, it.dri) group { - group(kind = ContentKind.Symbol) { - +buildSignature(it) - } + +buildSignature(it) + group(kind = ContentKind.BriefComment) { text(it.briefDocumentation()) } @@ -91,18 +88,16 @@ open class DefaultPageCreator( protected open fun contentForClasslike(c: Classlike) = contentBuilder.contentFor(c) { header(1) { text(c.name.orEmpty()) } - group(kind = ContentKind.Symbol) { - +buildSignature(c) - } + +buildSignature(c) + +contentForComments(c) { it !is Property } if (c is WithConstructors) { block("Constructors", 2, ContentKind.Constructors, c.constructors, c.platformData.toSet()) { link(it.name, it.dri) group { - group(kind = ContentKind.Symbol) { - +buildSignature(it) - } + +buildSignature(it) + group(kind = ContentKind.BriefComment) { text(it.briefDocumentation()) } diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index 265e05cd..284d6ab9 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -10,7 +10,7 @@ import org.jetbrains.dokka.model.Enum import org.jetbrains.dokka.model.Function import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode -import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.dokka.pages.TextStyle import org.jetbrains.dokka.utilities.DokkaLogger class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider { @@ -30,7 +30,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge ) } - private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol) { + private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } if (c is Class) { @@ -59,7 +59,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge } } - private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol) { + private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { text(f.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ") val returnType = f.type signatureForProjection(returnType) @@ -77,7 +77,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge text(")") } - private fun signature(t: TypeParameter) = contentBuilder.contentFor(t, ContentKind.Symbol) { + private fun signature(t: TypeParameter) = contentBuilder.contentFor(t) { text(t.name.substringAfterLast(".")) list(t.bounds, prefix = " extends ") { signatureForProjection(it) -- cgit