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

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

There is a newer version: 3.6.3-RC1-bin-20241114-6a7d5d3-NIGHTLY
Show newest version
package dotty.tools.scaladoc
package renderers

import util.HTML._
import scala.jdk.CollectionConverters._
import java.net.URI
import java.net.URL
import java.util.{List => JList, Set => JSet}
import scala.util.Try
import org.jsoup.Jsoup
import java.nio.file.Paths

// TODO merge it with new renderer
trait SignatureRenderer:
  def currentDri: DRI
  def link(dri: DRI): Option[String]

  def renderElement(e: SignaturePart, modifiers: AppliedAttr*): AppliedTag = renderElementWith(e, modifiers*)

  def renderLink(name: String, dri: DRI, modifiers: AppliedAttr*) =
    renderLinkContent(name, dri, modifiers*)

  def unresolvedLink(content: TagArg, modifiers: AppliedAttr*) =
    span(Attr("data-unresolved-link") := "", modifiers)(content)

  def renderLinkContent(content: TagArg, dri: DRI, modifiers: AppliedAttr*) =
    link(dri) match
      case Some(link) => a(href := link, modifiers)(content)
      case _ => unresolvedLink(content, modifiers*)

  def renderElementWith(e: SignaturePart, modifiers: AppliedAttr*) = e match
    case Name(name, dri) =>
      val attrs = Seq(Attr("t") := "n") ++ modifiers
      renderLink(name, dri, attrs*)
    case Type(name, Some(dri)) =>
      val attrs = Seq(Attr("t") := "t") ++ modifiers
      renderLink(name, dri, attrs*)
    case Type(name, None) => span(Attr("t") := "t")(name)
    case Keyword(name) => span(Attr("t") := "k")(name)
    case Plain(name) => raw(name)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy