diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-12 19:04:53 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-12 19:04:53 +0100 |
commit | f3ed9f5fa553c72a254e5ca5d28e108849937769 (patch) | |
tree | 76d4dd6239da5ca01bddd35a54b8427d550c9e4f /core/src/main/kotlin/Formats | |
parent | a3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af (diff) | |
download | dokka-f3ed9f5fa553c72a254e5ca5d28e108849937769.tar.gz dokka-f3ed9f5fa553c72a254e5ca5d28e108849937769.tar.bz2 dokka-f3ed9f5fa553c72a254e5ca5d28e108849937769.zip |
generate all types index
Diffstat (limited to 'core/src/main/kotlin/Formats')
-rw-r--r-- | core/src/main/kotlin/Formats/StructuredFormatService.kt | 65 |
1 files changed, 57 insertions, 8 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index 9221004c..c9218c46 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -98,10 +98,15 @@ abstract class StructuredFormatService(locationService: LocationService, } } - open fun link(from: DocumentationNode, to: DocumentationNode): FormatLink = link(from, to, extension) - - open fun link(from: DocumentationNode, to: DocumentationNode, extension: String): FormatLink { - return FormatLink(to.name, locationService.relativePathToLocation(from, to)) + open fun link(from: DocumentationNode, + to: DocumentationNode, + name: (DocumentationNode) -> String = DocumentationNode::name): FormatLink = link(from, to, extension, name) + + open fun link(from: DocumentationNode, + to: DocumentationNode, + extension: String, + name: (DocumentationNode) -> String = DocumentationNode::name): FormatLink { + return FormatLink(name(to), locationService.relativePathToLocation(from, to)) } fun locationHref(from: Location, to: DocumentationNode): String { @@ -279,7 +284,7 @@ abstract class StructuredFormatService(locationService: LocationService, } inner class SingleNodePageBuilder(location: Location, to: StringBuilder, val node: DocumentationNode) - : PageBuilder(location, to, listOf(node)) { + : PageBuilder(location, to, listOf(node)) { override fun build() { super.build() @@ -319,7 +324,8 @@ abstract class StructuredFormatService(locationService: LocationService, NodeKind.CompanionObjectProperty, NodeKind.CompanionObjectFunction, NodeKind.ExternalClass, - NodeKind.EnumItem + NodeKind.EnumItem, + NodeKind.AllTypes ) }) @@ -330,7 +336,13 @@ abstract class StructuredFormatService(locationService: LocationService, appendSection("Companion Object Extension Functions", allExtensions.filter { it.kind == NodeKind.CompanionObjectFunction }) appendSection("Inheritors", node.inheritors.filter { it.kind != NodeKind.EnumItem }) - appendSection("Links", node.links) + + if (node.kind == NodeKind.Module) { + appendHeader(to, "Index", 3) + node.members(NodeKind.AllTypes).singleOrNull()?.let { allTypes -> + to.append(formatLink(link(node, allTypes, { "All Types" }))) + } + } } private fun appendSection(caption: String, members: List<DocumentationNode>) { @@ -383,10 +395,47 @@ abstract class StructuredFormatService(locationService: LocationService, } } + inner class AllTypesNodeBuilder(location: Location, to: StringBuilder, val node: DocumentationNode) + : PageBuilder(location, to, listOf(node)) { + + override fun build() { + to.append(formatText(location, node.owner!!.summary)) + appendHeader(to, "All Types", 3) + + appendTable(to) { + appendTableBody(to) { + for (type in node.members) { + appendTableRow(to) { + appendTableCell(to) { + to.append(formatLink(link(node, type) { + if (it.kind == NodeKind.ExternalClass) it.name else it.qualifiedName() + })) + if (type.kind == NodeKind.ExternalClass) { + val packageName = type.owner?.name + if (packageName != null) { + to.append(formatText(" (extensions in package $packageName)")) + } + } + } + appendTableCell(to) { + to.append(formatText(location, type.summary)) + } + } + } + } + } + } + } + override fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { val singleNode = nodes.singleOrNull() if (singleNode != null) { - SingleNodePageBuilder(location, to, singleNode).build() + if (singleNode.kind == NodeKind.AllTypes) { + AllTypesNodeBuilder(location, to, singleNode).build() + } + else { + SingleNodePageBuilder(location, to, singleNode).build() + } } else { PageBuilder(location, to, nodes).build() |