aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers/documentables
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2023-07-03 16:18:43 +0300
committerGitHub <noreply@github.com>2023-07-03 16:18:43 +0300
commitcbd9733d3dd2f52992e98e7cebd072091a572529 (patch)
treed7142fb1c8b83b9f4c2d8abb873f8847c427a0d5 /plugins/base/src/main/kotlin/transformers/documentables
parent12a386bb7185f862a1cbd831e6856c4235953833 (diff)
downloaddokka-cbd9733d3dd2f52992e98e7cebd072091a572529.tar.gz
dokka-cbd9733d3dd2f52992e98e7cebd072091a572529.tar.bz2
dokka-cbd9733d3dd2f52992e98e7cebd072091a572529.zip
Enhance typealias presentation (#3053)
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers/documentables')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt15
1 files changed, 14 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
index e895db60..22fc6e9a 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
@@ -6,6 +6,13 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer
+/**
+ * Since we can not merge [DClasslike] with [DTypeAlias.underlyingType] and [DTypeAlias.extra],
+ * we have this transformer to add [ActualTypealias] extra in expect [DClasslike]
+ *
+ * The transformer should be applied after merging all documentables
+ */
+// TODO assign actual [DTypeAlias.expectPresentInSet] an expect source set, currently, [DTypeAlias.expectPresentInSet] always = null
class ActualTypealiasAdder : DocumentableTransformer {
override fun invoke(original: DModule, context: DokkaContext) = original.generateTypealiasesMap().let { aliases ->
@@ -66,30 +73,36 @@ class ActualTypealiasAdder : DocumentableTransformer {
elements.map { element ->
if (element.expectPresentInSet != null) {
typealiases[element.dri]?.let { ta ->
- val merged = element.withNewExtras(element.extra + ActualTypealias(ta.underlyingType)).let {
+ val actualTypealiasExtra = ActualTypealias(ta.copy(expectPresentInSet = element.expectPresentInSet))
+ val merged = element.withNewExtras(element.extra + actualTypealiasExtra).let {
when (it) {
is DClass -> it.copy(
documentation = element.documentation + ta.documentation,
+ sources = element.sources + ta.sources,
sourceSets = element.sourceSets + ta.sourceSets
)
is DEnum -> it.copy(
documentation = element.documentation + ta.documentation,
+ sources = element.sources + ta.sources,
sourceSets = element.sourceSets + ta.sourceSets
)
is DInterface -> it.copy(
documentation = element.documentation + ta.documentation,
+ sources = element.sources + ta.sources,
sourceSets = element.sourceSets + ta.sourceSets
)
is DObject -> it.copy(
documentation = element.documentation + ta.documentation,
+ sources = element.sources + ta.sources,
sourceSets = element.sourceSets + ta.sourceSets
)
is DAnnotation -> it.copy(
documentation = element.documentation + ta.documentation,
+ sources = element.sources + ta.sources,
sourceSets = element.sourceSets + ta.sourceSets
)