aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Formats
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2017-02-23 17:05:32 +0100
committerDmitry Jemerov <yole@jetbrains.com>2017-02-23 17:05:32 +0100
commit64a86842ae06c7119cca4ef7c66b024f771ab088 (patch)
tree7e98b4ee57c4219c1ea0bff59f289c36e2a9d750 /core/src/main/kotlin/Formats
parent99689adee954582da57268ff0375fdec52193a01 (diff)
downloaddokka-64a86842ae06c7119cca4ef7c66b024f771ab088.tar.gz
dokka-64a86842ae06c7119cca4ef7c66b024f771ab088.tar.bz2
dokka-64a86842ae06c7119cca4ef7c66b024f771ab088.zip
Don't show implied platforms in output
Diffstat (limited to 'core/src/main/kotlin/Formats')
-rw-r--r--core/src/main/kotlin/Formats/GFMFormatService.kt21
-rw-r--r--core/src/main/kotlin/Formats/HtmlFormatService.kt9
-rw-r--r--core/src/main/kotlin/Formats/JekyllFormatService.kt18
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt26
-rw-r--r--core/src/main/kotlin/Formats/MarkdownFormatService.kt15
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt13
6 files changed, 64 insertions, 38 deletions
diff --git a/core/src/main/kotlin/Formats/GFMFormatService.kt b/core/src/main/kotlin/Formats/GFMFormatService.kt
index cfb7fc03..cb31a1d3 100644
--- a/core/src/main/kotlin/Formats/GFMFormatService.kt
+++ b/core/src/main/kotlin/Formats/GFMFormatService.kt
@@ -3,11 +3,12 @@ package org.jetbrains.dokka
import com.google.inject.Inject
open class GFMOutputBuilder(to: StringBuilder,
- location: Location,
- locationService: LocationService,
- languageService: LanguageService,
- extension: String)
- : MarkdownOutputBuilder(to, location, locationService, languageService, extension)
+ location: Location,
+ locationService: LocationService,
+ languageService: LanguageService,
+ extension: String,
+ impliedPlatforms: List<String>)
+ : MarkdownOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
{
override fun appendTable(vararg columns: String, body: () -> Unit) {
to.appendln(columns.joinToString(" | ", "| ", " |"))
@@ -45,12 +46,14 @@ open class GFMOutputBuilder(to: StringBuilder,
open class GFMFormatService(locationService: LocationService,
signatureGenerator: LanguageService,
- linkExtension: String)
-: MarkdownFormatService(locationService, signatureGenerator, linkExtension) {
+ linkExtension: String,
+ impliedPlatforms: List<String>)
+: MarkdownFormatService(locationService, signatureGenerator, linkExtension, impliedPlatforms) {
@Inject constructor(locationService: LocationService,
- signatureGenerator: LanguageService) : this(locationService, signatureGenerator, "md")
+ signatureGenerator: LanguageService,
+ impliedPlatforms: List<String>) : this(locationService, signatureGenerator, "md", impliedPlatforms)
override fun createOutputBuilder(to: StringBuilder, location: Location): FormattedOutputBuilder =
- GFMOutputBuilder(to, location, locationService, languageService, extension)
+ GFMOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
}
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt
index d73e4e62..6819e652 100644
--- a/core/src/main/kotlin/Formats/HtmlFormatService.kt
+++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt
@@ -2,6 +2,7 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.google.inject.name.Named
+import org.jetbrains.dokka.Utilities.impliedPlatformsName
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths
@@ -11,8 +12,9 @@ open class HtmlOutputBuilder(to: StringBuilder,
locationService: LocationService,
languageService: LanguageService,
extension: String,
+ impliedPlatforms: List<String>,
val templateService: HtmlTemplateService)
- : StructuredOutputBuilder(to, location, locationService, languageService, extension)
+ : StructuredOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
{
override fun appendText(text: String) {
to.append(text.htmlEscape())
@@ -95,7 +97,8 @@ open class HtmlOutputBuilder(to: StringBuilder,
open class HtmlFormatService @Inject constructor(@Named("folders") locationService: LocationService,
signatureGenerator: LanguageService,
- val templateService: HtmlTemplateService)
+ val templateService: HtmlTemplateService,
+ @Named(impliedPlatformsName) val impliedPlatforms: List<String>)
: StructuredFormatService(locationService, signatureGenerator, "html"), OutlineFormatService {
override fun enumerateSupportFiles(callback: (String, String) -> Unit) {
@@ -103,7 +106,7 @@ open class HtmlFormatService @Inject constructor(@Named("folders") locationServi
}
override fun createOutputBuilder(to: StringBuilder, location: Location) =
- HtmlOutputBuilder(to, location, locationService, languageService, extension, templateService)
+ HtmlOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms, templateService)
override fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
templateService.appendHeader(to, "Module Contents", locationService.calcPathToRoot(location))
diff --git a/core/src/main/kotlin/Formats/JekyllFormatService.kt b/core/src/main/kotlin/Formats/JekyllFormatService.kt
index bab73379..d217bf38 100644
--- a/core/src/main/kotlin/Formats/JekyllFormatService.kt
+++ b/core/src/main/kotlin/Formats/JekyllFormatService.kt
@@ -1,13 +1,16 @@
package org.jetbrains.dokka
import com.google.inject.Inject
+import com.google.inject.name.Named
+import org.jetbrains.dokka.Utilities.impliedPlatformsName
open class JekyllOutputBuilder(to: StringBuilder,
location: Location,
locationService: LocationService,
languageService: LanguageService,
- extension: String)
- : MarkdownOutputBuilder(to, location, locationService, languageService, extension)
+ extension: String,
+ impliedPlatforms: List<String>)
+ : MarkdownOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
{
override fun appendNodes(nodes: Iterable<DocumentationNode>) {
to.appendln("---")
@@ -25,14 +28,15 @@ open class JekyllOutputBuilder(to: StringBuilder,
open class JekyllFormatService(locationService: LocationService,
signatureGenerator: LanguageService,
- linkExtension: String)
-: MarkdownFormatService(locationService, signatureGenerator, linkExtension) {
+ linkExtension: String,
+ impliedPlatforms: List<String>)
+: MarkdownFormatService(locationService, signatureGenerator, linkExtension, impliedPlatforms) {
@Inject constructor(locationService: LocationService,
- signatureGenerator: LanguageService): this(locationService, signatureGenerator, "md") {
- }
+ signatureGenerator: LanguageService,
+ @Named(impliedPlatformsName) impliedPlatforms: List<String>): this(locationService, signatureGenerator, "md", impliedPlatforms)
override fun createOutputBuilder(to: StringBuilder, location: Location): FormattedOutputBuilder =
- JekyllOutputBuilder(to, location, locationService, languageService, extension)
+ JekyllOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
}
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
index 007e9353..1897c53b 100644
--- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
+++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
@@ -1,14 +1,17 @@
package org.jetbrains.dokka
import com.google.inject.Inject
+import com.google.inject.name.Named
+import org.jetbrains.dokka.Utilities.impliedPlatformsName
open class KotlinWebsiteOutputBuilder(to: StringBuilder,
location: Location,
locationService: LocationService,
languageService: LanguageService,
- extension: String)
- : JekyllOutputBuilder(to, location, locationService, languageService, extension)
+ extension: String,
+ impliedPlatforms: List<String>)
+ : JekyllOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
{
private var needHardLineBreaks = false
private var insideDiv = 0
@@ -145,11 +148,12 @@ open class KotlinWebsiteOutputBuilder(to: StringBuilder,
}
class KotlinWebsiteFormatService @Inject constructor(locationService: LocationService,
- signatureGenerator: LanguageService)
- : JekyllFormatService(locationService, signatureGenerator, "html")
+ signatureGenerator: LanguageService,
+ impliedPlatforms: List<String>)
+ : JekyllFormatService(locationService, signatureGenerator, "html", impliedPlatforms)
{
override fun createOutputBuilder(to: StringBuilder, location: Location) =
- KotlinWebsiteOutputBuilder(to, location, locationService, languageService, extension)
+ KotlinWebsiteOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
}
@@ -157,8 +161,9 @@ class KotlinWebsiteRunnableSamplesOutputBuilder(to: StringBuilder,
location: Location,
locationService: LocationService,
languageService: LanguageService,
- extension: String)
- : KotlinWebsiteOutputBuilder(to, location, locationService, languageService, extension) {
+ extension: String,
+ impliedPlatforms: List<String>)
+ : KotlinWebsiteOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms) {
override fun appendSampleBlockCode(language: String, imports: () -> Unit, body: () -> Unit) {
div(to, "sample", true) {
@@ -173,9 +178,10 @@ class KotlinWebsiteRunnableSamplesOutputBuilder(to: StringBuilder,
}
class KotlinWebsiteRunnableSamplesFormatService @Inject constructor(locationService: LocationService,
- signatureGenerator: LanguageService)
- : JekyllFormatService(locationService, signatureGenerator, "html") {
+ signatureGenerator: LanguageService,
+ @Named(impliedPlatformsName) impliedPlatforms: List<String>)
+ : JekyllFormatService(locationService, signatureGenerator, "html", impliedPlatforms) {
override fun createOutputBuilder(to: StringBuilder, location: Location) =
- KotlinWebsiteRunnableSamplesOutputBuilder(to, location, locationService, languageService, extension)
+ KotlinWebsiteRunnableSamplesOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
}
diff --git a/core/src/main/kotlin/Formats/MarkdownFormatService.kt b/core/src/main/kotlin/Formats/MarkdownFormatService.kt
index fc63b2f2..b9c9c04f 100644
--- a/core/src/main/kotlin/Formats/MarkdownFormatService.kt
+++ b/core/src/main/kotlin/Formats/MarkdownFormatService.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka
import com.google.inject.Inject
+import com.google.inject.name.Named
+import org.jetbrains.dokka.Utilities.impliedPlatformsName
import java.util.*
enum class ListKind {
@@ -14,8 +16,9 @@ open class MarkdownOutputBuilder(to: StringBuilder,
location: Location,
locationService: LocationService,
languageService: LanguageService,
- extension: String)
- : StructuredOutputBuilder(to, location, locationService, languageService, extension)
+ extension: String,
+ impliedPlatforms: List<String>)
+ : StructuredOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
{
private val listKindStack = Stack<ListKind>()
protected var inTableCell = false
@@ -211,11 +214,13 @@ open class MarkdownOutputBuilder(to: StringBuilder,
open class MarkdownFormatService(locationService: LocationService,
signatureGenerator: LanguageService,
- linkExtension: String)
+ linkExtension: String,
+ val impliedPlatforms: List<String>)
: StructuredFormatService(locationService, signatureGenerator, "md", linkExtension) {
@Inject constructor(locationService: LocationService,
- signatureGenerator: LanguageService): this(locationService, signatureGenerator, "md")
+ signatureGenerator: LanguageService,
+ @Named(impliedPlatformsName) impliedPlatforms: List<String>): this(locationService, signatureGenerator, "md", impliedPlatforms)
override fun createOutputBuilder(to: StringBuilder, location: Location): FormattedOutputBuilder =
- MarkdownOutputBuilder(to, location, locationService, languageService, extension)
+ MarkdownOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
}
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index 71f9d577..de2ef3ed 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka
import org.jetbrains.dokka.LanguageService.RenderMode
+import org.jetbrains.kotlin.utils.ifEmpty
import java.util.*
data class FormatLink(val text: String, val href: String)
@@ -9,7 +10,8 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
val location: Location,
val locationService: LocationService,
val languageService: LanguageService,
- val extension: String) : FormattedOutputBuilder {
+ val extension: String,
+ val impliedPlatforms: List<String>) : FormattedOutputBuilder {
protected fun wrap(prefix: String, suffix: String, body: () -> Unit) {
to.append(prefix)
@@ -344,13 +346,16 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
private fun DocumentationNode.appendPlatforms() {
- if (platforms.isEmpty()) return
+ val platforms = platformsToShow.ifEmpty { return }
appendParagraph {
appendStrong { to.append("Platform and version requirements:") }
to.append(" " + platforms.joinToString())
}
}
+ val DocumentationNode.platformsToShow: List<String>
+ get() = platforms.let { if (it.containsAll(impliedPlatforms)) it - impliedPlatforms else it }
+
private fun DocumentationNode.appendDescription() {
if (content.description != ContentEmpty) {
appendContent(content.description)
@@ -498,8 +503,8 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
private fun appendPlatforms(items: List<DocumentationNode>) {
- val platforms = items.foldRight(items.first().platforms.toSet()) {
- node, platforms -> platforms.intersect(node.platforms)
+ val platforms = items.foldRight(items.first().platformsToShow.toSet()) {
+ node, platforms -> platforms.intersect(node.platformsToShow)
}
if (platforms.isNotEmpty()) {
appendLine()