aboutsummaryrefslogtreecommitdiff
path: root/javadoc/src/main
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-11-04 19:10:38 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-11-04 19:10:38 +0100
commit972118bcffbdf13ebd3aefd495618c4670bdc7b3 (patch)
tree1f72ad07c9e6e8b47fec518fc448fe8aaf18fd90 /javadoc/src/main
parentfb2a0e82254d473216ced358c0d80f80c3738a03 (diff)
downloaddokka-972118bcffbdf13ebd3aefd495618c4670bdc7b3.tar.gz
dokka-972118bcffbdf13ebd3aefd495618c4670bdc7b3.tar.bz2
dokka-972118bcffbdf13ebd3aefd495618c4670bdc7b3.zip
generate @deprecated tags for javadoc
Diffstat (limited to 'javadoc/src/main')
-rw-r--r--javadoc/src/main/kotlin/docbase.kt23
-rw-r--r--javadoc/src/main/kotlin/tags.kt21
2 files changed, 37 insertions, 7 deletions
diff --git a/javadoc/src/main/kotlin/docbase.kt b/javadoc/src/main/kotlin/docbase.kt
index 318aa3d5..cdb4bbc7 100644
--- a/javadoc/src/main/kotlin/docbase.kt
+++ b/javadoc/src/main/kotlin/docbase.kt
@@ -63,12 +63,25 @@ open class DocumentationNodeBareAdapter(override val node: DocumentationNode) :
open class DocumentationNodeAdapter(override val module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeBareAdapter(node), HasModule {
override fun inlineTags(): Array<out Tag> = buildInlineTags(module, this, node.content).toTypedArray()
override fun firstSentenceTags(): Array<out Tag> = buildInlineTags(module, this, node.summary).toTypedArray()
- override fun tags(): Array<out Tag> = (buildInlineTags(module, this, node.content) + node.content.sections.flatMap {
- when (it.tag) {
- ContentTags.SeeAlso -> buildInlineTags(module, this, it)
- else -> emptyList<Tag>()
+
+ override fun tags(): Array<out Tag> {
+ val result = ArrayList<Tag>(buildInlineTags(module, this, node.content))
+ node.content.sections.flatMapTo(result) {
+ when (it.tag) {
+ ContentTags.SeeAlso -> buildInlineTags(module, this, it)
+ else -> emptyList<Tag>()
+ }
}
- }).toTypedArray()
+
+ node.deprecation?.let {
+ val content = it.content.asText()
+ if (content != null) {
+ result.add(TagImpl(this, "deprecated", content))
+ }
+ }
+
+ return result.toTypedArray()
+ }
}
// should be extension property but can't because of KT-8745
diff --git a/javadoc/src/main/kotlin/tags.kt b/javadoc/src/main/kotlin/tags.kt
index 9fdf86f2..5c38bbee 100644
--- a/javadoc/src/main/kotlin/tags.kt
+++ b/javadoc/src/main/kotlin/tags.kt
@@ -4,6 +4,19 @@ import com.sun.javadoc.*
import org.jetbrains.dokka.*
import java.util.*
+class TagImpl(val holder: Doc, val name: String, val text: String): Tag {
+ override fun text(): String? = text
+
+ override fun holder(): Doc = holder
+ override fun firstSentenceTags(): Array<out Tag>? = arrayOf()
+ override fun inlineTags(): Array<out Tag>? = arrayOf()
+
+ override fun name(): String = name
+ override fun kind(): String = name
+
+ override fun position(): SourcePosition = holder.position()
+}
+
class TextTag(val holder: Doc, val content: ContentText) : Tag {
val plainText: String
get() = content.text
@@ -32,8 +45,7 @@ class SeeExternalLinkTagAdapter(val holder: Doc, val link: ContentExternalLink)
override fun inlineTags(): Array<out Tag> = emptyArray() // TODO
override fun label(): String {
- val contentText = link.children.singleOrNull() as? ContentText
- val label = contentText?.text ?: link.href
+ val label = link.asText() ?: link.href
return "<a href=\"${link.href}\">$label</a>"
}
@@ -48,6 +60,11 @@ class SeeExternalLinkTagAdapter(val holder: Doc, val link: ContentExternalLink)
override fun kind(): String = "@see"
}
+fun ContentBlock.asText(): String? {
+ val contentText = children.singleOrNull() as? ContentText
+ return contentText?.text
+}
+
class SeeMethodTagAdapter(holder: Doc, val method: MethodAdapter, content: ContentNodeLink) : SeeTagAdapter(holder, content) {
override fun referencedMember(): MemberDoc = method
override fun referencedMemberName(): String = method.name()