diff --git a/dokka-subprojects/plugin-base/src/main/kotlin/org/jetbrains/dokka/base/signatures/KotlinSignatureProvider.kt b/dokka-subprojects/plugin-base/src/main/kotlin/org/jetbrains/dokka/base/signatures/KotlinSignatureProvider.kt index 8480b92240..fda04f82c3 100644 --- a/dokka-subprojects/plugin-base/src/main/kotlin/org/jetbrains/dokka/base/signatures/KotlinSignatureProvider.kt +++ b/dokka-subprojects/plugin-base/src/main/kotlin/org/jetbrains/dokka/base/signatures/KotlinSignatureProvider.kt @@ -130,7 +130,7 @@ public class KotlinSignatureProvider( sourceSets = setOf(sourceSet) ) { annotationsBlock(c) - c.visibility[sourceSet]?.takeIf { it !in ignoredVisibilities }?.name?.let { keyword("$it ") } + c.visibility[sourceSet]?.takeIf { it !in ignoredVisibilities && it.name.isNotBlank() }?.name?.let { keyword("$it ") } if (c.isExpectActual) keyword(if (sourceSet == c.expectPresentInSet) "expect " else "actual ") if (c is DClass) { val modifier = diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt index 3099400ec8..115c90b140 100644 --- a/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt +++ b/dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt @@ -4,6 +4,7 @@ package signatures +import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jetbrains.dokka.model.DFunction @@ -1094,4 +1095,41 @@ class SignatureTest : BaseAbstractTest() { } } } + + @Test + fun `should not add an empty span with java default visibility`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + documentedVisibilities = setOf( + DokkaConfiguration.Visibility.PUBLIC, + DokkaConfiguration.Visibility.PACKAGE + ) + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + testInline( + """ + |/src/test/JavaAnnotationWithSpace.java + |package test; + | + |@interface JavaAnnotationWithSpace {} + """.trimIndent(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + val signatureHtml = writerPlugin.writer.renderedContent("root/test/-java-annotation-with-space/index.html") + .firstSignature() + .html() + + val expectedSignature = "annotation class JavaAnnotationWithSpace" + + assertEquals(expectedSignature, signatureHtml) + } + } + } }