diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2017-02-23 11:18:44 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2017-02-23 12:02:23 +0100 |
commit | 1270519a551cd30e452d282247d2d963bc9c25ca (patch) | |
tree | a42a39450ac361a25e7e1f901fda1132a428a382 /core/src/main/kotlin/Model | |
parent | 7fa258873eab770577879e9721c0864449ba1114 (diff) | |
download | dokka-1270519a551cd30e452d282247d2d963bc9c25ca.tar.gz dokka-1270519a551cd30e452d282247d2d963bc9c25ca.tar.bz2 dokka-1270519a551cd30e452d282247d2d963bc9c25ca.zip |
Refactor SinceKotlin support to a more general "platform" mechanism
Diffstat (limited to 'core/src/main/kotlin/Model')
-rw-r--r-- | core/src/main/kotlin/Model/DocumentationNode.kt | 5 | ||||
-rw-r--r-- | core/src/main/kotlin/Model/DocumentationReference.kt | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt index 83897a3f..56c295cd 100644 --- a/core/src/main/kotlin/Model/DocumentationNode.kt +++ b/core/src/main/kotlin/Model/DocumentationNode.kt @@ -48,6 +48,7 @@ enum class NodeKind { Signature, ExternalLink, + Platform, AllTypes, @@ -97,8 +98,8 @@ open class DocumentationNode(val name: String, get() = references(RefKind.Annotation).map { it.to } val deprecation: DocumentationNode? get() = references(RefKind.Deprecation).singleOrNull()?.to - val sinceKotlin: DocumentationNode? - get() = references(RefKind.SinceKotlin).singleOrNull()?.to + val platforms: List<String> + get() = references(RefKind.Platform).map { it.to.name } // TODO: Should we allow node mutation? Model merge will copy by ref, so references are transparent, which could nice fun addReferenceTo(to: DocumentationNode, kind: RefKind) { diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt index 8263cd6a..4f28d7c3 100644 --- a/core/src/main/kotlin/Model/DocumentationReference.kt +++ b/core/src/main/kotlin/Model/DocumentationReference.kt @@ -19,7 +19,7 @@ enum class RefKind { HiddenAnnotation, Deprecation, TopLevelPage, - SinceKotlin + Platform } data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: RefKind) { @@ -71,3 +71,14 @@ class NodeReferenceGraph references.forEach { it.resolve() } } } + +@Singleton +class PlatformNodeRegistry { + private val platformNodes = hashMapOf<String, DocumentationNode>() + + operator fun get(platform: String): DocumentationNode { + return platformNodes.getOrPut(platform) { + DocumentationNode(platform, Content.Empty, NodeKind.Platform) + } + } +} |