diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-03-31 08:39:01 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-03-31 16:02:09 +0200 |
commit | 6fec129cc61bd2a54f9d1111057c650430426013 (patch) | |
tree | f375410110c17bb3e68723bbbc0f60d382d96fba /core/src | |
parent | 810f3c922fb4f11dc3fbdddee82d919189ed8526 (diff) | |
download | dokka-6fec129cc61bd2a54f9d1111057c650430426013.tar.gz dokka-6fec129cc61bd2a54f9d1111057c650430426013.tar.bz2 dokka-6fec129cc61bd2a54f9d1111057c650430426013.zip |
Make PageContentBuilder to create proper content for all tags
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 00a26d90..fec94537 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -37,9 +37,27 @@ data class PlatformDependent<out T>( yieldAll(map.values) } + val allEntries: Sequence<Pair<PlatformData?, T>> = sequence { + expect?.also { yield(null to it) } + map.forEach { (k, v) -> yield(k to v) } + } + + fun getOrExpect(platform: PlatformData): T? = map[platform] ?: expect + companion object { fun <T> empty(): PlatformDependent<T> = PlatformDependent(emptyMap()) + fun <T> from(platformData: PlatformData, element: T) = PlatformDependent(mapOf(platformData to element)) + + @Suppress("UNCHECKED_CAST") + fun <T> from(pairs: Iterable<Pair<PlatformData?, T>>) = + PlatformDependent( + pairs.filter { it.first != null }.toMap() as Map<PlatformData, T>, + pairs.firstOrNull { it.first == null }?.second + ) + + fun <T> from(vararg pairs: Pair<PlatformData?, T>) = from(pairs.asIterable()) + fun <T> expectFrom(element: T) = PlatformDependent(map = emptyMap(), expect = element) } } @@ -330,12 +348,18 @@ sealed class Projection sealed class Bound : Projection() data class OtherParameter(val name: String) : Bound() object Star : Projection() -data class TypeConstructor(val dri: DRI, val projections: List<Projection>, val modifier: FunctionModifiers = FunctionModifiers.NONE) : Bound() +data class TypeConstructor( + val dri: DRI, + val projections: List<Projection>, + val modifier: FunctionModifiers = FunctionModifiers.NONE +) : Bound() + data class Nullable(val inner: Bound) : Bound() data class Variance(val kind: Kind, val inner: Bound) : Projection() { enum class Kind { In, Out } } -data class PrimitiveJavaType(val name: String): Bound() + +data class PrimitiveJavaType(val name: String) : Bound() object Void : Bound() object JavaObject : Bound() @@ -376,6 +400,7 @@ sealed class JavaVisibility(name: String) : Visibility(name) { } fun <T> PlatformDependent<T>?.orEmpty(): PlatformDependent<T> = this ?: PlatformDependent.empty() + sealed class DocumentableSource(val path: String) class DescriptorDocumentableSource(val descriptor: DeclarationDescriptor) : |