diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-11-04 20:17:03 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-11-04 20:17:03 +0100 |
commit | f50966b8da454a9dacc2b35267b2ffa11b227638 (patch) | |
tree | aa12cc4090e2aaa937cc153b20aab2bb1f04d84b | |
parent | 972118bcffbdf13ebd3aefd495618c4670bdc7b3 (diff) | |
download | dokka-f50966b8da454a9dacc2b35267b2ffa11b227638.tar.gz dokka-f50966b8da454a9dacc2b35267b2ffa11b227638.tar.bz2 dokka-f50966b8da454a9dacc2b35267b2ffa11b227638.zip |
remove extra <p> tags from @param
-rw-r--r-- | javadoc/src/main/kotlin/docbase.kt | 8 | ||||
-rw-r--r-- | javadoc/src/main/kotlin/tags.kt | 24 | ||||
-rw-r--r-- | src/Kotlin/ContentBuilder.kt | 9 | ||||
-rw-r--r-- | src/Kotlin/DescriptorDocumentationParser.kt | 8 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 14 | ||||
-rw-r--r-- | src/Kotlin/KotlinAsJavaDocumentationBuilder.kt | 2 |
6 files changed, 42 insertions, 23 deletions
diff --git a/javadoc/src/main/kotlin/docbase.kt b/javadoc/src/main/kotlin/docbase.kt index cdb4bbc7..19b29b00 100644 --- a/javadoc/src/main/kotlin/docbase.kt +++ b/javadoc/src/main/kotlin/docbase.kt @@ -308,9 +308,11 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: Documentatio override fun isVarArgs(): Boolean = node.details(DocumentationNode.Kind.Parameter).any { false } // TODO override fun isSynchronized(): Boolean = node.annotations.any { it.name == "synchronized" } - override fun paramTags(): Array<out ParamTag> = node.details(DocumentationNode.Kind.Parameter).filter { it.content.summary !is ContentEmpty || it.content.description !is ContentEmpty || it.content.sections.isNotEmpty() }.map { - ParamTagAdapter(module, this, it.name, false, it.content.children) - }.toTypedArray() + + override fun paramTags(): Array<out ParamTag> = node.details(DocumentationNode.Kind.Parameter) + .filter { it.content.summary !is ContentEmpty || it.content.description !is ContentEmpty || it.content.sections.isNotEmpty() } + .map { ParamTagAdapter(module, this, it.name, false, it.content.children) } + .toTypedArray() override fun thrownExceptionTypes(): Array<out Type> = emptyArray() override fun receiverType(): Type? = receiverNode()?.let { receiver -> TypeAdapter(module, receiver) } diff --git a/javadoc/src/main/kotlin/tags.kt b/javadoc/src/main/kotlin/tags.kt index 5c38bbee..5872dbaa 100644 --- a/javadoc/src/main/kotlin/tags.kt +++ b/javadoc/src/main/kotlin/tags.kt @@ -89,8 +89,15 @@ class SeeClassTagAdapter(holder: Doc, val clazz: ClassDocumentationNodeAdapter, override fun firstSentenceTags(): Array<out Tag> = inlineTags() // TODO } -class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parameterName: String, val typeParameter: Boolean, val content: List<ContentNode>) : ParamTag { - constructor(module: ModuleNodeAdapter, holder: Doc, parameterName: String, isTypeParameter: Boolean, content: ContentNode) : this(module, holder, parameterName, isTypeParameter, listOf(content)) +class ParamTagAdapter(val module: ModuleNodeAdapter, + val holder: Doc, + val parameterName: String, + val typeParameter: Boolean, + val content: List<ContentNode>) : ParamTag { + + constructor(module: ModuleNodeAdapter, holder: Doc, parameterName: String, isTypeParameter: Boolean, content: ContentNode) + : this(module, holder, parameterName, isTypeParameter, listOf(content)) { + } override fun name(): String = "@param" override fun kind(): String = name() @@ -125,6 +132,13 @@ class ThrowsTagAdapter(val holder: Doc, val type: ClassDocumentationNodeAdapter) fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, root: ContentNode): List<Tag> = ArrayList<Tag>().let { buildInlineTags(module, holder, root, it); it } +private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, nodes: List<ContentNode>, result: MutableList<Tag>) { + nodes.forEach { + buildInlineTags(module, holder, it, result) + } +} + + private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: ContentNode, result: MutableList<Tag>) { fun surroundWith(module: ModuleNodeAdapter, holder: Doc, prefix: String, postfix: String, node: ContentBlock, result: MutableList<Tag>) { if (node.children.isNotEmpty()) { @@ -132,9 +146,7 @@ private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: Conten val close = TextTag(holder, ContentText(postfix)) result.add(open) - node.children.forEach { - buildInlineTags(module, holder, it, result) - } + buildInlineTags(module, holder, node.children, result) if (result.last() === open) { result.removeAt(result.lastIndex) @@ -168,7 +180,7 @@ private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: Conten in DocumentationNode.Kind.classLike -> result.add(SeeClassTagAdapter(holder, ClassDocumentationNodeAdapter(module, node.node!!), node)) - else -> node.children.forEach { buildInlineTags(module, holder, it, result) } + else -> buildInlineTags(module, holder, node.children, result) } } is ContentExternalLink -> result.add(SeeExternalLinkTagAdapter(holder, node)) diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index 9fe0db6e..c4bb18de 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -5,9 +5,14 @@ import org.intellij.markdown.MarkdownTokenTypes import org.intellij.markdown.html.entities.EntityConverter import java.util.* -public fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlock): MutableContent { +public fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlock, inline: Boolean = false): MutableContent { val result = MutableContent() - buildContentTo(tree, result, linkResolver) + if (inline) { + buildInlineContentTo(tree, result, linkResolver) + } + else { + buildContentTo(tree, result, linkResolver) + } return result } diff --git a/src/Kotlin/DescriptorDocumentationParser.kt b/src/Kotlin/DescriptorDocumentationParser.kt index 839c3710..76bad31e 100644 --- a/src/Kotlin/DescriptorDocumentationParser.kt +++ b/src/Kotlin/DescriptorDocumentationParser.kt @@ -30,9 +30,10 @@ class DescriptorDocumentationParser val resolutionFacade: DokkaResolutionFacade, val refGraph: NodeReferenceGraph) { - fun parseDocumentation(descriptor: DeclarationDescriptor): Content = parseDocumentationAndDetails(descriptor).first + fun parseDocumentation(descriptor: DeclarationDescriptor, inline: Boolean = false): Content = + parseDocumentationAndDetails(descriptor, inline).first - fun parseDocumentationAndDetails(descriptor: DeclarationDescriptor): Pair<Content, (DocumentationNode) -> Unit> { + fun parseDocumentationAndDetails(descriptor: DeclarationDescriptor, inline: Boolean = false): Pair<Content, (DocumentationNode) -> Unit> { if (descriptor is JavaClassDescriptor || descriptor is JavaCallableMemberDescriptor) { return parseJavadoc(descriptor) } @@ -52,8 +53,7 @@ class DescriptorDocumentationParser kdocText += "\n" } val tree = parseMarkdown(kdocText) - //println(tree.toTestString()) - val content = buildContent(tree, { href -> linkResolver.resolveContentLink(descriptor, href) }) + val content = buildContent(tree, { href -> linkResolver.resolveContentLink(descriptor, href) }, inline) if (kdoc is KDocSection) { val tags = kdoc.getTags() tags.forEach { diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index cdbff877..97f2462b 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -84,8 +84,8 @@ class DocumentationBuilder refGraph.register(descriptor.signature(), node) } - fun <T> DocumentationNode(descriptor: T, kind: Kind): DocumentationNode where T : DeclarationDescriptor, T : Named { - val (doc, callback) = descriptorDocumentationParser.parseDocumentationAndDetails(descriptor) + fun <T> nodeForDescriptor(descriptor: T, kind: Kind): DocumentationNode where T : DeclarationDescriptor, T : Named { + val (doc, callback) = descriptorDocumentationParser.parseDocumentationAndDetails(descriptor, kind == Kind.Parameter) val node = DocumentationNode(descriptor.name.asString(), doc, kind).withModifiers(descriptor) callback(node) return node @@ -294,7 +294,7 @@ class DocumentationBuilder ClassKind.ENUM_ENTRY -> Kind.EnumItem else -> Kind.Class } - val node = DocumentationNode(this, kind) + val node = nodeForDescriptor(this, kind) node.appendSupertypes(this) if (getKind() != ClassKind.OBJECT && getKind() != ClassKind.ENUM_ENTRY) { node.appendInPageChildren(typeConstructor.parameters, DocumentationReference.Kind.Detail) @@ -321,7 +321,7 @@ class DocumentationBuilder } fun ConstructorDescriptor.build(): DocumentationNode { - val node = DocumentationNode(this, Kind.Constructor) + val node = nodeForDescriptor(this, Kind.Constructor) node.appendInPageChildren(valueParameters, DocumentationReference.Kind.Detail) register(this, node) return node @@ -341,7 +341,7 @@ class DocumentationBuilder logger.warn("Found an unresolved type in ${signatureWithSourceLocation()}") } - val node = DocumentationNode(this, if (inCompanionObject()) Kind.CompanionObjectFunction else Kind.Function) + val node = nodeForDescriptor(this, if (inCompanionObject()) Kind.CompanionObjectFunction else Kind.Function) node.appendInPageChildren(typeParameters, DocumentationReference.Kind.Detail) extensionReceiverParameter?.let { node.appendChild(it, DocumentationReference.Kind.Detail) } @@ -371,7 +371,7 @@ class DocumentationBuilder } fun PropertyDescriptor.build(): DocumentationNode { - val node = DocumentationNode(this, if (inCompanionObject()) Kind.CompanionObjectProperty else Kind.Property) + val node = nodeForDescriptor(this, if (inCompanionObject()) Kind.CompanionObjectProperty else Kind.Property) node.appendInPageChildren(typeParameters, DocumentationReference.Kind.Detail) extensionReceiverParameter?.let { node.appendChild(it, DocumentationReference.Kind.Detail) } node.appendType(returnType) @@ -415,7 +415,7 @@ class DocumentationBuilder } fun ValueParameterDescriptor.build(): DocumentationNode { - val node = DocumentationNode(this, Kind.Parameter) + val node = nodeForDescriptor(this, Kind.Parameter) node.appendType(varargElementType ?: type) if (declaresDefaultValue()) { val psi = source.getPsi() as? KtParameter diff --git a/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt b/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt index b5dc47a3..a802e06c 100644 --- a/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt +++ b/src/Kotlin/KotlinAsJavaDocumentationBuilder.kt @@ -58,7 +58,7 @@ class KotlinAsJavaDocumentationParser } } val descriptor = resolutionFacade.resolveToDescriptor(origin) - val content = descriptorDocumentationParser.parseDocumentation(descriptor) + val content = descriptorDocumentationParser.parseDocumentation(descriptor, origin is KtParameter) return JavadocParseResult(content, null) } } |