Skip to content

Commit 827b301

Browse files
committed
Search for name in range of lines and add flexible sourcelinks
1 parent b7aae46 commit 827b301

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

project/Build.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,16 @@ object Build {
12441244
// TODO add versions etc.
12451245
def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped/scala-$v/src_managed/main/$s-library-src"
12461246
def scalaSrcLink(v: String, s: String) = s"-source-links:$s=github://scala/scala/v$v#src/library"
1247-
def dottySrcLink(v: String, s: String) = s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
1247+
def dottySrcLink(v: String, s: String) = {
1248+
val srcLinks = sys.env.get("GITHUB_SHA") match {
1249+
case Some(sha) =>
1250+
s"-source-links:$s=github://${sys.env("GITHUB_REPOSITORY")}/$sha#library/src"
1251+
case None => s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
1252+
}
1253+
println("############ sourcelinks: " + srcLinks)
1254+
srcLinks
1255+
}
1256+
12481257

12491258
val revision = Seq("-revision", ref, "-project-version", projectVersion)
12501259
val cmd = Seq(

scaladoc/test-source-links/dotty/tools/scaladoc/source-links/RemoteLinksTest.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,23 @@ class RemoteLinksTest:
3636
@Test
3737
def runTest =
3838
assertTrue(mtslAll.nonEmpty)
39-
val mtsl = randomGenerator.shuffle(mtslAll).take(20) // take 20 random entries
39+
val mtsl = randomGenerator.shuffle(mtslAll.filter(_._1 != "Predef")).take(20) // take 20 random entries
4040
val pageToMtsl: Map[String, List[(String, String)]] = mtsl.groupMap(_._2.split("#L").head)(v => (v._1, v._2.split("#L").last))
4141
pageToMtsl.foreach { case (link, members) =>
4242
try
4343
val doc = getDocumentFromUrl(link)
44-
members.foreach { (member, line) =>
44+
println(s"Checking $link")
45+
members.foreach { case (member, expectedLine) =>
4546
if !member.startsWith("given_") then // TODO: handle synthetic givens, for now we disable them from testing
46-
val loc = doc.select(s"#LC$line").text
47+
val toLine = expectedLine + 3
4748
val memberToMatch = member.replace("`", "")
48-
assertTrue(s"Expected to find $memberToMatch at $link at line $line", loc.contains(memberToMatch))
49+
val lineCorrectlyDefined = (expectedLine.toInt until toLine.toInt).exists{ line =>
50+
val loc = doc.select(s"#LC$line").text
51+
52+
loc.contains(memberToMatch)
53+
}
54+
55+
assertTrue(s"Expected to find $memberToMatch at $link at lines $expectedLine-$toLine", lineCorrectlyDefined)
4956
}
5057
catch
5158
case e: java.lang.IllegalArgumentException =>

0 commit comments

Comments
 (0)