aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-06-23 08:59:22 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-06-23 09:24:08 +0200
commitca4622e32326f804a1dd03e03f36e874657442d4 (patch)
tree3dd4f8ffc4f6f0cb1f6a85afe4ddf7da0d68a939 /plugins/base
parent436b58507684e59544114a57896b894fe75fa679 (diff)
downloaddokka-ca4622e32326f804a1dd03e03f36e874657442d4.tar.gz
dokka-ca4622e32326f804a1dd03e03f36e874657442d4.tar.bz2
dokka-ca4622e32326f804a1dd03e03f36e874657442d4.zip
Added fallbacks for samples, params and see also
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt14
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index bc3f79c8..fb8cbf9e 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -246,6 +246,12 @@ open class DefaultPageCreator(
}.children
}
+ private fun Documentable.getPossibleFallbackSourcesets(sourceSet: SourceSetData) =
+ this.sourceSets.filter { it.sourceSetID in sourceSet.dependentSourceSets }
+
+ private fun <V> Map<SourceSetData, V>.fallback(sourceSets: List<SourceSetData>) : V? =
+ sourceSets.firstOrNull { it in this.keys }.let { this[it] }
+
protected open fun contentForComments(
d: Documentable
): List<ContentNode> {
@@ -264,7 +270,8 @@ open class DefaultPageCreator(
val params = tags.withTypeNamed<Param>()
table(kind = ContentKind.Parameters) {
platforms.flatMap { platform ->
- val receiverRow = receiver[platform]?.let {
+ val possibleFallbacks = d.getPossibleFallbackSourcesets(platform)
+ val receiverRow = (receiver[platform] ?: receiver.fallback(possibleFallbacks))?.let {
buildGroup(sourceSets = setOf(platform), kind = ContentKind.Parameters) {
text("<receiver>", styles = mainStyles + ContentStyle.RowTitle)
comment(it.root)
@@ -272,7 +279,7 @@ open class DefaultPageCreator(
}
val paramRows = params.mapNotNull { (_, param) ->
- param[platform]?.let {
+ (param[platform] ?: param.fallback(possibleFallbacks))?.let {
buildGroup(sourceSets = setOf(platform), kind = ContentKind.Parameters) {
text(it.name, kind = ContentKind.Parameters, styles = mainStyles + ContentStyle.RowTitle)
comment(it.root)
@@ -296,8 +303,9 @@ open class DefaultPageCreator(
val seeAlsoTags = tags.withTypeNamed<See>()
table(kind = ContentKind.Sample) {
platforms.flatMap { platform ->
+ val possibleFallbacks = d.getPossibleFallbackSourcesets(platform)
seeAlsoTags.mapNotNull { (_, see) ->
- see[platform]?.let {
+ (see[platform] ?: see.fallback(possibleFallbacks))?.let {
buildGroup(sourceSets = setOf(platform), kind = ContentKind.Comment, styles = mainStyles + ContentStyle.RowTitle) {
if (it.address != null) link(it.name, it.address!!, kind = ContentKind.Comment)
else text(it.name, kind = ContentKind.Comment)