Skip to content

Commit ad76ed7

Browse files
committed
Apply requested changes
1 parent 4cb278e commit ad76ed7

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

project/Build.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,18 @@ object Build {
11831183
val generateScalaDocumentation = inputKey[Unit]("Generate documentation for dotty lib")
11841184
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
11851185

1186+
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).
1187+
dependsOn(`scala3-compiler-bootstrapped`).
1188+
settings(commonBootstrappedSettings)
1189+
lazy val `scaladoc-js` = project.in(file("scaladoc-js")).
1190+
enablePlugins(DottyJSPlugin).
1191+
dependsOn(`scala3-library-bootstrappedJS`).
1192+
settings(
1193+
Test / fork := false,
1194+
scalaJSUseMainModuleInitializer := true,
1195+
libraryDependencies += ("org.scala-js" %%% "scalajs-dom" % "1.1.0").cross(CrossVersion.for3Use2_13)
1196+
)
1197+
11861198
def generateDocumentation(targets: Seq[String], name: String, outDir: String, ref: String, params: Seq[String] = Nil) =
11871199
Def.taskDyn {
11881200
val distLocation = (dist / pack).value
@@ -1215,8 +1227,8 @@ object Build {
12151227
dependsOn(`scala3-tasty-inspector`).
12161228
settings(inConfig(SourceLinksIntegrationTest)(Defaults.testSettings)).
12171229
settings(
1218-
scalaSource in SourceLinksIntegrationTest := baseDirectory.value / "test-source-links",
1219-
test in SourceLinksIntegrationTest := ((test in SourceLinksIntegrationTest) dependsOn generateScalaDocumentation.toTask("")).value,
1230+
SourceLinksIntegrationTest / scalaSource := baseDirectory.value / "test-source-links",
1231+
SourceLinksIntegrationTest / test:= ((SourceLinksIntegrationTest / test) dependsOn generateScalaDocumentation.toTask("")).value,
12201232
).
12211233
settings(
12221234
Compile / resourceGenerators += Def.task {

scaladoc/src/dotty/tools/scaladoc/SourceLinks.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,3 @@ object SourceLinks:
140140
)
141141
SourceLinks(sourceLinks)
142142
}
143-

scaladoc/src/dotty/tools/scaladoc/tasty/NameNormalizer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ object NameNormalizer {
2121
private val ignoredKeywords: Set[String] = Set("this")
2222

2323
private def escapedName(name: String) =
24-
val simpleIdentifierRegex = "([([{}]) ]|[^A-Za-z0-9$]_)".r
24+
val complexIdentifierRegex = """([([{}]) ]|[^A-Za-z0-9$]_)""".r
2525
name match
2626
case n if ignoredKeywords(n) => n
27-
case n if keywords(termName(n)) || simpleIdentifierRegex.findFirstIn(n).isDefined => s"`$n`"
27+
case n if keywords(termName(n)) || complexIdentifierRegex.findFirstIn(n).isDefined => s"`$n`"
2828
case _ => name
2929
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import org.junit.Test
1616

1717
class RemoteLinksTest:
1818

19-
Random.setSeed(123L)
19+
class TimeoutException extends Exception
20+
21+
Random.setSeed(125L)
2022
val mtslAll = membersToSourceLinks(using testDocContext())
2123

2224
@Test
@@ -25,7 +27,7 @@ class RemoteLinksTest:
2527

2628
@Test
2729
def scala3SourceLink =
28-
assertTrue(mtslAll.find((k, _) => k == "FromDigits").isDefined) // source link to Scala3 stdlib class
30+
assertTrue(mtslAll.find((k, _) => k == "PolyFunction").isDefined) // source link to Scala3 stdlib class
2931

3032
@Test
3133
def runTest =
@@ -44,20 +46,23 @@ class RemoteLinksTest:
4446
catch
4547
case e: java.lang.IllegalArgumentException =>
4648
report.error(s"Could not open link for $link - invalid URL")(using testContext)
49+
case e: TimeoutException =>
50+
report.error(s"Tried to open link $link 16 times but with no avail")(using testContext)
4751
case e: org.jsoup.HttpStatusException => e.getStatusCode match
4852
case 404 => throw AssertionError(s"Page $link does not exists")
4953
case n => report.warning(s"Could not open link for $link, return code $n")(using testContext)
5054
}
5155
assertNoErrors(testContext.reportedDiagnostics)
5256

53-
private def getDocumentFromUrl(link: String): Document =
57+
private def getDocumentFromUrl(link: String, retries: Int = 16): Document =
5458
try
59+
if retries == 0 then throw TimeoutException()
5560
Jsoup.connect(link).get
5661
catch
5762
case e: org.jsoup.HttpStatusException => e.getStatusCode match
5863
case 429 =>
5964
Thread.sleep(10)
60-
getDocumentFromUrl(link)
65+
getDocumentFromUrl(link, retries - 1)
6166
case n =>
6267
throw e
6368

0 commit comments

Comments
 (0)