All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.touk.nussknacker.engine.util.config.DocsConfig.scala Maven / Gradle / Ivy

There is a newer version: 1.18.0
Show newest version
package pl.touk.nussknacker.engine.util.config

import com.typesafe.config.Config
import pl.touk.nussknacker.engine.api.component.ComponentDefinition

import scala.language.implicitConversions

class DocsConfig(baseUrl: String) {

  def docsUrl(relative: String): String = baseUrl + relative

  implicit class ComponentConfig(componentDefinition: ComponentDefinition) {

    def withRelativeDocs(relative: String): ComponentDefinition =
      componentDefinition.copy(docsUrl = Some(docsUrl(relative)))

  }

}

object DocsConfig {

  val BaseDocsUrlConfigPath: String = "baseDocsUrl"

  val DefaultBaseUrl = "https://nussknacker.io/documentation/docs/scenarios_authoring/"

  val Default = new DocsConfig(DefaultBaseUrl)

  def apply(config: Config): DocsConfig = {
    import net.ceedubs.ficus.Ficus._
    val baseUrl = config
      .getAs[String](DocsConfig.BaseDocsUrlConfigPath)
      .getOrElse(DefaultBaseUrl)
    new DocsConfig(baseUrl)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy