diff options
author | Szymon Świstun <sswistun@virtuslab.com> | 2020-03-11 15:07:56 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-03-17 16:03:36 +0100 |
commit | 7cfdd8a512adb6b8589328610efb5bd56c3c0dd7 (patch) | |
tree | 2044eac2a4b5bc860e31c11a5a6a2063fd16fbf9 /core/src/main | |
parent | 14f0d36f6ec9d192a5c46c2b8267dcb2f1d21aa1 (diff) | |
download | dokka-7cfdd8a512adb6b8589328610efb5bd56c3c0dd7.tar.gz dokka-7cfdd8a512adb6b8589328610efb5bd56c3c0dd7.tar.bz2 dokka-7cfdd8a512adb6b8589328610efb5bd56c3c0dd7.zip |
Add annotations to extra properties
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/model/aditionalExtras.kt | 9 | ||||
-rw-r--r-- | core/src/main/kotlin/model/properties/PropertyContainer.kt | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt index d9587fe3..b0755759 100644 --- a/core/src/main/kotlin/model/aditionalExtras.kt +++ b/core/src/main/kotlin/model/aditionalExtras.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.model +import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy @@ -14,4 +15,12 @@ class AdditionalModifiers(val content: Set<ExtraModifiers>) : ExtraProperty<Docu override fun equals(other: Any?): Boolean = if (other is AdditionalModifiers) other.content == content else false override fun hashCode() = content.hashCode() override val key: ExtraProperty.Key<Documentable, *> = AdditionalKey +} + +class Annotations(val content: List<Annotation>) : ExtraProperty<Documentable> { + companion object : ExtraProperty.Key<Documentable, Annotations> + + override val key: ExtraProperty.Key<Documentable, *> = Annotations + + data class Annotation(val dri: DRI, val params: Map<String, String>) }
\ No newline at end of file diff --git a/core/src/main/kotlin/model/properties/PropertyContainer.kt b/core/src/main/kotlin/model/properties/PropertyContainer.kt index 7fa46ccb..5ea42e42 100644 --- a/core/src/main/kotlin/model/properties/PropertyContainer.kt +++ b/core/src/main/kotlin/model/properties/PropertyContainer.kt @@ -15,9 +15,12 @@ class PropertyContainer<C : Any> internal constructor( } inline fun <reified T : Any> allOfType(): List<T> = map.values.filterIsInstance<T>() + fun <D : C> addAll(vararg extras: ExtraProperty<D>): PropertyContainer<D> = + PropertyContainer(map + extras.map { p -> p.key to p }) companion object { fun <T : Any> empty(): PropertyContainer<T> = PropertyContainer(emptyMap()) + fun <T : Any> withAll(vararg extras: ExtraProperty<T>) = empty<T>().addAll(*extras) } } |