Skip to content

Commit 2b1bce3

Browse files
committed
Fix some broken likns for static site and configure CI for nightly pushes to docs.scala-lang
1 parent 43c73b4 commit 2b1bce3

File tree

5 files changed

+49
-23
lines changed

5 files changed

+49
-23
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,12 @@ jobs:
470470
if: "(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.repository == 'lampepfl/dotty'"
471471
env:
472472
NIGHTLYBUILD: yes
473-
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} # If you need to change this:
474-
# Generate one at https://github.com/settings/tokens
475-
# Make sure you have the write permissions to the repo: https://github.com/lampepfl/dotty-website
473+
DOTTY_WEBSITE_BOT_TOKEN: ${{ secrets.BOT_TOKEN }} # If you need to change this:
474+
# Generate one at https://github.com/settings/tokens
475+
# Make sure you have the write permissions to the repo: https://github.com/lampepfl/dotty-website
476+
DOCS_SCALALANG_BOT_TOKEN: ${{ secrets.DOCS_SCALALANG_BOT_TOKEN }} # If you need to change this:
477+
# Generate one at https://github.com/settings/tokens
478+
# Make sure you have the write permissions to the repo: https://github.com/scala/docs.scala-lang
476479

477480
steps:
478481
- name: Reset existing repo
@@ -494,14 +497,26 @@ jobs:
494497
run: |
495498
./project/scripts/genDocs -doc-snapshot
496499
497-
- name: Deploy Website
500+
- name: Deploy Website to dotty-website
498501
uses: peaceiris/actions-gh-pages@v3
499502
with:
500-
personal_token: ${{ secrets.BOT_TOKEN }}
503+
personal_token: ${{ DOTTY_WEBSITE_BOT_TOKEN }}
501504
publish_dir: docs/_site
502505
external_repository: lampepfl/dotty-website
503506
publish_branch: gh-pages
504507

508+
- name: Generate docs.scala-lang preprocessed files
509+
run: |
510+
./project/scripts/genDocsScalaLang
511+
512+
- name: Deploy Website to docs.scala-lang
513+
uses: peaceiris/actions-gh-pages@v3
514+
with:
515+
personal_token: ${{ DOCS_SCALALANG_BOT_TOKEN }}
516+
publish_dir: docsScalaLang
517+
external_repository: scala/docs.scala-lang
518+
publish_branch: dev
519+
505520
publish_release:
506521
runs-on: [self-hosted, Linux]
507522
container:

