aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2017-02-23 11:18:44 +0100
committerDmitry Jemerov <yole@jetbrains.com>2017-02-23 12:02:23 +0100
commit1270519a551cd30e452d282247d2d963bc9c25ca (patch)
treea42a39450ac361a25e7e1f901fda1132a428a382 /core/src/main/kotlin/Kotlin
parent7fa258873eab770577879e9721c0864449ba1114 (diff)
downloaddokka-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/Kotlin')
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt34
1 files changed, 24 insertions, 10 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 30c1413d..bcbdf5f4 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -62,6 +62,7 @@ class DocumentationBuilder
val descriptorDocumentationParser: DescriptorDocumentationParser,
val options: DocumentationOptions,
val refGraph: NodeReferenceGraph,
+ val platformNodeRegistry: PlatformNodeRegistry,
val logger: DokkaLogger,
val linkResolver: DeclarationLinkResolver) {
val boringBuiltinClasses = setOf(
@@ -199,21 +200,34 @@ class DocumentationBuilder
fun DocumentationNode.appendAnnotations(annotated: Annotated) {
annotated.annotations.forEach {
it.build()?.let { annotationNode ->
- val refKind = when {
- it.isDocumented() ->
- when {
- annotationNode.isDeprecation() -> RefKind.Deprecation
- annotationNode.isSinceKotlin() -> RefKind.SinceKotlin
- else -> RefKind.Annotation
- }
- it.isHiddenInDocumentation() -> RefKind.HiddenAnnotation
- else -> return@forEach
+ if (annotationNode.isSinceKotlin()) {
+ appendSinceKotlin(annotationNode)
}
- append(annotationNode, refKind)
+ else {
+ val refKind = when {
+ it.isDocumented() ->
+ when {
+ annotationNode.isDeprecation() -> RefKind.Deprecation
+ else -> RefKind.Annotation
+ }
+ it.isHiddenInDocumentation() -> RefKind.HiddenAnnotation
+ else -> return@forEach
+ }
+ append(annotationNode, refKind)
+ }
+
}
}
}
+ fun DocumentationNode.appendSinceKotlin(annotation: DocumentationNode) {
+ var kotlinVersion = annotation.detail(NodeKind.Parameter).detail(NodeKind.Value).name
+ if (kotlinVersion.startsWith('\"') && kotlinVersion.endsWith('\"')) {
+ kotlinVersion = kotlinVersion.substring(1..kotlinVersion.length-2)
+ }
+ append(platformNodeRegistry["Kotlin " + kotlinVersion], RefKind.Platform)
+ }
+
fun DocumentationNode.appendModifiers(descriptor: DeclarationDescriptor) {
val psi = (descriptor as DeclarationDescriptorWithSource).source.getPsi() as? KtModifierListOwner ?: return
KtTokens.MODIFIER_KEYWORDS_ARRAY.filter { it !in knownModifiers }.forEach {