diff options
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 29 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 34 | ||||
-rw-r--r-- | src/Model/DocumentationNode.kt | 1 |
3 files changed, 50 insertions, 14 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 280aa6b5..740f6b6a 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -81,7 +81,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi if (!single) { appendBlockCode(to, formatText(location, languageService.render(node))) } - appendLine(to, formatText(location,node.content.description)) + appendLine(to, formatText(location, node.content.description)) appendLine(to) for ((label, section) in node.content.sections) { if (label.startsWith("$")) @@ -118,7 +118,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi } } - private fun StructuredFormatService.appendSection(location : Location, caption: String, nodes: List<DocumentationNode>, node: DocumentationNode, to: StringBuilder) { + private fun StructuredFormatService.appendSection(location: Location, caption: String, nodes: List<DocumentationNode>, node: DocumentationNode, to: StringBuilder) { if (nodes.any()) { appendHeader(to, caption, 3) @@ -163,7 +163,30 @@ public abstract class StructuredFormatService(val locationService: LocationServi } for (node in nodes) { - appendSection(location, "Members", node.members, node, to) + appendSection(location, "Packages", node.members(DocumentationNode.Kind.Package), node, to) + appendSection(location, "Types", node.members.filter { + it.kind in setOf( + DocumentationNode.Kind.Class, + DocumentationNode.Kind.Interface, + DocumentationNode.Kind.Enum, + DocumentationNode.Kind.Object) + }, node, to) + appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to) + appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to) + appendSection(location, "Functions", node.members(DocumentationNode.Kind.Function), node, to) + appendSection(location, "Accessors", node.members(DocumentationNode.Kind.PropertyAccessor), node, to) + appendSection(location, "Other members", node.members.filter { + it.kind !in setOf( + DocumentationNode.Kind.Class, + DocumentationNode.Kind.Interface, + DocumentationNode.Kind.Object, + DocumentationNode.Kind.Constructor, + DocumentationNode.Kind.Property, + DocumentationNode.Kind.Package, + DocumentationNode.Kind.Function, + DocumentationNode.Kind.PropertyAccessor + ) + }, node, to) appendSection(location, "Extensions", node.extensions, node, to) appendSection(location, "Inheritors", node.inheritors, node, to) appendSection(location, "Links", node.links, node, to) diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 875048e5..c3f8ca57 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -139,10 +139,9 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati is ClassDescriptor -> build() is ConstructorDescriptor -> build() is ScriptDescriptor -> build() - is FunctionDescriptor -> build() is PropertyDescriptor -> build() - is PropertyGetterDescriptor -> build() - is PropertySetterDescriptor -> build() + is PropertyAccessorDescriptor -> build() + is FunctionDescriptor -> build() is TypeParameterDescriptor -> build() is ValueParameterDescriptor -> build() is ReceiverParameterDescriptor -> build() @@ -192,6 +191,17 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati } + fun PropertyAccessorDescriptor.build(): DocumentationNode { + val doc = parseDocumentation(this) + val specialName = getName().asString().drop(1).takeWhile { it != '-' } + val node = DocumentationNode(specialName, doc, Kind.PropertyAccessor) + + node.appendChildren(getValueParameters(), DocumentationReference.Kind.Detail) + node.appendType(getReturnType()) + register(this, node) + return node + } + fun PropertyDescriptor.build(): DocumentationNode { val node = DocumentationNode(this, Kind.Property) node.appendChildren(getTypeParameters(), DocumentationReference.Kind.Detail) @@ -257,14 +267,16 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati * $node: [DocumentationNode] to visit */ public fun resolveReferences(node: DocumentationNode) { - node.details(DocumentationNode.Kind.Receiver).forEach { detail -> - val receiverType = detail.detail(DocumentationNode.Kind.Type) - val descriptor = links[receiverType] - if (descriptor != null) { - val typeNode = descriptorToNode[descriptor] - // if typeNode is null, extension is to external type like in a library - // should we create dummy node here? - typeNode?.addReferenceTo(node, DocumentationReference.Kind.Extension) + if (node.kind != Kind.PropertyAccessor) { + node.details(DocumentationNode.Kind.Receiver).forEach { receiver -> + val receiverType = receiver.detail(DocumentationNode.Kind.Type) + val descriptor = links[receiverType] + if (descriptor != null) { + val typeNode = descriptorToNode[descriptor] + // if typeNode is null, extension is to external type like in a library + // should we create dummy node here? + typeNode?.addReferenceTo(node, DocumentationReference.Kind.Extension) + } } } node.details(DocumentationNode.Kind.Supertype).forEach { detail -> diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index 2be5bf15..c2d7e3fb 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -68,6 +68,7 @@ public open class DocumentationNode(val name: String, Constructor Function Property + PropertyAccessor Parameter Receiver |