Skip to content

Refactor expected links test #14863

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
Show file tree
Hide file tree
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
12 changes: 4 additions & 8 deletions .github/workflows/scaladoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ jobs:
- name: Generate testcases documentation
run: ./project/scripts/sbt scaladoc/generateTestcasesDocumentation

- name: Generate reference documentation and check links stability
run: |
./project/scripts/sbt scaladoc/generateReferenceDocumentation
./project/scripts/docsLinksStability ./scaladoc/output/reference ./project/scripts/expected-links/reference-expected-links.txt
- name: Generate reference documentation
run: ./project/scripts/sbt scaladoc/generateReferenceDocumentation --no-regenerate-expected-links

- name: Generate Scala 3 documentation and check links stability
run: |
./project/scripts/sbt scaladoc/generateScalaDocumentation
./project/scripts/docsLinksStability ./scaladoc/output/scala3 ./project/scripts/expected-links/scala3-expected-links.txt
- name: Generate Scala 3 documentation
run: ./project/scripts/sbt scaladoc/generateScalaDocumentation

- name: Generate documentation for example project using dotty-sbt
run: ./project/scripts/sbt "sbt-test/scripted sbt-dotty/scaladoc"
Expand Down
20 changes: 16 additions & 4 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ object Build {
val generateScalaDocumentation = inputKey[Unit]("Generate documentation for dotty lib")
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")

val generateReferenceDocumentation = taskKey[Unit]("Generate language reference documentation for Scala 3")
val generateReferenceDocumentation = inputKey[Unit]("Generate language reference documentation for Scala 3")

lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).
dependsOn(`scala3-compiler-bootstrapped`).
Expand Down Expand Up @@ -1376,7 +1376,9 @@ object Build {
generateDocumentation(Testcases)
}.value,

generateReferenceDocumentation := Def.taskDyn {
generateReferenceDocumentation := Def.inputTaskDyn {
val shouldRegenerateExpectedLinks = literal("--no-regenerate-expected-links").?.parsed.isEmpty

val temp = IO.createTemporaryDirectory
IO.copyDirectory(file("docs"), temp / "docs")
IO.delete(temp / "docs" / "_blog")
Expand All @@ -1399,8 +1401,18 @@ object Build {
.withTargets(List("___fake___.scala"))
}

generateDocumentation(languageReferenceConfig)
}.value,
val expectedLinksRegeneration = Def.task {
if (shouldRegenerateExpectedLinks) {
val script = (file("project") / "scripts" / "regenerateExpectedLinks").toString
val outputDir = languageReferenceConfig.value.get[OutputDir].get.value
val expectedLinksFile = (file("project") / "scripts" / "expected-links" / "reference-expected-links.txt").toString
import _root_.scala.sys.process._
s"$script $outputDir $expectedLinksFile" !
}
}

expectedLinksRegeneration.dependsOn(generateDocumentation(languageReferenceConfig))
}.evaluated,

Test / buildInfoKeys := Seq[BuildInfoKey](
(Test / Build.testcasesOutputDir),
Expand Down
Loading