aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-27 21:27:37 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-27 21:27:37 +0300
commitd43d47b9486bbd7e926cf1a3fc6372f2a457a5e5 (patch)
tree925229bac0b49943f38766d07802026beed11910 /core
parent05c5a8f20167b652f918e8260fd16453efadf5ff (diff)
parentbc71b31be28ed558e022babcf40ec1fd3bff923a (diff)
downloaddokka-d43d47b9486bbd7e926cf1a3fc6372f2a457a5e5.tar.gz
dokka-d43d47b9486bbd7e926cf1a3fc6372f2a457a5e5.tar.bz2
dokka-d43d47b9486bbd7e926cf1a3fc6372f2a457a5e5.zip
Merge branch 'semoro/multiplatform'
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt2
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt31
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt29
-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)2
-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/packagePlatformsFromMembers/multiplatform.package.md10
-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
-rw-r--r--core/testdata/format/sinceKotlin.package.md2
23 files changed, 73 insertions, 17 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..a7b696eb 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -263,6 +263,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
val packageName = if (singleNode.name.isEmpty()) "<root>" else singleNode.name
appendHeader(2) { appendText("Package $packageName") }
}
+ singleNode.appendPlatforms()
appendContent(singleNode.content)
} else {
val breakdownByName = nodes.groupBy { node -> node.name }
@@ -354,13 +355,25 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
private fun DocumentationNode.appendPlatforms() {
- val platforms = platformsToShow.ifEmpty { return }
+ val platforms = if (isModuleOrPackage())
+ platformsToShow.toSet() + platformsOfItems(members)
+ else
+ platformsToShow
+
+ if(platforms.isEmpty()) return
+
appendParagraph {
appendStrong { to.append("Platform and version requirements:") }
to.append(" " + platforms.joinToString())
}
}
+ protected fun platformsOfItems(items: List<DocumentationNode>): Set<String> =
+ items.foldRight(items.first().platformsToShow.toSet()) {
+ node, platforms ->
+ platforms.intersect(node.platformsToShow)
+ }
+
val DocumentationNode.platformsToShow: List<String>
get() = platforms.let { if (it.containsAll(impliedPlatforms)) it - impliedPlatforms else it }
@@ -408,7 +421,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 +476,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 +490,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)
@@ -496,10 +514,7 @@ 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)
- }
+ val platforms = platformsOfItems(items)
if (platforms.isNotEmpty() && (platforms != node.platformsToShow.toSet() || !omitSamePlatforms)) {
return platforms
}
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 121e9afb..cdb55cba 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -259,35 +259,48 @@ 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 multiplePlatformsPackagePlatformFromMembersIndex() {
+ 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(listOf(model))
+ }
+ }
+
+ @Test fun multiplePlatformsPackagePlatformFromMembers() {
+ verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/packagePlatformsFromMembers"), "multiplatform/packagePlatformsFromMembers")
+ }
+
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..8e463327 100644
--- a/core/testdata/format/multiplatformMerge/multiplatform.package.md
+++ b/core/testdata/format/multiplatform/merge/multiplatform.package.md
@@ -2,6 +2,8 @@
## Package foo
+**Platform and version requirements:** JVM, JS
+
### Types
| [Foo](test/foo/-foo/index)<br>(JVM, JS) | `class Foo`<br>This is a foo. |
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..294513ed
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md
@@ -0,0 +1,8 @@
+[test](test/index)
+
+### Packages
+
+| [foo.bar](test/foo.bar/index)<br>(JVM, JS) | |
+
+### Index
+
diff --git a/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.package.md b/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.package.md
new file mode 100644
index 00000000..2921cdd1
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.package.md
@@ -0,0 +1,10 @@
+[test](test/index) / [foo.bar](test/foo.bar/index)
+
+## Package foo.bar
+
+**Platform and version requirements:** JVM, JS
+
+### 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
diff --git a/core/testdata/format/sinceKotlin.package.md b/core/testdata/format/sinceKotlin.package.md
index 2af0c9ee..c811749c 100644
--- a/core/testdata/format/sinceKotlin.package.md
+++ b/core/testdata/format/sinceKotlin.package.md
@@ -2,6 +2,8 @@
## Package &lt;root&gt;
+**Platform and version requirements:** Kotlin 1.1
+
### Types
| [Since1.1](test/-since1.1/index)<br>(Kotlin 1.1) | `class Since1.1`<br>Useful |