aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-10-20 12:43:11 +0200
committerGitHub <noreply@github.com>2022-10-20 12:43:11 +0200
commitcacdcd9739bb4fefb5a92cefd30ec58a172db148 (patch)
tree7c1431bffb9c499ef6517d2f717841587792dd1e
parent41e366da55a272daa6b73414277918cb4b8cccaa (diff)
downloaddokka-cacdcd9739bb4fefb5a92cefd30ec58a172db148.tar.gz
dokka-cacdcd9739bb4fefb5a92cefd30ec58a172db148.tar.bz2
dokka-cacdcd9739bb4fefb5a92cefd30ec58a172db148.zip
Do not render default value for var properties (#2717)
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt7
-rw-r--r--plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt30
-rw-r--r--plugins/base/src/test/kotlin/utils/contentUtils.kt2
3 files changed, 36 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 2692928b..1da8e3d1 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 c0f1ebfb..3497317c 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 08ddf034..9f024c5b 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")
}
}