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

dotty.tools.scaladoc.site.BlogParser.scala Maven / Gradle / Ivy

There is a newer version: 3.6.0-RC1-bin-20240917-6e852d2-NIGHTLY
Show newest version
package dotty.tools.scaladoc.site

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.databind.DeserializationFeature
import java.io.File
import scala.beans.{BooleanBeanProperty, BeanProperty}
import scala.util.Try

case class BlogConfig(
  @BeanProperty input: String,
  @BeanProperty output: String,
  @BooleanBeanProperty hidden: Boolean
):
  def this() = this(null, null, false)

object BlogParser:
  def readYml(content: File | String): BlogConfig =
    val mapper = ObjectMapper(YAMLFactory())
      .findAndRegisterModules()

    content match
      case f: File =>
        val ymlFile = f.toPath.resolve("blog.yml").toFile
        if ymlFile.exists then mapper.readValue(ymlFile, classOf[BlogConfig]) else new BlogConfig
      case s: String => Try(mapper.readValue(s, classOf[BlogConfig])).getOrElse(new BlogConfig)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy