Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ trait SiteRenderer(using DocContext) extends Locations:
def siteContent(pageDri: DRI, content: ResolvedTemplate): PageContent =
import content.ctx
def tryAsDri(str: String): Option[String] =
val (path, prefix) = str match
val newStr =
str.dropWhile(c => c == '.' || c == '/').replaceAll("/", ".") match
case str if str.endsWith("$.html") => str.stripSuffix("$.html")
case str if str.endsWith(".html") => str.stripSuffix(".html")
case _ => str

val (path, prefix) = newStr match
case HashRegex(path, prefix) => (path, prefix)
case _ => (str, "")
case _ => (newStr, "")

val res = ctx.driForLink(content.template.file, path).filter(driExists)
res.headOption.map(pathToPage(pageDri, _) + prefix)
Expand All @@ -49,7 +55,7 @@ trait SiteRenderer(using DocContext) extends Locations:

/* Link resolving checks performs multiple strategies with following priority:
1. We check if the link is a valid URL e.g. http://dotty.epfl.ch
2. We check if the link leads to other static site
2. We check if the link leads to other static site or API pages, example: [[exemple.scala.Foo]] || [Foo](../exemple/scala/Foo.html)
3. We check if the link leads to existing asset e.g. images/logo.svg -> <static-site-root>/_assets/images/logo.svg
*/

Expand Down