diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-07-17 11:22:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-17 11:22:35 +0200 |
commit | 72541d1f1717e79534d9f24cbc7263bebde24885 (patch) | |
tree | a6bba9bdbc1bc3cca169cab87bc0970571d672a5 /plugins/base | |
parent | 20e06e878ebbe09865ff36d64ff113fd4cff8905 (diff) | |
download | dokka-72541d1f1717e79534d9f24cbc7263bebde24885.tar.gz dokka-72541d1f1717e79534d9f24cbc7263bebde24885.tar.bz2 dokka-72541d1f1717e79534d9f24cbc7263bebde24885.zip |
Hardcode documentation for the synthetic Enum.entries property (#3071)
Diffstat (limited to 'plugins/base')
-rw-r--r-- | plugins/base/src/main/resources/dokka/docs/kdoc/EnumEntries.kt.template | 3 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt | 63 |
2 files changed, 66 insertions, 0 deletions
diff --git a/plugins/base/src/main/resources/dokka/docs/kdoc/EnumEntries.kt.template b/plugins/base/src/main/resources/dokka/docs/kdoc/EnumEntries.kt.template new file mode 100644 index 00000000..20d16421 --- /dev/null +++ b/plugins/base/src/main/resources/dokka/docs/kdoc/EnumEntries.kt.template @@ -0,0 +1,3 @@ +Returns a representation of an immutable list of all enum entries, in the order they're declared. + +This method may be used to iterate over the enum entries. diff --git a/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt index c7e2bc21..9a96ad29 100644 --- a/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt +++ b/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt @@ -918,6 +918,69 @@ val soapXml = node("soap-env:Envelope", soapAttrs, } @Test + fun `should have documentation for synthetic Enum entries property`() { + testInline( + """ + |/src/main/kotlin/test/KotlinEnum.kt + |package test + | + |enum class KotlinEnum { + | FOO, BAR; + |} + """.trimIndent(), + configuration + ) { + documentablesMergingStage = { module -> + val kotlinEnum = module.packages.find { it.name == "test" } + ?.classlikes + ?.single { it.name == "KotlinEnum" } + + checkNotNull(kotlinEnum) + + val entriesProperty = kotlinEnum.properties.single { it.name == "entries" } + val expectedEntriesType = GenericTypeConstructor( + dri = DRI( + packageName = "kotlin.enums", + classNames = "EnumEntries" + ), + projections = listOf( + Invariance( + GenericTypeConstructor( + dri = DRI( + packageName = "test", + classNames = "KotlinEnum" + ), + projections = emptyList() + ) + ) + ) + ) + assertEquals(expectedEntriesType, entriesProperty.type) + + val expectedDocumentation = DocumentationNode(listOf( + Description( + CustomDocTag( + children = listOf( + P(listOf( + Text( + "Returns a representation of an immutable list of all enum entries, " + + "in the order they're declared." + ), + )), + P(listOf( + Text("This method may be used to iterate over the enum entries.") + )) + ), + name = "MARKDOWN_FILE" + ) + ) + )) + assertEquals(expectedDocumentation, entriesProperty.documentation.values.single()) + } + } + } + + @Test fun `should have documentation for synthetic Enum valueOf functions`() { testInline( """ |