diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-26 19:08:59 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-26 19:08:59 +0100 |
commit | 146764aca661d51daa298c7cfe6b9b5efcff7e5f (patch) | |
tree | 8379c830a61ffa9a879e29405c83847b552aa028 /src/Kotlin | |
parent | 1e74c644b1163948c389dd9082e0cba60ab5ed65 (diff) | |
download | dokka-146764aca661d51daa298c7cfe6b9b5efcff7e5f.tar.gz dokka-146764aca661d51daa298c7cfe6b9b5efcff7e5f.tar.bz2 dokka-146764aca661d51daa298c7cfe6b9b5efcff7e5f.zip |
stop generating separate pages for property accessors
Diffstat (limited to 'src/Kotlin')
-rw-r--r-- | src/Kotlin/ContentBuilder.kt | 4 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 38 | ||||
-rw-r--r-- | src/Kotlin/KotlinLanguageService.kt | 5 |
3 files changed, 24 insertions, 23 deletions
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index 56d2a407..4b8897b2 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -10,8 +10,8 @@ import org.intellij.markdown.* import org.jetbrains.kotlin.psi.JetDeclarationWithBody import org.jetbrains.kotlin.psi.JetBlockExpression -public fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlock): Content { - val result = Content() +public fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlock): MutableContent { + val result = MutableContent() buildContentTo(tree, result, linkResolver) return result } diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index b6bd8701..3910de04 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -136,7 +136,7 @@ class DocumentationBuilder(val session: ResolveSession, fun KDocSection.getTags(): Array<KDocTag> = PsiTreeUtil.getChildrenOfType(this, javaClass<KDocTag>()) ?: array() - private fun Content.addTagToSeeAlso(descriptor: DeclarationDescriptor, seeTag: KDocTag) { + private fun MutableContent.addTagToSeeAlso(descriptor: DeclarationDescriptor, seeTag: KDocTag) { val subjectName = seeTag.getSubjectName() if (subjectName != null) { val seeSection = findSectionByTag("See Also") ?: addSection("See Also", null) @@ -321,7 +321,6 @@ class DocumentationBuilder(val session: ResolveSession, is ConstructorDescriptor -> build() is ScriptDescriptor -> build() is PropertyDescriptor -> build() - is PropertyAccessorDescriptor -> build() is FunctionDescriptor -> build() is TypeParameterDescriptor -> build() is ValueParameterDescriptor -> build() @@ -414,17 +413,6 @@ class DocumentationBuilder(val session: ResolveSession, } } - fun PropertyAccessorDescriptor.build(): DocumentationNode { - val doc = parseDocumentation(this) - val specialName = getName().asString().drop(1).takeWhile { it != '-' } - val node = DocumentationNode(specialName, doc, Kind.PropertyAccessor).withModifiers(this) - - node.appendInPageChildren(getValueParameters(), DocumentationReference.Kind.Detail) - node.appendType(getReturnType()) - register(this, node) - return node - } - fun PropertyDescriptor.build(): DocumentationNode { val node = DocumentationNode(this, if (inClassObject()) Kind.DefaultObjectProperty else Kind.Property) node.appendInPageChildren(getTypeParameters(), DocumentationReference.Kind.Detail) @@ -436,12 +424,14 @@ class DocumentationBuilder(val session: ResolveSession, node.appendTextNode("var", DocumentationNode.Kind.Modifier) } getGetter()?.let { - if (!it.isDefault()) - node.appendChild(it, DocumentationReference.Kind.Member) + if (!it.isDefault()) { + node.addAccessorDocumentation(parseDocumentation(it), "Getter") + } } getSetter()?.let { - if (!it.isDefault()) - node.appendChild(it, DocumentationReference.Kind.Member) + if (!it.isDefault()) { + node.addAccessorDocumentation(parseDocumentation(it), "Setter") + } } getOverriddenDescriptors().forEach { @@ -452,6 +442,20 @@ class DocumentationBuilder(val session: ResolveSession, return node } + fun DocumentationNode.addAccessorDocumentation(documentation: Content, prefix: String) { + if (documentation == Content.Empty) return + updateContent { + if (!documentation.children.isEmpty()) { + val section = addSection(prefix, null) + documentation.children.forEach { section.append(it) } + } + documentation.sections.forEach { + val section = addSection("$prefix ${it.tag}", it.subjectName) + it.children.forEach { section.append(it) } + } + } + } + fun ValueParameterDescriptor.build(): DocumentationNode { val node = DocumentationNode(this, Kind.Parameter) val varargType = getVarargElementType() diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt index ab1f7016..9836bbda 100644 --- a/src/Kotlin/KotlinLanguageService.kt +++ b/src/Kotlin/KotlinLanguageService.kt @@ -26,8 +26,7 @@ class KotlinLanguageService : LanguageService { DocumentationNode.Kind.Modifier -> renderModifier(node) DocumentationNode.Kind.Constructor, DocumentationNode.Kind.Function, - DocumentationNode.Kind.DefaultObjectFunction, - DocumentationNode.Kind.PropertyAccessor -> renderFunction(node) + DocumentationNode.Kind.DefaultObjectFunction -> renderFunction(node) DocumentationNode.Kind.Property, DocumentationNode.Kind.DefaultObjectProperty -> renderProperty(node) else -> identifier(node.name) @@ -241,7 +240,6 @@ class KotlinLanguageService : LanguageService { DocumentationNode.Kind.Constructor -> identifier(node.owner!!.name) DocumentationNode.Kind.Function, DocumentationNode.Kind.DefaultObjectFunction -> keyword("fun ") - DocumentationNode.Kind.PropertyAccessor -> {} else -> throw IllegalArgumentException("Node $node is not a function-like object") } renderTypeParametersForNode(node) @@ -267,7 +265,6 @@ class KotlinLanguageService : LanguageService { private fun needReturnType(node: DocumentationNode) = when(node.kind) { DocumentationNode.Kind.Constructor -> false - DocumentationNode.Kind.PropertyAccessor -> node.name == "get" else -> true } |