From 1270519a551cd30e452d282247d2d963bc9c25ca Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 23 Feb 2017 11:18:44 +0100 Subject: Refactor SinceKotlin support to a more general "platform" mechanism --- core/src/main/kotlin/Model/DocumentationNode.kt | 5 +++-- core/src/main/kotlin/Model/DocumentationReference.kt | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'core/src/main/kotlin/Model') 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 + 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() + + operator fun get(platform: String): DocumentationNode { + return platformNodes.getOrPut(platform) { + DocumentationNode(platform, Content.Empty, NodeKind.Platform) + } + } +} -- cgit