aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/plugability/DefaultExtensions.kt5
-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
4 files changed, 15 insertions, 7 deletions
diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt
index c62bdd41..029d21de 100644
--- a/core/src/main/kotlin/plugability/DefaultExtensions.kt
+++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka.plugability
import org.jetbrains.dokka.CoreExtensions
import org.jetbrains.dokka.pages.DocTagToContentConverter
import org.jetbrains.dokka.renderers.FileWriter
+import org.jetbrains.dokka.renderers.OutputWriter
import org.jetbrains.dokka.renderers.html.HtmlRenderer
import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory
import org.jetbrains.dokka.transformers.descriptors.DefaultDescriptorToDocumentationTranslator
@@ -20,7 +21,7 @@ internal object DefaultExtensions {
}
private val converter: LazyEvaluated<DocTagToContentConverter> = LazyEvaluated.fromRecipe { DocTagToContentConverter(it) }
private val providerFactory: LazyEvaluated<DefaultLocationProviderFactory> = LazyEvaluated.fromRecipe { DefaultLocationProviderFactory(it) }
-
+ private val outputWriter: LazyEvaluated<OutputWriter> = LazyEvaluated.fromRecipe { FileWriter(it) }
@Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST")
internal fun <T : Any, E : ExtensionPoint<T>> get(point: E, fullContext: DokkaContext): List<T> =
@@ -32,7 +33,7 @@ internal object DefaultExtensions {
CoreExtensions.documentationToPageTranslator -> DefaultDocumentationToPageTranslator
CoreExtensions.renderer -> renderer.get(fullContext)
CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext)
- CoreExtensions.outputWriter -> FileWriter(fullContext, "")
+ CoreExtensions.outputWriter -> outputWriter.get(fullContext)
CoreExtensions.fileExtension -> ".html"
else -> null
}.let { listOfNotNull( it ) as List<T> }
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