From f89fab1fdcf022b7b6db542a600882732c6ac703 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Mon, 14 Feb 2022 12:11:03 +0300 Subject: [PATCH] Extract a nested custom tags brief block into a separate method --- .../tags/SinceKotlinTagContentProvider.kt | 2 +- .../documentables/DefaultPageCreator.kt | 32 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt b/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt index 5aa3574309..904784c08d 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/tags/SinceKotlinTagContentProvider.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.pages.TextStyle object SinceKotlinTagContentProvider : CustomTagContentProvider { - private val TAG_NAME = "Since Kotlin" + private const val TAG_NAME = "Since Kotlin" override fun DocumentableContentBuilder.contentForDescription( sourceSet: DokkaConfiguration.DokkaSourceSet, diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 0c13a5bea2..c6dc0b8ce0 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -683,21 +683,7 @@ open class DefaultPageCreator( } after(extra = PropertyContainer.empty()) { contentForBrief(it) - - val customTags = it.customTags - if (customTags.isNotEmpty()) { - it.sourceSets.forEach { sourceSet -> - customTags.forEach { (tagName, sourceSetTag) -> - sourceSetTag[sourceSet]?.let { tag -> - customTagContentProviders.forEach { provider -> - with(provider) { - contentForBrief(sourceSet, tag) - } - } - } - } - } - } + contentForCustomTagsBrief(it) } } } @@ -708,6 +694,22 @@ open class DefaultPageCreator( } } + private fun DocumentableContentBuilder.contentForCustomTagsBrief(documentable: Documentable) { + val customTags = documentable.customTags + if (customTags.isEmpty()) return + + documentable.sourceSets.forEach { sourceSet -> + customTags.forEach { (tagName, sourceSetTag) -> + sourceSetTag[sourceSet]?.let { tag -> + customTagContentProviders.forEach { provider -> + with(provider) { + contentForBrief(sourceSet, tag) + } + } + } + } + } + } protected open fun TagWrapper.toHeaderString() = this.javaClass.toGenericString().split('.').last()