aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators/documentables
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-08-26 16:38:37 +0200
committerGitHub <noreply@github.com>2022-08-26 16:38:37 +0200
commit34a8ae166e7220ddf8c3c42fab466234623501e7 (patch)
treed061a5775aa57d1d31ab8efca5f1a36ac7be3fbe /plugins/base/src/main/kotlin/translators/documentables
parentc37c9716857d78589a9e6faba27d2c596f2384de (diff)
downloaddokka-34a8ae166e7220ddf8c3c42fab466234623501e7.tar.gz
dokka-34a8ae166e7220ddf8c3c42fab466234623501e7.tar.bz2
dokka-34a8ae166e7220ddf8c3c42fab466234623501e7.zip
Do not render constructor pages and blocks and for annotation classes (#2642)
Diffstat (limited to 'plugins/base/src/main/kotlin/translators/documentables')
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 44e2728a..7f16c568 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -96,7 +96,12 @@ open class DefaultPageCreator(
}
}
- val constructors = documentables.flatMap { if (it is WithConstructors) it.constructors else emptyList() }
+ val constructors =
+ if (documentables.shouldRenderConstructors()) {
+ documentables.flatMap { (it as? WithConstructors)?.constructors ?: emptyList() }
+ } else {
+ emptyList()
+ }
val classlikes = documentables.flatMap { it.classlikes }
val functions = documentables.flatMap { it.filteredFunctions }
@@ -366,7 +371,7 @@ open class DefaultPageCreator(
group(styles = setOf(ContentStyle.TabbedContent), sourceSets = mainSourcesetData + extensions.sourceSets) {
+contentForComments(documentables)
val csWithConstructor = classlikes.filterIsInstance<WithConstructors>()
- if (csWithConstructor.isNotEmpty()) {
+ if (csWithConstructor.isNotEmpty() && documentables.shouldRenderConstructors()) {
val constructorsToDocumented = csWithConstructor.flatMap { it.constructors }
multiBlock(
"Constructors",
@@ -432,6 +437,11 @@ open class DefaultPageCreator(
}
}
+ // Annotations might have constructors to substitute reflection invocations
+ // and for internal/compiler purposes, but they are not expected to be documented
+ // and instantiated directly under normal circumstances, so constructors should not be rendered.
+ private fun List<Documentable>.shouldRenderConstructors() = !this.any { it is DAnnotation }
+
@Suppress("UNCHECKED_CAST")
private inline fun <reified T : TagWrapper> GroupedTags.withTypeUnnamed(): SourceSetDependent<T> =
(this[T::class] as List<Pair<DokkaSourceSet, T>>?)?.toMap().orEmpty()