aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/renderers
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/renderers')
-rw-r--r--core/src/main/kotlin/renderers/DefaultRenderer.kt4
-rw-r--r--core/src/main/kotlin/renderers/FileWriter.kt3
-rw-r--r--core/src/main/kotlin/renderers/OutputWriter.kt10
3 files changed, 12 insertions, 5 deletions
diff --git a/core/src/main/kotlin/renderers/DefaultRenderer.kt b/core/src/main/kotlin/renderers/DefaultRenderer.kt
index cdd28737..4b4d6fd3 100644
--- a/core/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/core/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -12,8 +12,6 @@ abstract class DefaultRenderer<T>(
protected val context: DokkaContext
) : Renderer {
- private val extension = context.single(CoreExtensions.fileExtension)
-
protected lateinit var locationProvider: LocationProvider
private set
@@ -77,7 +75,7 @@ abstract class DefaultRenderer<T>(
open fun renderPage(page: PageNode) {
val path by lazy { locationProvider.resolve(page, skipExtension = true) }
when (page) {
- is ContentPage -> outputWriter.write(path, buildPage(page) { c, p -> buildPageContent(c, p) }, extension)
+ is ContentPage -> outputWriter.write(path, buildPage(page) { c, p -> buildPageContent(c, p) })
is RendererSpecificPage -> when (val strategy = page.strategy) {
is RenderingStrategy.Copy -> outputWriter.writeResources(strategy.from, path)
is RenderingStrategy.Write -> outputWriter.write(path, strategy.text, "")
diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/core/src/main/kotlin/renderers/FileWriter.kt
index 78cfdde7..83bb9ce3 100644
--- a/core/src/main/kotlin/renderers/FileWriter.kt
+++ b/core/src/main/kotlin/renderers/FileWriter.kt
@@ -6,10 +6,11 @@ import java.io.IOException
import java.net.URI
import java.nio.file.*
-class FileWriter(val context: DokkaContext, override val extension: String): OutputWriter {
+class FileWriter(override val context: DokkaContext): OutputWriter {
private val createdFiles: MutableSet<String> = mutableSetOf()
private val jarUriPrefix = "jar:file:"
private val root = context.configuration.outputDir
+
override fun write(path: String, text: String, ext: String) {
if (createdFiles.contains(path)) {
context.logger.error("An attempt to write ${root}/$path several times!")
diff --git a/core/src/main/kotlin/renderers/OutputWriter.kt b/core/src/main/kotlin/renderers/OutputWriter.kt
index 8ef7e8b2..b2059aa3 100644
--- a/core/src/main/kotlin/renderers/OutputWriter.kt
+++ b/core/src/main/kotlin/renderers/OutputWriter.kt
@@ -1,7 +1,15 @@
package org.jetbrains.dokka.renderers
-interface OutputWriter{
+import org.jetbrains.dokka.CoreExtensions
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.single
+
+interface OutputWriter {
+
+ val context: DokkaContext
val extension: String
+ get() = context.single(CoreExtensions.fileExtension)
+
fun write(path: String, text: String, ext: String = extension)
fun writeResources(pathFrom: String, pathTo: String)
} \ No newline at end of file