aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-28 16:58:22 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-28 16:58:22 +0300
commitddad0ac478f31ca0b74de43af4254f115f694ef7 (patch)
tree958628cb8388dc5c2f718b22f6d9210fce28beb2 /core
parent6276fd0e68085c9b0994f8f947bf904b9b285b34 (diff)
downloaddokka-ddad0ac478f31ca0b74de43af4254f115f694ef7.tar.gz
dokka-ddad0ac478f31ca0b74de43af4254f115f694ef7.tar.bz2
dokka-ddad0ac478f31ca0b74de43af4254f115f694ef7.zip
Correct detecting platform for Extensions on external classes
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt20
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt27
-rw-r--r--core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md2
-rw-r--r--core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/jvm.kt5
-rw-r--r--core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.index.md10
-rw-r--r--core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.package.md10
6 files changed, 61 insertions, 13 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index a7b696eb..419e5eeb 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -368,11 +368,19 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
}
- protected fun platformsOfItems(items: List<DocumentationNode>): Set<String> =
- items.foldRight(items.first().platformsToShow.toSet()) {
- node, platforms ->
- platforms.intersect(node.platformsToShow)
+ protected fun platformsOfItems(items: List<DocumentationNode>): Set<String> {
+ val platforms = items.asSequence().map {
+ when (it.kind) {
+ NodeKind.ExternalClass, NodeKind.Package, NodeKind.Module -> platformsOfItems(it.members)
+ else -> it.platformsToShow.toSet()
}
+ }
+ // Calculating common platforms for items
+ return platforms.fold(platforms.first()) {
+ result, platforms ->
+ result.intersect(platforms)
+ }
+ }
val DocumentationNode.platformsToShow: List<String>
get() = platforms.let { if (it.containsAll(impliedPlatforms)) it - impliedPlatforms else it }
@@ -498,7 +506,9 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
appendIndexRow(platforms) {
appendTableCell {
appendLink(memberLocation)
- appendPlatforms(platforms)
+ if (members.singleOrNull()?.kind != NodeKind.ExternalClass) {
+ appendPlatforms(platforms)
+ }
}
appendTableCell {
val breakdownBySummary = members.groupBy { it.summary }
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index cdb55cba..04c2dc62 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -288,17 +288,20 @@ class MarkdownFormatTest {
}
}
- @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 packagePlatformsWithExtExtensions() {
+ val path = "multiplatform/packagePlatformsWithExtExtensions"
+ val module = DocumentationModule("test")
+ val options = DocumentationOptions("", "html", generateIndexPages = false)
+ appendDocumentation(module, contentRootFromPath("testdata/format/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), withKotlinRuntime = true, options = options)
+ verifyMultiplatformIndex(module, path)
+ verifyMultiplatformPackage(module, path)
}
@Test fun multiplePlatformsPackagePlatformFromMembers() {
- verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/packagePlatformsFromMembers"), "multiplatform/packagePlatformsFromMembers")
+ val path = "multiplatform/packagePlatformsFromMembers"
+ val module = buildMultiplePlatforms(path)
+ verifyMultiplatformIndex(module, path)
+ verifyMultiplatformPackage(module, path)
}
private fun buildMultiplePlatforms(path: String): DocumentationModule {
@@ -315,6 +318,14 @@ class MarkdownFormatTest {
}
}
+ private fun verifyMultiplatformIndex(module: DocumentationModule, path: String) {
+ verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.index.kt") {
+ model, output ->
+ MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf())
+ .createOutputBuilder(output, tempLocation).appendNodes(listOf(model))
+ }
+ }
+
@Test fun blankLineInsideCodeBlock() {
verifyMarkdownNode("blankLineInsideCodeBlock")
}
diff --git a/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md b/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md
index 294513ed..1dda25d4 100644
--- a/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md
+++ b/core/testdata/format/multiplatform/packagePlatformsFromMembers/multiplatform.index.md
@@ -1,5 +1,7 @@
[test](test/index)
+**Platform and version requirements:** JVM, JS
+
### Packages
| [foo.bar](test/foo.bar/index)<br>(JVM, JS) | |
diff --git a/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/jvm.kt b/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/jvm.kt
new file mode 100644
index 00000000..27ab1b32
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/jvm.kt
@@ -0,0 +1,5 @@
+package some
+
+fun String.buz(): Unit {
+
+} \ No newline at end of file
diff --git a/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.index.md b/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.index.md
new file mode 100644
index 00000000..f6e770b2
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.index.md
@@ -0,0 +1,10 @@
+[test](test/index)
+
+**Platform and version requirements:** JVM
+
+### Packages
+
+| [some](test/some/index)<br>(JVM) | |
+
+### Index
+
diff --git a/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.package.md b/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.package.md
new file mode 100644
index 00000000..22f778d6
--- /dev/null
+++ b/core/testdata/format/multiplatform/packagePlatformsWithExtExtensions/multiplatform.package.md
@@ -0,0 +1,10 @@
+[test](test/index) / [some](test/some/index)
+
+## Package some
+
+**Platform and version requirements:** JVM
+
+### Extensions for External Classes
+
+| [kotlin.String](test/some/kotlin.-string/index) | |
+