From ec637955575995011351b106d3a67194d21c4b15 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Mon, 14 Sep 2020 13:49:54 +0200 Subject: Introduce top-level DocTag --- .../pages/annotations/SinceKotlinTransformer.kt | 15 +++++++++++++-- .../pages/comments/DocTagToContentConverter.kt | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'plugins/base/src/main/kotlin/transformers/pages') diff --git a/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt index 7914e88f..acff5ada 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/annotations/SinceKotlinTransformer.kt @@ -1,7 +1,9 @@ package org.jetbrains.dokka.base.transformers.pages.annotations +import org.intellij.markdown.MarkdownElementTypes import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.model.doc.CustomDocTag import org.jetbrains.dokka.model.doc.CustomTagWrapper import org.jetbrains.dokka.model.doc.Text import org.jetbrains.dokka.model.properties.WithExtraProperties @@ -73,10 +75,19 @@ class SinceKotlinTransformer(val context: DokkaContext) : DocumentableTransforme acc.mapValues { if (it.key == sourceSet) it.value.copy( it.value.children + listOf( - CustomTagWrapper(Text(version.dropWhile { it == '"' }.dropLastWhile { it == '"' }), "Since Kotlin") + CustomTagWrapper( + CustomDocTag( + listOf( + Text(version.dropWhile { it == '"' }.dropLastWhile { it == '"' } + ) + ), + name = MarkdownElementTypes.MARKDOWN_FILE.name + ), + "Since Kotlin" + ) ) ) else it.value } } ?: acc } -} \ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt index 51ab0858..0fea6b4f 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.base.transformers.pages.comments +import org.intellij.markdown.MarkdownElementTypes import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.model.properties.PropertyContainer @@ -175,7 +176,24 @@ object DocTagToContentConverter : CommentsToContentConverter { styles ) ) + + is CustomDocTag -> if (docTag.isNonemptyFile()) { + listOf( + ContentGroup( + buildChildren(docTag), + dci, + sourceSets.toDisplaySourceSets(), + styles, + extra = extra + ) + ) + } else { + buildChildren(docTag) + } + else -> buildChildren(docTag) } } + + private fun CustomDocTag.isNonemptyFile() = name == MarkdownElementTypes.MARKDOWN_FILE.name && children.size > 1 } -- cgit