From c14cfa23bc65aeaf1e74ae982459fa0321d7e615 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 3 Dec 2015 17:08:23 +0100 Subject: allow each format service to provide its own support files --- core/src/main/kotlin/Formats/FormatService.kt | 4 +++- core/src/main/kotlin/Formats/HtmlFormatService.kt | 4 ++++ core/src/main/kotlin/Generation/FileGenerator.kt | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'core/src/main') diff --git a/core/src/main/kotlin/Formats/FormatService.kt b/core/src/main/kotlin/Formats/FormatService.kt index 7e66a6b7..73e54956 100644 --- a/core/src/main/kotlin/Formats/FormatService.kt +++ b/core/src/main/kotlin/Formats/FormatService.kt @@ -6,7 +6,6 @@ package org.jetbrains.dokka * Bundled Formatters: * * [HtmlFormatService] – outputs documentation to HTML format * * [MarkdownFormatService] – outputs documentation in Markdown format - * * [TextFormatService] – outputs documentation in Text format */ public interface FormatService { /** Returns extension for output files */ @@ -14,6 +13,9 @@ public interface FormatService { /** Appends formatted content to [StringBuilder](to) using specified [location] */ fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable) + + fun enumerateSupportFiles(callback: (resource: String, targetPath: String) -> Unit) { + } } /** Format content to [String] using specified [location] */ diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt index 4d45e6cb..a58319bc 100644 --- a/core/src/main/kotlin/Formats/HtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt @@ -149,6 +149,10 @@ public open class HtmlFormatService @Inject constructor(@Named("folders") locati } override fun formatNonBreakingSpace(): String = " " + + override fun enumerateSupportFiles(callback: (String, String) -> Unit) { + callback("/dokka/styles/style.css", "style.css") + } } fun getPageTitle(nodes: Iterable): String? { diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt index a762bae3..e3d1d1fe 100644 --- a/core/src/main/kotlin/Generation/FileGenerator.kt +++ b/core/src/main/kotlin/Generation/FileGenerator.kt @@ -44,8 +44,10 @@ public class FileGenerator @Inject constructor(val locationService: FileLocation } override fun buildSupportFiles() { - FileOutputStream(locationService.location(listOf("style.css"), false).file).use { - javaClass.getResourceAsStream("/dokka/styles/style.css").copyTo(it) + formatService.enumerateSupportFiles { resource, targetPath -> + FileOutputStream(locationService.location(listOf(targetPath), false).file).use { + javaClass.getResourceAsStream(resource).copyTo(it) + } } } } -- cgit