From 8554cf430222eef1f0e320696f330fb77521c127 Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Thu, 5 May 2022 18:17:30 +0200 Subject: [PATCH 1/2] 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: https://github.com/scala/docs.scala-lang/pull/2391/commits/763d51842a16cf2398087a4a1af3c914fbbd8179 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. --- docs/_docs/reference/changed-features/changed-features.md | 1 + docs/_docs/reference/contextual/contextual.md | 1 + docs/_docs/reference/dropped-features/dropped-features.md | 1 + docs/_docs/reference/metaprogramming/metaprogramming.md | 1 + .../{other-new-types.md => other-new-features.md} | 1 + docs/sidebar.yml | 2 +- project/resources/referenceReplacements/sidebar.yml | 2 +- 7 files changed, 7 insertions(+), 2 deletions(-) rename docs/_docs/reference/other-new-features/{other-new-types.md => other-new-features.md} (82%) diff --git a/docs/_docs/reference/changed-features/changed-features.md b/docs/_docs/reference/changed-features/changed-features.md index e8eb2ac6714b..6f47e15dd879 100644 --- a/docs/_docs/reference/changed-features/changed-features.md +++ b/docs/_docs/reference/changed-features/changed-features.md @@ -2,6 +2,7 @@ layout: index title: "Other Changed Features" movedTo: https://docs.scala-lang.org/scala3/reference/changed-features.html +redirectFrom: /changed-features.html --- The following pages document the features that have changed in Scala 3, compared to Scala 2. diff --git a/docs/_docs/reference/contextual/contextual.md b/docs/_docs/reference/contextual/contextual.md index 67200a7626ca..838325e169dc 100644 --- a/docs/_docs/reference/contextual/contextual.md +++ b/docs/_docs/reference/contextual/contextual.md @@ -2,6 +2,7 @@ layout: index title: "Contextual Abstractions" movedTo: https://docs.scala-lang.org/scala3/reference/contextual.html +redirectFrom: /contextual.html --- ### Critique of the Status Quo diff --git a/docs/_docs/reference/dropped-features/dropped-features.md b/docs/_docs/reference/dropped-features/dropped-features.md index 51fbbc8a26ab..4b53c64f1489 100644 --- a/docs/_docs/reference/dropped-features/dropped-features.md +++ b/docs/_docs/reference/dropped-features/dropped-features.md @@ -2,6 +2,7 @@ layout: index title: "Dropped Features" movedTo: https://docs.scala-lang.org/scala3/reference/dropped-features.html +redirectFrom: /dropped-features.html --- The following pages document the features of Scala 2 that have been dropped in Scala 3. diff --git a/docs/_docs/reference/metaprogramming/metaprogramming.md b/docs/_docs/reference/metaprogramming/metaprogramming.md index 6b682d3ce237..4c6f8eb9328f 100644 --- a/docs/_docs/reference/metaprogramming/metaprogramming.md +++ b/docs/_docs/reference/metaprogramming/metaprogramming.md @@ -2,6 +2,7 @@ layout: index title: "Metaprogramming" movedTo: https://docs.scala-lang.org/scala3/reference/metaprogramming.html +redirectFrom: /metaprogramming.html --- The following pages introduce the redesign of metaprogramming in Scala. They diff --git a/docs/_docs/reference/other-new-features/other-new-types.md b/docs/_docs/reference/other-new-features/other-new-features.md similarity index 82% rename from docs/_docs/reference/other-new-features/other-new-types.md rename to docs/_docs/reference/other-new-features/other-new-features.md index 6264bd95c3f1..06c79c6a5fe8 100644 --- a/docs/_docs/reference/other-new-features/other-new-types.md +++ b/docs/_docs/reference/other-new-features/other-new-features.md @@ -2,6 +2,7 @@ layout: index title: "Other New Features" movedTo: https://docs.scala-lang.org/scala3/reference/other-new-features.html +redirectFrom: /other-new-features.html --- The following pages document new features of Scala 3. diff --git a/docs/sidebar.yml b/docs/sidebar.yml index 95786121e8f4..e3d496822003 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -69,7 +69,7 @@ subsection: - page: reference/metaprogramming/reflection.md - page: reference/metaprogramming/tasty-inspect.md - title: Other New Features - index: reference/other-new-features/other-new-types.md + index: reference/other-new-features/other-new-features.md subsection: - page: reference/other-new-features/trait-parameters.md - page: reference/other-new-features/transparent-traits.md diff --git a/project/resources/referenceReplacements/sidebar.yml b/project/resources/referenceReplacements/sidebar.yml index 680b44d353d4..a9a4d23c869f 100644 --- a/project/resources/referenceReplacements/sidebar.yml +++ b/project/resources/referenceReplacements/sidebar.yml @@ -49,7 +49,7 @@ subsection: - page: reference/metaprogramming/reflection.md - page: reference/metaprogramming/tasty-inspect.md - title: Other New Features - index: reference/other-new-features/other-new-types.md + index: reference/other-new-features/other-new-features.md subsection: - page: reference/other-new-features/trait-parameters.md - page: reference/other-new-features/transparent-traits.md From e17894ef4a68f11dba0d6192e2f558d179b59240 Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Fri, 6 May 2022 08:53:40 +0200 Subject: [PATCH 2/2] Alternative implementation that alters only the documentation published to docs.scala-lang.org/scala3/reference --- .../reference/changed-features/changed-features.md | 1 - docs/_docs/reference/contextual/contextual.md | 1 - .../reference/dropped-features/dropped-features.md | 1 - .../reference/metaprogramming/metaprogramming.md | 1 - .../other-new-features/other-new-features.md | 1 - project/Build.scala | 12 ++++++++++++ 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/_docs/reference/changed-features/changed-features.md b/docs/_docs/reference/changed-features/changed-features.md index 6f47e15dd879..e8eb2ac6714b 100644 --- a/docs/_docs/reference/changed-features/changed-features.md +++ b/docs/_docs/reference/changed-features/changed-features.md @@ -2,7 +2,6 @@ layout: index title: "Other Changed Features" movedTo: https://docs.scala-lang.org/scala3/reference/changed-features.html -redirectFrom: /changed-features.html --- The following pages document the features that have changed in Scala 3, compared to Scala 2. diff --git a/docs/_docs/reference/contextual/contextual.md b/docs/_docs/reference/contextual/contextual.md index 838325e169dc..67200a7626ca 100644 --- a/docs/_docs/reference/contextual/contextual.md +++ b/docs/_docs/reference/contextual/contextual.md @@ -2,7 +2,6 @@ layout: index title: "Contextual Abstractions" movedTo: https://docs.scala-lang.org/scala3/reference/contextual.html -redirectFrom: /contextual.html --- ### Critique of the Status Quo diff --git a/docs/_docs/reference/dropped-features/dropped-features.md b/docs/_docs/reference/dropped-features/dropped-features.md index 4b53c64f1489..51fbbc8a26ab 100644 --- a/docs/_docs/reference/dropped-features/dropped-features.md +++ b/docs/_docs/reference/dropped-features/dropped-features.md @@ -2,7 +2,6 @@ layout: index title: "Dropped Features" movedTo: https://docs.scala-lang.org/scala3/reference/dropped-features.html -redirectFrom: /dropped-features.html --- The following pages document the features of Scala 2 that have been dropped in Scala 3. diff --git a/docs/_docs/reference/metaprogramming/metaprogramming.md b/docs/_docs/reference/metaprogramming/metaprogramming.md index 4c6f8eb9328f..6b682d3ce237 100644 --- a/docs/_docs/reference/metaprogramming/metaprogramming.md +++ b/docs/_docs/reference/metaprogramming/metaprogramming.md @@ -2,7 +2,6 @@ layout: index title: "Metaprogramming" movedTo: https://docs.scala-lang.org/scala3/reference/metaprogramming.html -redirectFrom: /metaprogramming.html --- The following pages introduce the redesign of metaprogramming in Scala. They diff --git a/docs/_docs/reference/other-new-features/other-new-features.md b/docs/_docs/reference/other-new-features/other-new-features.md index 06c79c6a5fe8..6264bd95c3f1 100644 --- a/docs/_docs/reference/other-new-features/other-new-features.md +++ b/docs/_docs/reference/other-new-features/other-new-features.md @@ -2,7 +2,6 @@ layout: index title: "Other New Features" movedTo: https://docs.scala-lang.org/scala3/reference/other-new-features.html -redirectFrom: /other-new-features.html --- The following pages document new features of Scala 3. diff --git a/project/Build.scala b/project/Build.scala index a581cd26aa38..16f45f50befb 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1381,21 +1381,33 @@ object Build { generateDocumentation(Testcases) }.value, + // Generate the Scala 3 reference documentation (published at https://docs.scala-lang.org/scala3/reference) generateReferenceDocumentation := Def.inputTaskDyn { val shouldRegenerateExpectedLinks = (Space ~> literal("--no-regenerate-expected-links")).?.parsed.isEmpty generateStaticAssetsTask.value + // Move all the source files to a temporary directory and apply some changes specific to the reference documentation val temp = IO.createTemporaryDirectory IO.copyDirectory(file("docs"), temp / "docs") IO.delete(temp / "docs" / "_blog") + // Overwrite the main layout and the sidebar IO.copyDirectory( file("project") / "resources" / "referenceReplacements", temp / "docs", overwrite = true ) + // Add redirections from previously supported URLs, for some pages + for (name <- Seq("changed-features", "contextual", "dropped-features", "metaprogramming", "other-new-features")) { + val path = temp / "docs" / "_docs" / "reference" / name / s"${name}.md" + val contentLines = IO.read(path).linesIterator.to[collection.mutable.ArrayBuffer] + contentLines.insert(1, s"redirectFrom: /${name}.html") // Add redirection + val newContent = contentLines.mkString("\n") + IO.write(path, newContent) + } + val languageReferenceConfig = Def.task { Scala3.value .add(OutputDir("scaladoc/output/reference"))