Skip to content

Scala3doc: fix rendering source links on Windows #10809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2020
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
9 changes: 6 additions & 3 deletions scala3doc/src/dotty/dokka/SourceLinks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import liqp.Template
import dotty.dokka.model.api._
import dotty.tools.dotc.core.Contexts.Context

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

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

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