From 852b4c439b54d9244bbebe421952defa632ad985 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 4 Nov 2015 17:32:51 +0100 Subject: javadoc link rendering fixes --- javadoc/src/main/kotlin/tags.kt | 17 +++++++++++------ src/Languages/JavaLanguageService.kt | 6 +----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/javadoc/src/main/kotlin/tags.kt b/javadoc/src/main/kotlin/tags.kt index 266c8712..9fdf86f2 100644 --- a/javadoc/src/main/kotlin/tags.kt +++ b/javadoc/src/main/kotlin/tags.kt @@ -30,7 +30,13 @@ class SeeExternalLinkTagAdapter(val holder: Doc, val link: ContentExternalLink) override fun position(): SourcePosition = holder.position() override fun text(): String = label() override fun inlineTags(): Array = emptyArray() // TODO - override fun label(): String = "${link.href}" + + override fun label(): String { + val contentText = link.children.singleOrNull() as? ContentText + val label = contentText?.text ?: link.href + return "$label" + } + override fun referencedPackage(): PackageDoc? = null override fun referencedClass(): ClassDoc? = null override fun referencedMemberName(): String? = null @@ -139,14 +145,13 @@ private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: Conten when (node) { is ContentText -> result.add(TextTag(holder, node)) is ContentNodeLink -> { - when (node.node?.kind) { + val target = node.node + when (target?.kind) { DocumentationNode.Kind.Function -> result.add(SeeMethodTagAdapter(holder, MethodAdapter(module, node.node!!), node)) - DocumentationNode.Kind.Class, - DocumentationNode.Kind.ExternalClass, - DocumentationNode.Kind.Enum -> result.add(SeeClassTagAdapter(holder, ClassDocumentationNodeAdapter(module, node.node!!), node)) + in DocumentationNode.Kind.classLike -> result.add(SeeClassTagAdapter(holder, ClassDocumentationNodeAdapter(module, node.node!!), node)) - else -> result.add(TextTag(holder, ContentText("other link: ${node.node}"))) // TODO + else -> node.children.forEach { buildInlineTags(module, holder, it, result) } } } is ContentExternalLink -> result.add(SeeExternalLinkTagAdapter(holder, node)) diff --git a/src/Languages/JavaLanguageService.kt b/src/Languages/JavaLanguageService.kt index 5750588e..7e40beff 100644 --- a/src/Languages/JavaLanguageService.kt +++ b/src/Languages/JavaLanguageService.kt @@ -10,11 +10,7 @@ public class JavaLanguageService : LanguageService { override fun render(node: DocumentationNode, renderMode: RenderMode): ContentNode { return ContentText(when (node.kind) { Kind.Package -> renderPackage(node) - Kind.Class, - Kind.Interface, - Kind.Enum, - Kind.EnumItem, - Kind.Object -> renderClass(node) + in Kind.classLike -> renderClass(node) Kind.TypeParameter -> renderTypeParameter(node) Kind.Type, -- cgit