Skip to content

Commit 8252ee6

Browse files
authored
Add redirections from old URLs to avoid breakages (#15118)
* Add redirections from old URLs to avoid breakages The Scala 3 reference documentation that used to be published to https://docs.scala-lang.org was using some different URLs than the URLs used by the documentation produced by Scaladoc. You can see here some examples of breakages: scala/docs.scala-lang@763d518 We add redirects from previously supported URLs to avoid such breakages in case there are links in the web that point to the old URLs.
1 parent 5675a8d commit 8252ee6

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

docs/sidebar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ subsection:
6969
- page: reference/metaprogramming/reflection.md
7070
- page: reference/metaprogramming/tasty-inspect.md
7171
- title: Other New Features
72-
index: reference/other-new-features/other-new-types.md
72+
index: reference/other-new-features/other-new-features.md
7373
subsection:
7474
- page: reference/other-new-features/trait-parameters.md
7575
- page: reference/other-new-features/transparent-traits.md

project/Build.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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"))

project/resources/referenceReplacements/sidebar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ subsection:
4949
- page: reference/metaprogramming/reflection.md
5050
- page: reference/metaprogramming/tasty-inspect.md
5151
- title: Other New Features
52-
index: reference/other-new-features/other-new-types.md
52+
index: reference/other-new-features/other-new-features.md
5353
subsection:
5454
- page: reference/other-new-features/trait-parameters.md
5555
- page: reference/other-new-features/transparent-traits.md

0 commit comments

Comments
 (0)