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

dotty.tools.scaladoc.renderers.Writer.scala Maven / Gradle / Ivy

There is a newer version: 3.6.0-RC1-bin-20240903-21a3d39-NIGHTLY
Show newest version
package dotty.tools.scaladoc
package renderers

import java.io.InputStream
import java.nio.file.Paths
import java.nio.file.Path
import java.nio.file.Files
import java.io.File

import util.HTML._

// TODO be more clever about writting - make it much faster!
trait Writer(using ctx: DocContext) extends Locations:
  private val args = summon[DocContext].args

  private def dest(path: String) =
    val absPath = args.output.toPath.resolve(path)
    if !Files.exists(absPath.getParent) then Files.createDirectories(absPath.getParent)
    absPath

  def write(dri: DRI, content: AppliedTag, extension: String = "html"): String =
    val path = absolutePath(dri, extension)
    Files.write(dest(path), content.toString.getBytes)
    path

  def write(path: String, content: String): String =
    Files.write(dest(path), content.toString.getBytes)
    path

  def copy(from: Path, to: String): String =
    Files.copy(from, dest(to))
    to

  def copy(from: InputStream, to: String): String =
    Files.copy(from, dest(to))
    to




© 2015 - 2024 Weber Informatics LLC | Privacy Policy