Skip to content

Commit 396f993

Browse files
committed
Scala3doc: fix rendering source links on Windows
1 parent bbd092b commit 396f993

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scala3doc/src/dotty/dokka/SourceLinks.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import liqp.Template
66
import dotty.dokka.model.api._
77
import dotty.tools.dotc.core.Contexts.Context
88

9-
def pathToString(p: Path) = p.toString.replace('\\', '/')
9+
def pathToString(p: Path) =
10+
import scala.jdk.CollectionConverters._
11+
// !!! gives wrong result for absolute paths!
12+
p.iterator.asScala.mkString("/")
1013

1114
trait SourceLink:
1215
val path: Option[Path] = None
@@ -34,7 +37,7 @@ case class WebBasedSourceLink(prefix: String, revision: String, subPath: String)
3437
override def render(path: Path, operation: String, line: Option[Int]): String =
3538
val action = if operation == "view" then "blob" else operation
3639
val linePart = line.fold("")(l => s"#L$l")
37-
s"$prefix/$action/$revision$subPath/$path$linePart"
40+
s"$prefix/$action/$revision$subPath/${pathToString(path)}$linePart"
3841

3942
object SourceLink:
4043
val SubPath = "([^=]+)=(.+)".r
@@ -173,4 +176,4 @@ object SourceLinks:
173176
ctx.args.revision,
174177
// TODO (https://github.com/lampepfl/scala3doc/issues/240): configure source root
175178
Paths.get("").toAbsolutePath
176-
)
179+
)

0 commit comments

Comments
 (0)