docs/docs/usage/getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ For more information, read the [coursier-cli documentation](https://get-coursier
5050
You only need two tools to compile, run, test, and package a Scala project: Java 8 or 11, and sbt.
5151
To install these manually:
5252

53-
1. Download Java from [Oracle Java 8](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html), [Oracle Java 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html), or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail.
53+
1. Download Java from [Oracle Java 8](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html), [Oracle Java 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html), or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail.
5454
2. Install [sbt](https://www.scala-sbt.org/download.html)
5555

5656

@@ -87,7 +87,7 @@ hello-world/
8787
```
8888
The scala file `Main.scala` in `src/main/scala` is all we need for now.
8989

90-
More documentation about sbt can be found in the [Scala Book](/scala3/book/scala-tools.html) and in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html)
90+
More documentation about sbt can be found in the [Scala Book](https://docs.scala-lang.org/scala3/book/scala-tools.html) and in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html)
9191

9292

9393
{% comment %}
@@ -156,8 +156,8 @@ Then type `exit` or press `[Ctrl][d]` to exit sbt and return to your command lin
156156
Now that you’ve created a first “Hello, world” example with Scala 3, you’re ready for some next steps.
157157
Consider checking out:
158158

159-
- [The Scala 3 Book](/scala3/book/introduction.html), which provides a set of short lessons introducing Scala’s main features
160-
- [The migration guide](/scala3/guides/migration/compatibility-intro.html) helps you to migrate your existing Scala 2 code base to Scala 3.
159+
- [The Scala 3 Book](https://docs.scala-lang.org/scala3/book/introduction.html), which provides a set of short lessons introducing Scala’s main features
160+
- [The migration guide](https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html) helps you to migrate your existing Scala 2 code base to Scala 3.
161161

162162
When you want to connect with other Scala users, there are several mailing lists and real-time chat rooms available.
163163
Check out our [Scala community page](https://scala-lang.org/community/) for a list of these resources, and for where to reach out for help.

docs/docs/usage/scaladoc/search-engine.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ Inkuire works as a JavaScript worker in the browser thanks to the power of [Scal
8383

8484
To enable Inkuire when running scaladoc, add the flag `-Ygenerate-inkuire`. By adding this flag two files are generated:
8585
- `inkuire-db.json` - this is the file containing all the searchable declarations from the currently documented project in a format readable to the Inkuire search engine.
86-
- `inkuire-config.json` - this file contains the locations of the database files that should be searchable from the documentation of the current project. By default, it will be generated with the location of the local db file as well as the default implied locations of database files in [External mappings](/scala3/guides/scaladoc/settings.html#-external-mappings).
86+
- `inkuire-config.json` - this file contains the locations of the database files that should be searchable from the documentation of the current project. By default, it will be generated with the location of the local db file as well as the default implied locations of database files in [External mappings](https://docs.scala-lang.org/scala3/guides/scaladoc/settings.html#-external-mappings).

project/CopyDocs.scala

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ object CopyDocs {
2222
implicit def stringToFun(s: String): MyParams => String = _ => s
2323

2424
// Patterns, for convenience
25-
val titlePattern = "(?s)^---\n.*title: ([^\n]*).*---"
26-
val jekyllLinkPattern = """\{\% link _overviews/scala3-scaladoc(.*) %\}"""
25+
val titlePattern = "(?s)^---\n.*?title: ([^\n]*).*?---"
26+
val jekyllLinkPattern = """\{\% link _overviews/scala3-reference(.*) %\}"""
2727
val jekyllLinkSubstitution = "..$1"
28-
val jekyllLinkPattern2 = """\{\% link |_overviews/scala3-scaladoc/(.*) %\}"""
29-
val jekyllLinkSubstitution2 = "$1"
28+
val jekyllLinkPattern2 = """\{\% link _overviews/scala3-scaladoc(.*) %\}"""
29+
val jekyllLinkSubstitution2 = ".$1"
3030
val localLinkPattern = """\((?!http|www)(.*).html\)"""
3131
val localLinkSubstitution = "($1.md)"
3232

@@ -44,6 +44,22 @@ object CopyDocs {
4444
* The inner set is a collection of pairs `regex pattern` -> `substitution value`.
4545
*/
4646
val transformationMap: Map[String, Set[(String, MyParams => String)]] = Map(
47+
"docs/docs/usage/scaladoc/index.md" -> Set(
48+
("""\{\{ site\.baseurl \}\}/resources/images/scala3/scaladoc/logo\.svg""" -> "images/scaladoc-logo.png"),
49+
),
50+
51+
"docs/docs/usage/scaladoc/site-versioning.md" -> Set(
52+
("""/resources/images/scala3/scaladoc/nightly\.gif""" -> "images/scaladoc/nightly.gif"),
53+
),
54+
55+
"docs/docs/usage/scaladoc/search-engine.md" -> Set(
56+
("""/resources/images/scala3/scaladoc/inkuire-1\.0\.0-M2_js_flatMap\.gif""" -> "images/scaladoc/inkuire-1.0.0-M2_js_flatMap.gif"),
57+
),
58+
59+
"docs/docs/reference/other-new-features/explicit-nulls.md" -> Set(
60+
("""/resources/images/scala3/explicit-nulls/explicit-nulls-type-hierarchy\.png""" -> "images/explicit-nulls/explicit-nulls-type-hierarchy.png"),
61+
),
62+
4763
"docs/docs/reference/" -> (commonTransformations +
4864
(titlePattern -> ((p) => s"---\nlayout: doc-page\ntitle: $$1\nmovedTo: https://docs.scala-lang.org/scala3/reference/${p.newPath}.html\n---")),
4965
),
@@ -57,7 +73,9 @@ object CopyDocs {
5773
),
5874

5975
"docs/docs/usage/tools-worksheets" -> (commonTransformations +
60-
(titlePattern -> "---\nlayout: doc-page\ntitle: \"Worksheet mode with Dotty IDE\"\nmovedTo: https://docs.scala-lang.org/scala3/book/tools-worksheets.html\n---")
76+
(titlePattern -> "---\nlayout: doc-page\ntitle: \"Worksheet mode with Dotty IDE\"\nmovedTo: https://docs.scala-lang.org/scala3/book/tools-worksheets.html\n---") +
77+
("""/resources/images/scala3-book/intellij-worksheet\.png""" -> "images/worksheets/intellij-worksheet.png") +
78+
("""/resources/images/scala3-book/metals-worksheet\.png""" -> "images/worksheets/metals-worksheet.png")
6179
),
6280

6381
"docs/docs/resources/talks" -> (commonTransformations +
@@ -76,7 +94,7 @@ object CopyDocs {
7694
val fileContent = inputStream.getLines().mkString("\n")
7795

7896
new PrintStream(newPath.toFile) {
79-
val patterns = transformationMap.find { case (k, v) => path.toString.startsWith(k) }.map(_._2).getOrElse(Set.empty)
97+
val patterns = transformationMap.filter { case (k, v) => path.toString.startsWith(k) }.flatMap(_._2)
8098
val params = MyParams(newPath = s.stripPrefix("docs/docs/reference/").stripSuffix(".md"))
8199
val transformed = patterns.foldLeft(fileContent) { case (res, (pattern, substitution)) => res.replaceAll(pattern, substitution(params)) }
82100
write(transformed.getBytes("UTF8"))

project/scripts/genDocsScalaLang

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,3 @@ cp -f "$PWD/docs/docsScalaLangResources/scaladoc-assets.html" "$DOCS_SCALA_LANG_
4141

4242
# Hack inclusion of these assests by the docs.scala-lang jekyll builder
4343
echo "{% include scaladoc-assets.html %}" >> "$DOCS_SCALA_LANG_DIR/_layouts/inner-page-parent-dropdown.html"
44-
45-
# Push changes to fork branch
46-
cd $DOCS_SCALA_LANG_DIR
47-
git remote add barkingbad [email protected]:BarkingBad/docs.scala-lang.git
48-
git add .
49-
git commit -m "Update docs from dotty repo"
50-
git push -f barkingbad main:pregenerated-page

0 commit comments

Comments
 (0)