diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 2692928b66..1da8e3d16b 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -275,10 +275,15 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog link(p.name, p.dri, styles = mainStyles + p.stylesIfDeprecated(sourceSet)) operator(": ") signatureForProjection(p.type) - defaultValueAssign(p, sourceSet) + + if (p.isNotMutable()) { + defaultValueAssign(p, sourceSet) + } } } + private fun DProperty.isNotMutable(): Boolean = !isMutable() + private fun DProperty.isMutable(): Boolean { return this.extra[IsVar] != null || this.setter != null } diff --git a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt index c0f1ebfb8b..3497317cf5 100644 --- a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt +++ b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt @@ -373,7 +373,35 @@ class ContentForSignaturesTest : BaseAbstractTest() { pagesTransformationStage = { module -> val page = module.children.single { it.name == "test" } as PackagePageNode page.content.assertNode { - propertySignature(emptyMap(), "protected", "", setOf("lateinit"), "var", "property", "Int", "6") + propertySignature(emptyMap(), "protected", "", setOf("lateinit"), "var", "property", "Int", null) + } + } + } + } + + @Test + fun `should not display default value for mutable property`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |var property: Int = 6 + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } as PackagePageNode + page.content.assertNode { + propertySignature( + annotations = emptyMap(), + visibility = "", + modifier = "", + keywords = setOf(), + preposition = "var", + name = "property", + type = "Int", + value = null + ) } } } diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 08ddf03472..9f024c5bfb 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -176,7 +176,7 @@ fun ContentMatcherBuilder<*>.propertySignature( } } } - if (type != null) { + if (value != null) { +(" = $value") } }