diff options
Diffstat (limited to 'core/src/main/kotlin/renderers')
-rw-r--r-- | core/src/main/kotlin/renderers/DefaultRenderer.kt | 6 | ||||
-rw-r--r-- | core/src/main/kotlin/renderers/FileWriter.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/renderers/HtmlRenderer.kt | 6 | ||||
-rw-r--r-- | core/src/main/kotlin/renderers/Writer.kt | 7 |
4 files changed, 15 insertions, 8 deletions
diff --git a/core/src/main/kotlin/renderers/DefaultRenderer.kt b/core/src/main/kotlin/renderers/DefaultRenderer.kt index e2ebf8b3..8f6c6635 100644 --- a/core/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/core/src/main/kotlin/renderers/DefaultRenderer.kt @@ -5,7 +5,7 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.resolvers.LocationProvider abstract class DefaultRenderer<T>( - protected val fileWriter: FileWriter, + protected val writer: Writer, protected val locationProvider: LocationProvider, protected val context: DokkaContext ) : Renderer { @@ -64,7 +64,7 @@ abstract class DefaultRenderer<T>( } protected open fun renderPage(page: PageNode) = - fileWriter.write(locationProvider.resolve(page), buildPage(page, ::buildPageContent), "") + writer.write(locationProvider.resolve(page), buildPage(page, ::buildPageContent), "") protected open fun renderPages(root: PageNode) { renderPage(root) @@ -77,7 +77,7 @@ abstract class DefaultRenderer<T>( getPackageNamesAndPlatforms(root) .keys .joinToString("\n") - .also { fileWriter.write("${root.name}/package-list", it, "") } + .also { writer.write("${root.name}/package-list", it, "") } protected open fun getPackageNamesAndPlatforms(root: PageNode): Map<String, List<PlatformData>> = root.children diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/core/src/main/kotlin/renderers/FileWriter.kt index 9ee02b4b..c9785dfd 100644 --- a/core/src/main/kotlin/renderers/FileWriter.kt +++ b/core/src/main/kotlin/renderers/FileWriter.kt @@ -4,10 +4,10 @@ import java.io.File import java.io.IOException import java.nio.file.Paths -class FileWriter(val root: String, val extension: String){ +class FileWriter(override val root: String, override val extension: String) : Writer { private val createdFiles: MutableSet<String> = mutableSetOf() - fun write(path: String, text: String, ext: String = extension){ + override fun write(path: String, text: String, ext: String){ if (createdFiles.contains(path)) { println("ERROR. An attempt to write $root/$path several times!") return diff --git a/core/src/main/kotlin/renderers/HtmlRenderer.kt b/core/src/main/kotlin/renderers/HtmlRenderer.kt index 2c450ae5..2bb07666 100644 --- a/core/src/main/kotlin/renderers/HtmlRenderer.kt +++ b/core/src/main/kotlin/renderers/HtmlRenderer.kt @@ -9,10 +9,10 @@ import java.io.File import java.net.URL open class HtmlRenderer( - fileWriter: FileWriter, + writer: Writer, locationProvider: LocationProvider, context: DokkaContext -) : DefaultRenderer<FlowContent>(fileWriter, locationProvider, context) { +) : DefaultRenderer<FlowContent>(writer, locationProvider, context) { override fun FlowContent.buildList(node: ContentList, pageContext: PageNode) = if (node.ordered) ol { @@ -121,7 +121,7 @@ open class HtmlRenderer( } override fun buildSupportFiles() { // TODO copy file instead of reading - fileWriter.write( + writer.write( "style.css", javaClass.getResourceAsStream("/dokka/styles/style.css").reader().readText() ) diff --git a/core/src/main/kotlin/renderers/Writer.kt b/core/src/main/kotlin/renderers/Writer.kt new file mode 100644 index 00000000..ead281fe --- /dev/null +++ b/core/src/main/kotlin/renderers/Writer.kt @@ -0,0 +1,7 @@ +package org.jetbrains.dokka.renderers + +interface Writer { + val root: String + val extension: String + fun write(path: String, text: String, ext: String = extension) +}
\ No newline at end of file |