aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--.idea/runConfigurations/Stdlib.xml2
-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
22 files changed, 41 insertions, 13 deletions
diff --git a/.idea/runConfigurations/Stdlib.xml b/.idea/runConfigurations/Stdlib.xml
index 91f85056..fc196ae4 100644
--- a/.idea/runConfigurations/Stdlib.xml
+++ b/.idea/runConfigurations/Stdlib.xml
@@ -3,7 +3,7 @@
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.dokka.MainKt" />
<option name="VM_PARAMETERS" value="-Xmx2048m -Xms256m" />
- <option name="PROGRAM_PARAMETERS" value="JVM::../kotlin/libraries/stdlib/src JVM::../kotlin/core/builtins JVM::../kotlin/core/reflection.jvm JVM::../kotlin/core/runtime.jvm JVM,JRE7::../kotlin/libraries/stdlib/jre7/src JVM,JRE8::../kotlin/libraries/stdlib/jre8/src JS::../kotlin/core/builtins JS::../kotlin/dist/kotlin-stdlib-js-sources -samples ../kotlin/libraries/stdlib/test -output ../kotlin-web-site/pages/api/latest/jvm -module stdlib -include ../kotlin/libraries/stdlib/src/Module.md -format kotlin-website -nodeprecated -srcLink ../kotlin=http://github.com/JetBrains/kotlin/blob/master#L -impliedPlatforms JVM,JS" />
+ <option name="PROGRAM_PARAMETERS" value="JVM::../kotlin/libraries/stdlib/src JVM::../kotlin/core/builtins JVM::../kotlin/core/reflection.jvm JVM::../kotlin/core/runtime.jvm JVM,JRE7::../kotlin/libraries/stdlib/jre7/src JVM,JRE8::../kotlin/libraries/stdlib/jre8/src JS::../kotlin/core/builtins JS::../kotlin/dist/kotlin-stdlib-js-sources -samples ../kotlin/libraries/stdlib/test -output ../kotlin-web-site/pages/api/latest/jvm -module stdlib -include ../kotlin/libraries/stdlib/src/Module.md -format kotlin-website-samples -nodeprecated -srcLink ../kotlin=http://github.com/JetBrains/kotlin/blob/master#L -impliedPlatforms JVM,JS" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
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