Skip to content

Commit 6a3f467

Browse files
committed
Try relative and absolute path in PathBased
1 parent 93b300f commit 6a3f467

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ object Build {
14161416
.add(ProjectVersion("3.1.2")) // TODO: Change that later to the current version tag. (This must happen on first forward this branch to stable release tag)
14171417
.remove[VersionsDictionaryUrl]
14181418
.add(SourceLinks(List(
1419-
dottySrcLink(referenceVersion, temp.getAbsolutePath + "=")
1419+
dottySrcLink("language-reference-stable", temp.getAbsolutePath + "=")
14201420
)))
14211421
.withTargets(List("___fake___.scala"))
14221422
}

scaladoc/src/dotty/tools/scaladoc/PathBased.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import java.nio.file.{Path, Paths}
44

55
case class PathBased[T](entries: List[PathBased.Entry[T]], projectRoot: Path):
66
def get(path: Path): Option[PathBased.Result[T]] =
7-
if path.isAbsolute && path.startsWith(projectRoot) then get(projectRoot.relativize(path))
8-
else entries.filter(_.path.forall(p => path.startsWith(p))).maxByOption(_.path.map(_.toString.length)).map(entry =>
9-
PathBased.Result(entry.path.fold(path)(_.relativize(path)), entry.elem)
10-
)
7+
val paths = Option.when(path.isAbsolute && path.startsWith(projectRoot))(projectRoot.relativize(path)).toSeq :+ path
8+
paths.iterator.to(LazyList).flatMap { path =>
9+
entries.filter(_.path.forall(p => path.startsWith(p))).maxByOption(_.path.map(_.toString.length)).map(entry =>
10+
PathBased.Result(entry.path.fold(path)(_.relativize(path)), entry.elem)
11+
)
12+
}.headOption
1113

1214
trait ArgParser[T]:
1315
def parse(s: String): Either[String, T]

scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ case class LoadedTemplate(
4343
def getMap(key: String) = templateFile.settings.getOrElse(key, Map.empty).asInstanceOf[Map[String, Object]]
4444

4545
val sourceLinks = if !templateFile.file.exists() then Nil else
46-
// TODO (https://github.com/lampepfl/scala3doc/issues/240): configure source root
47-
// toRealPath is used to turn symlinks into proper paths
48-
val actualPath = Paths.get("").toAbsolutePath.relativize(templateFile.file.toPath.toRealPath())
46+
val actualPath = templateFile.file.toPath
4947
ctx.sourceLinks.pathTo(actualPath).map("viewSource" -> _ ) ++
5048
ctx.sourceLinks.pathTo(actualPath, operation = "edit").map("editSource" -> _)
5149

0 commit comments

Comments
 (0)