Skip to content

Commit 4fff29b

Browse files
romanowskiBarkingBad
authored andcommitted
Search for name in range of lines and add flexible sourcelinks
1 parent 4c389a2 commit 4fff29b

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

docs/blog/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h1>{{ page.title }}</h1>
99
{% for post in site.posts %}
1010
<li>
1111
<h2>
12-
<a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>
12+
<a href="{{ post.url }}">{{ post.title }}</a>
1313
</h2>
1414
<div class="byline">
1515
<time class="date">

project/Build.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,13 @@ object Build {
12521252
// TODO add versions etc.
12531253
def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped/scala-$v/src_managed/main/$s-library-src"
12541254
def scalaSrcLink(v: String, s: String) = s"-source-links:$s=github://scala/scala/v$v#src/library"
1255-
def dottySrcLink(v: String, s: String) = s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
1255+
def dottySrcLink(v: String, s: String) =
1256+
sys.env.get("GITHUB_SHA") match {
1257+
case Some(sha) =>
1258+
s"-source-links:$s=github://${sys.env("GITHUB_REPOSITORY")}/$sha#library/src"
1259+
case None => s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
1260+
}
1261+
12561262
val revision = Seq("-revision", ref, "-project-version", projectVersion)
12571263
val cmd = Seq(
12581264
"-d",

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class RemoteLinksTest:
1919
class TimeoutException extends Exception
2020

2121
val randomGenerator = new Random(125L)
22-
val mtslAll = membersToSourceLinks(using testDocContext())
22+
// Predef has often problems with positions
23+
val mtslAll = membersToSourceLinks(using testDocContext()).filter(_._1 != "Predef")
2324

2425
@Test
2526
def scala213XSourceLink =
@@ -36,16 +37,23 @@ class RemoteLinksTest:
3637
@Test
3738
def runTest =
3839
assertTrue(mtslAll.nonEmpty)
39-
val mtsl = randomGenerator.shuffle(mtslAll).take(20) // take 20 random entries
40+
val mtsl = randomGenerator.shuffle(mtslAll).take(40) // take 40 random entries
4041
val pageToMtsl: Map[String, List[(String, String)]] = mtsl.groupMap(_._2.split("#L").head)(v => (v._1, v._2.split("#L").last))
4142
pageToMtsl.foreach { case (link, members) =>
4243
try
4344
val doc = getDocumentFromUrl(link)
44-
members.foreach { (member, line) =>
45+
println(s"Checking $link")
46+
members.foreach { case (member, expectedLine) =>
4547
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
48+
val toLine = expectedLine + 3
4749
val memberToMatch = member.replace("`", "")
48-
assertTrue(s"Expected to find $memberToMatch at $link at line $line", loc.contains(memberToMatch))
50+
val lineCorrectlyDefined = (expectedLine.toInt until toLine.toInt).exists{ line =>
51+
val loc = doc.select(s"#LC$line").text
52+
53+
loc.contains(memberToMatch)
54+
}
55+
56+
assertTrue(s"Expected to find $memberToMatch at $link at lines $expectedLine-$toLine", lineCorrectlyDefined)
4957
}
5058
catch
5159
case e: java.lang.IllegalArgumentException =>

0 commit comments

Comments
 (0)