aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt2
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt11
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt25
3 files changed, 26 insertions, 12 deletions
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
index 6366ff61..0444a25a 100644
--- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
+++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
@@ -148,7 +148,7 @@ open class KotlinWebsiteOutputBuilder(to: StringBuilder,
override fun appendIndexRow(platforms: Set<String>, block: () -> Unit) {
if (platforms.isNotEmpty())
- wrap("<tr data-platform=\"${platforms.joinToString(" ")}\">", "</tr>", block)
+ wrap("<tr data-platform=\"${platforms.joinToString()}\">", "</tr>", block)
else
appendTableRow(block)
}
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index b5a35356..79ebabe0 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -408,7 +408,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
return
}
- appendSection("Packages", node.members(NodeKind.Package))
+ appendSection("Packages", node.members(NodeKind.Package), platformsBasedOnMembers = true)
appendSection("Types", node.members.filter { it.kind in NodeKind.classLike && it.kind != NodeKind.TypeAlias && it.kind != NodeKind.AnnotationClass && it.kind != NodeKind.Exception })
appendSection("Annotations", node.members(NodeKind.AnnotationClass))
appendSection("Exceptions", node.members(NodeKind.Exception))
@@ -463,7 +463,8 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
private fun appendSection(caption: String, members: List<DocumentationNode>,
sortMembers: Boolean = true,
- omitSamePlatforms: Boolean = false) {
+ omitSamePlatforms: Boolean = false,
+ platformsBasedOnMembers: Boolean = false) {
if (members.isEmpty()) return
appendHeader(3) { appendText(caption) }
@@ -476,7 +477,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
appendTable("Name", "Summary") {
appendTableBody {
for ((memberLocation, members) in membersMap) {
- val platforms = platformsOfItems(members, omitSamePlatforms)
+ val elementPlatforms = platformsOfItems(members, omitSamePlatforms)
+ val platforms = if (platformsBasedOnMembers)
+ members.flatMapTo(mutableSetOf()) { platformsOfItems(it.members) } + elementPlatforms
+ else
+ elementPlatforms
appendIndexRow(platforms) {
appendTableCell {
appendLink(memberLocation)
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 4830d760..e87811ee 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -255,35 +255,44 @@ class MarkdownFormatTest {
}
@Test fun multiplePlatforms() {
- verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform"), "multiplatform")
+ verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/simple"), "multiplatform/simple")
}
@Test fun multiplePlatformsMerge() {
- verifyMultiplatformPackage(buildMultiplePlatforms("multiplatformMerge"), "multiplatformMerge")
+ verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/merge"), "multiplatform/merge")
}
@Test fun multiplePlatformsMergeMembers() {
- val module = buildMultiplePlatforms("multiplatformMergeMembers")
- verifyModelOutput(module, ".md", "testdata/format/multiplatformMergeMembers/foo.kt") { model, output ->
+ val module = buildMultiplePlatforms("multiplatform/mergeMembers")
+ verifyModelOutput(module, ".md", "testdata/format/multiplatform/mergeMembers/foo.kt") { model, output ->
markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
}
}
@Test fun multiplePlatformsOmitRedundant() {
- val module = buildMultiplePlatforms("multiplatformOmitRedundant")
- verifyModelOutput(module, ".md", "testdata/format/multiplatformOmitRedundant/foo.kt") { model, output ->
+ val module = buildMultiplePlatforms("multiplatform/omitRedundant")
+ verifyModelOutput(module, ".md", "testdata/format/multiplatform/omitRedundant/foo.kt") { model, output ->
markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
}
}
@Test fun multiplePlatformsImplied() {
- val module = buildMultiplePlatforms("multiplatformImplied")
- verifyModelOutput(module, ".md", "testdata/format/multiplatformImplied/foo.kt") { model, output ->
+ val module = buildMultiplePlatforms("multiplatform/implied")
+ verifyModelOutput(module, ".md", "testdata/format/multiplatform/implied/foo.kt") { model, output ->
MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf("JVM", "JS"))
.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
}
}
+ @Test fun multiplePlatformsPackagePlatformFromMembers() {
+ val module = buildMultiplePlatforms("multiplatform/packagePlatformsFromMembers")
+ verifyModelOutput(module, ".md", "testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.kt") {
+ model, output ->
+ MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf())
+ .createOutputBuilder(output, tempLocation).appendNodes(model.members)
+ }
+ }
+
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
val options = DocumentationOptions("", "html", generateIndexPages = false)