aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt6
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt6
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt12
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt12
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt23
5 files changed, 35 insertions, 24 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
index a9b99840..58c601bc 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
@@ -66,7 +66,7 @@ class ActualTypealiasAdder : DocumentableTransformer {
elements.map { element ->
if (element.expectPresentInSet != null) {
typealiases[element.dri]?.let { ta ->
- element.withNewExtras(element.extra + ActualTypealias(ta.underlyingType)).let {
+ val merged = element.withNewExtras(element.extra + ActualTypealias(ta.underlyingType)).let {
when(it) {
is DClass -> it.copy(sourceSets = element.sourceSets + ta.sourceSets)
is DEnum -> it.copy(sourceSets = element.sourceSets + ta.sourceSets)
@@ -75,7 +75,9 @@ class ActualTypealiasAdder : DocumentableTransformer {
is DAnnotation -> it.copy(sourceSets = element.sourceSets + ta.sourceSets)
else -> throw IllegalStateException("${it::class.qualifiedName} ${it.name} cannot have copy its sourceSets")
}
- } as T
+ }
+ @Suppress("UNCHECKED_CAST")
+ merged as T
} ?: element
} else {
element
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt
index 6239ad6b..17e3cbcd 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt
@@ -49,7 +49,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab
fun mergeClashingElements(elements: List<Pair<T, Set<DokkaConfiguration.DokkaSourceSet>>>): List<T> =
elements.groupBy { it.first.name }.values.flatMap { listOfDocumentableToSSIds ->
- listOfDocumentableToSSIds.map { (documentable, sourceSets) ->
+ val merged = listOfDocumentableToSSIds.map { (documentable, sourceSets) ->
when (documentable) {
is DClass -> documentable.copy(
extra = documentable.extra + ClashingDriIdentifier(
@@ -88,7 +88,9 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab
)
else -> documentable
}
- } as List<T>
+ }
+ @Suppress("UNCHECKED_CAST")
+ merged as List<T>
}
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt
index 4ca3d861..94688799 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt
@@ -35,10 +35,12 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe
packageOptions.firstOrNull { Regex(it.matchingRegex).matches(name) }
}
- val (documentedVisibilities, includeNonPublic) = when {
- packageOpts != null -> packageOpts.documentedVisibilities to packageOpts.includeNonPublic
- else -> globalOptions.documentedVisibilities to globalOptions.includeNonPublic
- }
+ val (documentedVisibilities, includeNonPublic) =
+ @Suppress("DEPRECATION") // for includeNonPublic, preserve backwards compatibility
+ when {
+ packageOpts != null -> packageOpts.documentedVisibilities to packageOpts.includeNonPublic
+ else -> globalOptions.documentedVisibilities to globalOptions.includeNonPublic
+ }
// if `documentedVisibilities` is explicitly overridden by the user (i.e. not default value by reference),
// deprecated `includeNonPublic` should not be taken into account, so that only one setting prevails
@@ -176,7 +178,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe
): Pair<Boolean, List<DProperty>> {
val modifier: (DProperty, Set<DokkaSourceSet>) -> Pair<Boolean, DProperty> =
- { original, filteredPlatforms ->
+ { original, _ ->
val setter = original.setter?.let { filterFunctions(listOf(it), additionalConditionAccessors) }
val getter = original.getter?.let { filterFunctions(listOf(it), additionalConditionAccessors) }
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt
index a1b5052d..2e4b29ff 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt
@@ -6,8 +6,12 @@ import org.jetbrains.dokka.plugability.DokkaContext
class InheritedEntriesDocumentableFilterTransformer(context: DokkaContext) :
SuppressedByConditionDocumentableFilterTransformer(context) {
- override fun shouldBeSuppressed(d: Documentable): Boolean =
- context.configuration.suppressInheritedMembers && (d as? WithExtraProperties<Documentable>)?.extra?.get(
- InheritedMember
- )?.inheritedFrom?.any { entry -> entry.value != null } ?: false
+
+ override fun shouldBeSuppressed(d: Documentable): Boolean {
+ @Suppress("UNCHECKED_CAST")
+ val inheritedMember = (d as? WithExtraProperties<Documentable>)?.extra?.get(InheritedMember)
+ val containsInheritedFrom = inheritedMember?.inheritedFrom?.any { entry -> entry.value != null } ?: false
+
+ return context.configuration.suppressInheritedMembers && containsInheritedFrom
+ }
} \ 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 c38edea8..85b082ef 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
@@ -15,17 +15,18 @@ open class DocTagToContentConverter : CommentsToContentConverter {
dci: DCI,
sourceSets: Set<DokkaSourceSet>,
styles: Set<Style>,
- extra: PropertyContainer<ContentNode>
+ extras: PropertyContainer<ContentNode>
): List<ContentNode> {
fun buildChildren(docTag: DocTag, newStyles: Set<Style> = emptySet(), newExtras: SimpleAttr? = null) =
docTag.children.flatMap {
- buildContent(it, dci, sourceSets, styles + newStyles, newExtras?.let { extra + it } ?: extra)
+ buildContent(it, dci, sourceSets, styles + newStyles, newExtras?.let { extras + it } ?: extras)
}
fun buildTableRows(rows: List<DocTag>, newStyle: Style): List<ContentGroup> =
rows.flatMap {
- buildContent(it, dci, sourceSets, styles + newStyle, extra) as List<ContentGroup>
+ @Suppress("UNCHECKED_CAST")
+ buildContent(it, dci, sourceSets, styles + newStyle, extras) as List<ContentGroup>
}
fun buildHeader(level: Int) =
@@ -70,7 +71,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
is Ul -> buildList(false)
is Ol -> buildList(true, start = docTag.params["start"]?.toInt() ?: 1)
is Li -> listOf(
- ContentGroup(buildChildren(docTag), dci, sourceSets.toDisplaySourceSets(), styles, extra)
+ ContentGroup(buildChildren(docTag), dci, sourceSets.toDisplaySourceSets(), styles, extras)
)
is Dl -> buildList(false, newStyles = setOf(ListStyle.DescriptionList))
is Dt -> listOf(
@@ -98,7 +99,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
dci,
sourceSets.toDisplaySourceSets(),
styles + setOf(TextStyle.Paragraph),
- extra
+ extras
)
)
is A -> listOf(
@@ -147,7 +148,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
dci = dci,
sourceSets = sourceSets.toDisplaySourceSets(),
style = styles,
- extra = extra
+ extra = extras
)
)
is HorizontalRule -> listOf(
@@ -164,7 +165,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
dci,
sourceSets.toDisplaySourceSets(),
styles,
- extra + HtmlContent.takeIf { docTag.params["content-type"] == "html" }
+ extras + HtmlContent.takeIf { docTag.params["content-type"] == "html" }
)
)
is Strikethrough -> buildChildren(docTag, setOf(TextStyle.Strikethrough))
@@ -182,7 +183,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
dci,
sourceSets.toDisplaySourceSets(),
styles,
- extra
+ extras
)
},
buildTableRows(body.filterIsInstance<Tr>(), CommentTable),
@@ -208,7 +209,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
is Tr -> listOf(
ContentGroup(
docTag.children.map {
- ContentGroup(buildChildren(it), dci, sourceSets.toDisplaySourceSets(), styles, extra)
+ ContentGroup(buildChildren(it), dci, sourceSets.toDisplaySourceSets(), styles, extras)
},
dci,
sourceSets.toDisplaySourceSets(),
@@ -230,7 +231,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
dci,
sourceSets.toDisplaySourceSets(),
styles,
- extra = extra
+ extra = extras
)
)
} else {
@@ -242,7 +243,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
dci,
sourceSets.toDisplaySourceSets(),
styles + ContentStyle.Caption,
- extra = extra
+ extra = extras
)
)