@@ -1381,21 +1381,33 @@ object Build {
13811381 generateDocumentation(Testcases )
13821382 }.value,
13831383
1384+ // Generate the Scala 3 reference documentation (published at https://docs.scala-lang.org/scala3/reference)
13841385 generateReferenceDocumentation := Def .inputTaskDyn {
13851386 val shouldRegenerateExpectedLinks = (Space ~> literal(" --no-regenerate-expected-links" )).? .parsed.isEmpty
13861387
13871388 generateStaticAssetsTask.value
13881389
1390+ // Move all the source files to a temporary directory and apply some changes specific to the reference documentation
13891391 val temp = IO .createTemporaryDirectory
13901392 IO .copyDirectory(file(" docs" ), temp / " docs" )
13911393 IO .delete(temp / " docs" / " _blog" )
13921394
1395+ // Overwrite the main layout and the sidebar
13931396 IO .copyDirectory(
13941397 file(" project" ) / " resources" / " referenceReplacements" ,
13951398 temp / " docs" ,
13961399 overwrite = true
13971400 )
13981401
1402+ // Add redirections from previously supported URLs, for some pages
1403+ for (name <- Seq (" changed-features" , " contextual" , " dropped-features" , " metaprogramming" , " other-new-features" )) {
1404+ val path = temp / " docs" / " _docs" / " reference" / name / s " ${name}.md "
1405+ val contentLines = IO .read(path).linesIterator.to[collection.mutable.ArrayBuffer ]
1406+ contentLines.insert(1 , s " redirectFrom: / ${name}.html " ) // Add redirection
1407+ val newContent = contentLines.mkString(" \n " )
1408+ IO .write(path, newContent)
1409+ }
1410+
13991411 val languageReferenceConfig = Def .task {
14001412 Scala3 .value
14011413 .add(OutputDir (" scaladoc/output/reference" ))
@@ -1404,7 +1416,7 @@ object Build {
14041416 .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)
14051417 .remove[VersionsDictionaryUrl ]
14061418 .add(SourceLinks (List (
1407- dottySrcLink(referenceVersion , temp.getAbsolutePath + " =" )
1419+ dottySrcLink(" language-reference-stable " , temp.getAbsolutePath + " =" )
14081420 )))
14091421 .withTargets(List (" ___fake___.scala" ))
14101422 }
0 commit comments