diff options
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r-- | core/src/main/kotlin/CoreExtensions.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/DokkaGenerator.kt | 10 | ||||
-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 |
6 files changed, 22 insertions, 15 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index 7393dd68..191a6c59 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -4,8 +4,8 @@ import org.jetbrains.dokka.pages.CommentsToContentConverter import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.ExtensionPoint -import org.jetbrains.dokka.renderers.FileWriter import org.jetbrains.dokka.renderers.Renderer +import org.jetbrains.dokka.renderers.Writer import org.jetbrains.dokka.resolvers.LocationProvider import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator import org.jetbrains.dokka.transformers.documentation.DocumentationNodeMerger @@ -26,7 +26,7 @@ object CoreExtensions { val commentsToContentConverterFactory by coreExtension<(DokkaContext) -> CommentsToContentConverter>() val documentationToPageTranslator by coreExtension<DocumentationToPageTranslator>() val pageTransformer by coreExtension<PageNodeTransformer>() - val rendererFactory by coreExtension<(FileWriter, LocationProvider, DokkaContext) -> Renderer>() + val rendererFactory by coreExtension<(Writer, LocationProvider, DokkaContext) -> Renderer>() val locationProviderFactory by coreExtension<(root: PageNode, DokkaConfiguration, DokkaContext) -> LocationProvider>() val fileExtension by coreExtension<String>() diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index b4035617..845ad53f 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -16,12 +16,12 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.utils.PathUtil import java.io.File -class DokkaGenerator( +open class DokkaGenerator( private val configuration: DokkaConfiguration, private val logger: DokkaLogger ) { - fun generate() { + open fun generate() { logger.debug("Setting up analysis environments") val platforms: Map<PlatformData, EnvironmentAndFacade> = configuration.passesConfigurations.map { PlatformData(it.moduleName, it.analysisPlatform, it.targets) to createEnvironmentAndFacade(it) @@ -59,7 +59,7 @@ class DokkaGenerator( renderer.render(transformedPages) } - private fun createEnvironmentAndFacade(pass: DokkaConfiguration.PassConfiguration): EnvironmentAndFacade = + protected fun createEnvironmentAndFacade(pass: DokkaConfiguration.PassConfiguration): EnvironmentAndFacade = AnalysisEnvironment(DokkaMessageCollector(logger), pass.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) @@ -75,7 +75,7 @@ class DokkaGenerator( EnvironmentAndFacade(environment, facade) } - private fun translateDescriptors(platformData: PlatformData, context: DokkaContext): Module { + protected fun translateDescriptors(platformData: PlatformData, context: DokkaContext): Module { val (environment, facade) = context.platforms.getValue(platformData) val packageFragments = environment.getSourceFiles().asSequence() @@ -88,7 +88,7 @@ class DokkaGenerator( .invoke(platformData.name, packageFragments, platformData, context) } - private class DokkaMessageCollector(private val logger: DokkaLogger) : MessageCollector { + protected class DokkaMessageCollector(private val logger: DokkaLogger) : MessageCollector { override fun clear() { seenErrors = false } 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 |