diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-02-16 21:28:16 +0300 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2017-02-23 11:20:13 +0100 |
commit | 7fa258873eab770577879e9721c0864449ba1114 (patch) | |
tree | fefbab3c102c00aa412dff4341c8160714f0c309 /core/src/main/kotlin | |
parent | 2bd8bdf9dc0a8e48ce558b2eed0c8e8fd4883902 (diff) | |
download | dokka-7fa258873eab770577879e9721c0864449ba1114.tar.gz dokka-7fa258873eab770577879e9721c0864449ba1114.tar.bz2 dokka-7fa258873eab770577879e9721c0864449ba1114.zip |
Dokka now can detect and recognize SinceKotlin
Diffstat (limited to 'core/src/main/kotlin')
4 files changed, 27 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index 7896bcd8..1488a4f9 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -59,6 +59,13 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, abstract fun appendText(text: String) + open fun appendSinceKotlin(version: String) { + appendParagraph { + appendText("Available since Kotlin: ") + appendCode { appendText(version) } + } + } + open fun appendSymbol(text: String) { appendText(text) } @@ -284,12 +291,14 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } item.appendOverrides() item.appendDeprecation() + item.appendSinceKotlin() } // All items have exactly the same documentation, so we can use any item to render it val item = items.first() item.details(NodeKind.OverloadGroupNote).forEach { appendContent(it.content) } + appendContent(item.content.summary) item.appendDescription() } @@ -312,6 +321,12 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } } + private fun DocumentationNode.appendSinceKotlin() { + val annotation = sinceKotlin ?: return + val value = annotation.detail(NodeKind.Parameter).detail(NodeKind.Value) + appendSinceKotlin(value.name) + } + private fun DocumentationNode.appendDeprecation() { if (deprecation != null) { val deprecationParameter = deprecation!!.details(NodeKind.Parameter).firstOrNull() diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index afb95fe6..30c1413d 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -200,8 +200,12 @@ class DocumentationBuilder annotated.annotations.forEach { it.build()?.let { annotationNode -> val refKind = when { - it.isDocumented() && annotationNode.isDeprecation() -> RefKind.Deprecation - it.isDocumented() -> RefKind.Annotation + it.isDocumented() -> + when { + annotationNode.isDeprecation() -> RefKind.Deprecation + annotationNode.isSinceKotlin() -> RefKind.SinceKotlin + else -> RefKind.Annotation + } it.isHiddenInDocumentation() -> RefKind.HiddenAnnotation else -> return@forEach } @@ -221,6 +225,8 @@ class DocumentationBuilder fun DocumentationNode.isDeprecation() = name == "Deprecated" || name == "deprecated" + fun DocumentationNode.isSinceKotlin() = name == "SinceKotlin" && kind == NodeKind.Annotation + fun DocumentationNode.appendSourceLink(sourceElement: SourceElement) { appendSourceLink(sourceElement.getPsi(), options.sourceLinks) } diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt index def0f626..83897a3f 100644 --- a/core/src/main/kotlin/Model/DocumentationNode.kt +++ b/core/src/main/kotlin/Model/DocumentationNode.kt @@ -97,6 +97,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 // 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 0165b567..8263cd6a 100644 --- a/core/src/main/kotlin/Model/DocumentationReference.kt +++ b/core/src/main/kotlin/Model/DocumentationReference.kt @@ -18,7 +18,8 @@ enum class RefKind { Annotation, HiddenAnnotation, Deprecation, - TopLevelPage + TopLevelPage, + SinceKotlin } data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: RefKind) { |