diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/servicelocator/ServiceLocator.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/servicelocator/ServiceLocator.kt index fadfc115..7ace6011 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/servicelocator/ServiceLocator.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/servicelocator/ServiceLocator.kt @@ -45,8 +45,7 @@ internal fun ServiceLocator.moduleRegistryWriter( ) internal val ServiceLocator.mermaidGraphWriter get() = MermaidGraphWriter( - codeGenConfig, - codeGenerator + codeGenConfig ) internal val ServiceLocator.customNavTypeWriter get() = CustomNavTypesWriter( diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt index 5ec59264..2754af67 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt @@ -1,11 +1,8 @@ package com.ramcosta.composedestinations.codegen.writers -import com.ramcosta.composedestinations.codegen.DEFAULT_GEN_PACKAGE_NAME import com.ramcosta.composedestinations.codegen.commons.RawNavGraphTree -import com.ramcosta.composedestinations.codegen.commons.plusAssign import com.ramcosta.composedestinations.codegen.commons.snakeToCamelCase import com.ramcosta.composedestinations.codegen.commons.toSnakeCase -import com.ramcosta.composedestinations.codegen.facades.CodeOutputStreamMaker import com.ramcosta.composedestinations.codegen.model.CodeGenConfig import com.ramcosta.composedestinations.codegen.model.CodeGenProcessedDestination import com.ramcosta.composedestinations.codegen.model.ExternalRoute @@ -15,10 +12,13 @@ import java.util.Locale internal class MermaidGraphWriter( private val codeGenConfig: CodeGenConfig, - private val codeGenerator: CodeOutputStreamMaker ) { fun write(graphTrees: List) { + if (codeGenConfig.mermaidGraph == null && codeGenConfig.htmlMermaidGraph == null) { + return + } + graphTrees.forEach { writeMermaidGraph(it) } @@ -57,32 +57,15 @@ internal class MermaidGraphWriter( mermaidGraph .replace("@clicksPlaceholder@", externalNavGraphClicks(tree, "mmd")) ) - } else { - codeGenerator.makeFile( - name = tree.rawNavGraphGenParams.name, - packageName = "$DEFAULT_GEN_PACKAGE_NAME.mermaid", - extensionName = "mmd", - ).use { - it += mermaidGraph - .replace("@clicksPlaceholder@", "") - } } - val htmlMermaid = html(title, mermaidGraph) if (codeGenConfig.htmlMermaidGraph != null) { + val htmlMermaid = html(title, mermaidGraph) File(codeGenConfig.htmlMermaidGraph, "${tree.rawNavGraphGenParams.name}.html") .apply { parentFile?.mkdirs() } .writeText( htmlMermaid.replace("@clicksPlaceholder@", externalNavGraphClicks(tree, "html")) ) - } else { - codeGenerator.makeFile( - name = tree.rawNavGraphGenParams.name, - packageName = "$DEFAULT_GEN_PACKAGE_NAME.mermaid", - extensionName = "html", - ).use { - it += htmlMermaid.replace("@clicksPlaceholder@", "") - } } }