Skip to content

Commit 12b4e0e

Browse files
committed
scaladoc: fix link resolving
1 parent 2616c8b commit 12b4e0e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ trait SiteRenderer(using DocContext) extends Locations:
2929

3030
def siteContent(pageDri: DRI, content: ResolvedTemplate): PageContent =
3131
import content.ctx
32+
33+
def tryAsDriPlain(str: String): Option[String] =
34+
val (path, prefix) = str match
35+
case HashRegex(path, prefix) => (path, prefix)
36+
case _ => (str, "")
37+
val res = ctx.driForLink(content.template.file, path).filter(driExists)
38+
res.headOption.map(pathToPage(pageDri, _) + prefix)
39+
3240
def tryAsDri(str: String): Option[String] =
3341
val newStr =
3442
str.dropWhile(c => c == '.' || c == '/').replaceAll("/", ".") match
@@ -51,7 +59,7 @@ trait SiteRenderer(using DocContext) extends Locations:
5159
)(
5260
resolveLink(pageDri, str.stripPrefix("/"))
5361
)
54-
def asStaticSite: Option[String] = tryAsDri(str)
62+
def asStaticSite: Option[String] = tryAsDriPlain(str).orElse(tryAsDri(str))
5563

5664
/* Link resolving checks performs multiple strategies with following priority:
5765
1. We check if the link is a valid URL e.g. http://dotty.epfl.ch

0 commit comments

Comments
 (0)