aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt7
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt43
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt9
3 files changed, 41 insertions, 18 deletions
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
index 7ebc5f09..6366ff61 100644
--- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
+++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
@@ -145,6 +145,13 @@ open class KotlinWebsiteOutputBuilder(to: StringBuilder,
IdentifierKind.SummarizedTypeName -> "summarizedTypeName"
else -> "identifier"
}
+
+ override fun appendIndexRow(platforms: Set<String>, block: () -> Unit) {
+ if (platforms.isNotEmpty())
+ wrap("<tr data-platform=\"${platforms.joinToString(" ")}\">", "</tr>", block)
+ else
+ appendTableRow(block)
+ }
}
class KotlinWebsiteFormatService @Inject constructor(locationService: LocationService,
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index 6e887c05..b5a35356 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -208,6 +208,17 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
block()
}
+ protected open fun appendIndexRow(platforms: Set<String>, block: () -> Unit) {
+ appendTableRow(block)
+ }
+
+ protected open fun appendPlatforms(platforms: Set<String>) {
+ if (platforms.isNotEmpty()) {
+ appendLine()
+ appendText(platforms.joinToString(prefix = "(", postfix = ")"))
+ }
+ }
+
protected open fun appendBreadcrumbs(path: Iterable<FormatLink>) {
for ((index, item) in path.withIndex()) {
if (index > 0) {
@@ -460,13 +471,16 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
val children = if (sortMembers) members.sortedBy { it.name } else members
val membersMap = children.groupBy { link(node, it) }
+
+
appendTable("Name", "Summary") {
appendTableBody {
for ((memberLocation, members) in membersMap) {
- appendTableRow {
+ val platforms = platformsOfItems(members, omitSamePlatforms)
+ appendIndexRow(platforms) {
appendTableCell {
appendLink(memberLocation)
- appendPlatforms(members, omitSamePlatforms)
+ appendPlatforms(platforms)
}
appendTableCell {
val breakdownBySummary = members.groupBy { it.summary }
@@ -481,6 +495,17 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
}
+ private fun platformsOfItems(items: List<DocumentationNode>, omitSamePlatforms: Boolean = true): Set<String> {
+ val platforms = items.foldRight(items.first().platformsToShow.toSet()) {
+ node, platforms ->
+ platforms.intersect(node.platformsToShow)
+ }
+ if (platforms.isNotEmpty() && (platforms != node.platformsToShow.toSet() || !omitSamePlatforms)) {
+ return platforms
+ }
+ return emptySet()
+ }
+
private fun appendSummarySignatures(items: List<DocumentationNode>) {
val summarySignature = languageService.summarizeSignatures(items)
if (summarySignature != null) {
@@ -500,16 +525,6 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
renderedSignatures.last().appendSignature()
}
}
-
- private fun appendPlatforms(items: List<DocumentationNode>, omitSamePlatforms: Boolean) {
- val platforms = items.foldRight(items.first().platformsToShow.toSet()) {
- node, platforms -> platforms.intersect(node.platformsToShow)
- }
- if (platforms.isNotEmpty() && (platforms != node.platformsToShow.toSet() || !omitSamePlatforms)) {
- appendLine()
- to.append("(${platforms.joinToString()})")
- }
- }
}
inner class AllTypesNodeBuilder(val node: DocumentationNode)
@@ -520,9 +535,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
appendHeader(3) { to.append("All Types") }
appendTable("Name", "Summary") {
- appendTableBody() {
+ appendTableBody {
for (type in node.members) {
- appendTableRow() {
+ appendTableRow {
appendTableCell {
appendLink(link(node, type) {
if (it.kind == NodeKind.ExternalClass) it.name else it.qualifiedName()
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 2ab43fa1..fcb86d53 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -234,10 +234,11 @@ class DocumentationBuilder
}
fun DocumentationNode.appendSinceKotlin(annotation: DocumentationNode) {
- var kotlinVersion = annotation.detail(NodeKind.Parameter).detail(NodeKind.Value).name
- if (kotlinVersion.startsWith('\"') && kotlinVersion.endsWith('\"')) {
- kotlinVersion = kotlinVersion.substring(1..kotlinVersion.length-2)
- }
+ val kotlinVersion = annotation
+ .detail(NodeKind.Parameter)
+ .detail(NodeKind.Value)
+ .name.removeSurrounding("\"")
+
append(platformNodeRegistry["Kotlin " + kotlinVersion], RefKind.Platform)
}