aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-27 18:30:30 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-27 18:30:30 +0300
commitef753c8a1b9f02d9f6f026d555d628fbb207c574 (patch)
tree6c70dec31eb1a010f6b9db44dcac7a7720ab8d56 /core
parent289d287993b4618f73ebcbc5056a5495238a5836 (diff)
downloaddokka-ef753c8a1b9f02d9f6f026d555d628fbb207c574.tar.gz
dokka-ef753c8a1b9f02d9f6f026d555d628fbb207c574.tar.bz2
dokka-ef753c8a1b9f02d9f6f026d555d628fbb207c574.zip
Package platforms detected based on it's members, refactored multiplatform tests layout
Diffstat (limited to 'core')
-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
-rw-r--r--core/testdata/format/multiplatform/implied/foo.md (renamed from core/testdata/format/multiplatformImplied/foo.md)0
-rw-r--r--core/testdata/format/multiplatform/implied/js.kt (renamed from core/testdata/format/multiplatformImplied/js.kt)0
-rw-r--r--core/testdata/format/multiplatform/implied/jvm.kt (renamed from core/testdata/format/multiplatformImplied/jvm.kt)0
-rw-r--r--core/testdata/format/multiplatform/merge/js.kt (renamed from core/testdata/format/multiplatformMerge/js.kt)0
-rw-r--r--core/testdata/format/multiplatform/merge/jvm.kt (renamed from core/testdata/format/multiplatform/jvm.kt)0
-rw-r--r--core/testdata/format/multiplatform/merge/multiplatform.package.md (renamed from core/testdata/format/multiplatformMerge/multiplatform.package.md)0
-rw-r--r--core/testdata/format/multiplatform/mergeMembers/foo.md (renamed from core/testdata/format/multiplatformMergeMembers/foo.md)0
-rw-r--r--core/testdata/format/multiplatform/mergeMembers/js.kt (renamed from core/testdata/format/multiplatformMergeMembers/js.kt)0
-rw-r--r--core/testdata/format/multiplatform/mergeMembers/jvm.kt (renamed from core/testdata/format/multiplatformMergeMembers/jvm.kt)0
-rw-r--r--core/testdata/format/multiplatform/omitRedundant/foo.md (renamed from core/testdata/format/multiplatformOmitRedundant/foo.md)0
-rw-r--r--core/testdata/format/multiplatform/omitRedundant/js.kt (renamed from core/testdata/format/multiplatformOmitRedundant/js.kt)0
-rw-r--r--core/testdata/format/multiplatform/omitRedundant/jvm.kt (renamed from core/testdata/format/multiplatformOmitRedundant/jvm.kt)0
-rw-r--r--core/testdata/format/multiplatform/packagePlatformsFromMembers/js.kt3
-rw-r--r--core/testdata/format/multiplatform/packagePlatformsFromMembers/jvm.kt3
-rw-r--r--core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md8
-rw-r--r--core/testdata/format/multiplatform/simple/js.kt (renamed from core/testdata/format/multiplatform/js.kt)0
-rw-r--r--core/testdata/format/multiplatform/simple/jvm.kt (renamed from core/testdata/format/multiplatformMerge/jvm.kt)0
-rw-r--r--core/testdata/format/multiplatform/simple/multiplatform.package.md (renamed from core/testdata/format/multiplatform/multiplatform.package.md)0
21 files changed, 40 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)
diff --git a/core/testdata/format/multiplatformImplied/foo.md b/core/testdata/format/multiplatform/implied/foo.md
index c615dd8e..c615dd8e 100644
--- a/core/testdata/format/multiplatformImplied/foo.md
+++ b/core/testdata/format/multiplatform/implied/foo.md
diff --git a/core/testdata/format/multiplatformImplied/js.kt b/core/testdata/format/multiplatform/implied/js.kt
index dd2de5bc..dd2de5bc 100644
--- a/core/testdata/format/multiplatformImplied/js.kt
+++ b/core/testdata/format/multiplatform/implied/js.kt
diff --git a/core/testdata/format/multiplatformImplied/jvm.kt b/core/testdata/format/multiplatform/implied/jvm.kt
index 8d73ce25..8d73ce25 100644
--- a/core/testdata/format/multiplatformImplied/jvm.kt
+++ b/core/testdata/format/multiplatform/implied/jvm.kt
diff --git a/core/testdata/format/multiplatformMerge/js.kt b/core/testdata/format/multiplatform/merge/js.kt
index bbf1dd7c..bbf1dd7c 100644
--- a/core/testdata/format/multiplatformMerge/js.kt
+++ b/core/testdata/format/multiplatform/merge/js.kt
diff --git a/core/testdata/format/multiplatform/jvm.kt b/core/testdata/format/multiplatform/merge/jvm.kt
index cb77273f..cb77273f 100644
--- a/core/testdata/format/multiplatform/jvm.kt
+++ b/core/testdata/format/multiplatform/merge/jvm.kt
diff --git a/core/testdata/format/multiplatformMerge/multiplatform.package.md b/core/testdata/format/multiplatform/merge/multiplatform.package.md
index a423f603..a423f603 100644
--- a/core/testdata/format/multiplatformMerge/multiplatform.package.md
+++ b/core/testdata/format/multiplatform/merge/multiplatform.package.md
diff --git a/core/testdata/format/multiplatformMergeMembers/foo.md b/core/testdata/format/multiplatform/mergeMembers/foo.md
index 7490c878..7490c878 100644
--- a/core/testdata/format/multiplatformMergeMembers/foo.md
+++ b/core/testdata/format/multiplatform/mergeMembers/foo.md
diff --git a/core/testdata/format/multiplatformMergeMembers/js.kt b/core/testdata/format/multiplatform/mergeMembers/js.kt
index dd2de5bc..dd2de5bc 100644
--- a/core/testdata/format/multiplatformMergeMembers/js.kt
+++ b/core/testdata/format/multiplatform/mergeMembers/js.kt
diff --git a/core/testdata/format/multiplatformMergeMembers/jvm.kt b/core/testdata/format/multiplatform/mergeMembers/jvm.kt
index 8d73ce25..8d73ce25 100644
--- a/core/testdata/format/multiplatformMergeMembers/jvm.kt
+++ b/core/testdata/format/multiplatform/mergeMembers/jvm.kt
diff --git a/core/testdata/format/multiplatformOmitRedundant/foo.md b/core/testdata/format/multiplatform/omitRedundant/foo.md
index 088ced2c..088ced2c 100644
--- a/core/testdata/format/multiplatformOmitRedundant/foo.md
+++ b/core/testdata/format/multiplatform/omitRedundant/foo.md
diff --git a/core/testdata/format/multiplatformOmitRedundant/js.kt b/core/testdata/format/multiplatform/omitRedundant/js.kt
index d1b1429c..d1b1429c 100644
--- a/core/testdata/format/multiplatformOmitRedundant/js.kt
+++ b/core/testdata/format/multiplatform/omitRedundant/js.kt
diff --git a/core/testdata/format/multiplatformOmitRedundant/jvm.kt b/core/testdata/format/multiplatform/omitRedundant/jvm.kt
index 35e3c08d..35e3c08d 100644
--- a/core/testdata/format/multiplatformOmitRedundant/jvm.kt
+++ b/core/testdata/format/multiplatform/omitRedundant/jvm.kt
diff --git a/core/testdata/format/multiplatform/packagePlatformsFromMembers/js.kt b/core/testdata/format/multiplatform/packagePlatformsFromMembers/js.kt
new file mode 100644
index 00000000..86d09289
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsFromMembers/js.kt
@@ -0,0 +1,3 @@
+package foo.bar
+
+fun buz() {}
diff --git a/core/testdata/format/multiplatform/packagePlatformsFromMembers/jvm.kt b/core/testdata/format/multiplatform/packagePlatformsFromMembers/jvm.kt
new file mode 100644
index 00000000..86d09289
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsFromMembers/jvm.kt
@@ -0,0 +1,3 @@
+package foo.bar
+
+fun buz() {}
diff --git a/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md b/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md
new file mode 100644
index 00000000..0440bb1d
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md
@@ -0,0 +1,8 @@
+[test](test/index) / [foo.bar](test/foo.bar/index)
+
+## Package foo.bar
+
+### Functions
+
+| [buz](test/foo.bar/buz)<br>(JVM, JS) | `fun buz(): Unit` |
+
diff --git a/core/testdata/format/multiplatform/js.kt b/core/testdata/format/multiplatform/simple/js.kt
index e6d66ffd..e6d66ffd 100644
--- a/core/testdata/format/multiplatform/js.kt
+++ b/core/testdata/format/multiplatform/simple/js.kt
diff --git a/core/testdata/format/multiplatformMerge/jvm.kt b/core/testdata/format/multiplatform/simple/jvm.kt
index cb77273f..cb77273f 100644
--- a/core/testdata/format/multiplatformMerge/jvm.kt
+++ b/core/testdata/format/multiplatform/simple/jvm.kt
diff --git a/core/testdata/format/multiplatform/multiplatform.package.md b/core/testdata/format/multiplatform/simple/multiplatform.package.md
index 3574942c..3574942c 100644
--- a/core/testdata/format/multiplatform/multiplatform.package.md
+++ b/core/testdata/format/multiplatform/simple/multiplatform.package.md