From 1ed877e8b51ec586a2976e8088e34d17de82fc52 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Wed, 4 Mar 2020 14:07:57 +0100 Subject: Now signature provider uses new visibility model --- .../src/main/kotlin/signatures/KotlinSignatureProvider.kt | 13 +++++++------ .../base/src/test/resources/expect/test/out/root/fn.html | 2 +- .../base/src/test/resources/expect/test/out/root/index.html | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 3e06dc20..cfca20b0 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -15,6 +15,8 @@ import org.jetbrains.dokka.utilities.DokkaLogger class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider { private val contentBuilder = PageContentBuilder(ctcc, this, logger) + private val ignoredVisibilities = setOf(JavaVisibility.Default, KotlinVisibility.Public) + override fun signature(documentable: Documentable): ContentNode = when (documentable) { is Function -> signature(documentable) is Classlike -> signature(documentable) @@ -25,7 +27,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol) { - platformText(c.visibility) { it.externalDisplayName + " " } + platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } if (c is Class) { text(c.modifier.toString() + " ") } @@ -47,7 +49,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol) { - platformText(f.visibility) { it.externalDisplayName + " " } + platformText(f.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } text(f.modifier.toString().toLowerCase() + " ") text("fun ") f.receiver?.also { @@ -101,12 +103,11 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog text("?") } } - - private fun Collection.filterOnPlatform(platformData: PlatformData) = - this.filter { it.platformData.contains(platformData) } } private fun PageContentBuilder.DocumentableContentBuilder.platformText( value: PlatformDependent, transform: (T) -> String -) = value.entries.forEach { (p, v) -> text(transform(v), platformData = setOf(p)) } \ No newline at end of file +) = value.entries.forEach { (p, v) -> + transform(v).takeIf { it.isNotBlank() }?.also { text(it, platformData = setOf(p)) } +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/test/out/root/fn.html b/plugins/base/src/test/resources/expect/test/out/root/fn.html index cc0ae002..e87d7bc4 100644 --- a/plugins/base/src/test/resources/expect/test/out/root/fn.html +++ b/plugins/base/src/test/resources/expect/test/out/root/fn.html @@ -14,7 +14,7 @@
//root//fn

fn

-public final fun fn() +final fun fn()

Description

Function fn
diff --git a/plugins/base/src/test/resources/expect/test/out/root/index.html b/plugins/base/src/test/resources/expect/test/out/root/index.html index 81f2bcc2..25c65b11 100644 --- a/plugins/base/src/test/resources/expect/test/out/root/index.html +++ b/plugins/base/src/test/resources/expect/test/out/root/index.html @@ -20,7 +20,7 @@ fn - public final fun fn() + final fun fn() Function fn -- cgit