Skip to content

Commit 515cb9f

Browse files
authored
Merge pull request #12787 from BarkingBad/scaladoc/version-browser-docs
Update scaladoc docs
2 parents f003711 + 123b286 commit 515cb9f

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

docs/docs/usage/scaladoc/settings.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,20 @@ A base URL to use as prefix and add `canonical` URLs to all pages. The canonical
117117
##### -siteroot
118118

119119
A directory containing static files from which to generate documentation. Default directory is `./docs`
120+
121+
##### -versions-dictionary-url
122+
123+
A URL pointing to a JSON document containing a dictionary: `version label -> documentation location`.
124+
The JSON file has single property `versions` that holds the dictionary associating the labels of specific versions of the documentation to the URLs pointing to their index.html
125+
Useful for libraries that maintain different versions of their documentation.
126+
127+
Example JSON file:
128+
```
129+
{
130+
"versions": {
131+
"3.0.x": "https://dotty.epfl.ch/3.0.x/docs/index.html",
132+
"Nightly": "https://dotty.epfl.ch/docs/index.html"
133+
}
134+
}
135+
```
136+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Site versioning
3+
---
4+
5+
# {{ page.title }}
6+
7+
Scaladoc provides a convenient way to switch between different versions of the documentation. The feature is useful if we want to expose older docs for users that didn't migrate to the new version of our library.
8+
9+
### How to setup it
10+
11+
The feature was designed for easy scalability with no need to regenerate all scaladocs after adding a new version. To do so a new setting is introduced: `-versions-dictionary-url`. Its argument must be a URL to a JSON document holding information about the locations of specific versions. The JSON file has single property `versions` that holds the dictionary associating the labels of specific versions of the documentation to the URLs pointing to their index.html
12+
13+
Example JSON file:
14+
```
15+
{
16+
"versions": {
17+
"3.0.x": "https://dotty.epfl.ch/3.0.x/docs/index.html",
18+
"Nightly": "https://dotty.epfl.ch/docs/index.html"
19+
}
20+
}
21+
```
22+
23+
This enforce us to provide the setting while generating docs for each of the versions, however it gives us more flexibility later. If you want to add a version of the API docs next to the previous 5 versions that you have already published, then you only need to upload the new docs to a web server and add a new entry to the JSON file. All versions of the site will now become aware of the new site version.
24+
25+
The important thing to note is that there is only one JSON file to avoid redundancy and each scaladoc must set up its URL location beforehand, for example, in sbt:
26+
27+
```
28+
doc / scalacOptions ++= Seq("-versions-dictionary-url", "https://dotty.epfl.ch/versions.json")
29+
```
30+
31+
32+
### How does it look from user perspective
33+
34+
Providing a JSON file via `-versions-dictionary-url` enables scaladoc to link between versions. It is also convenient to be able to change the revision label in the drop-down menu. Everything will change automatically.
35+
36+
![](../../../images/scaladoc/nightly.gif)

docs/images/scaladoc/nightly.gif

70.1 KB
Loading

scaladoc/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ sbt scaladoc/generateSelfDocumentation
2323
sbt scaladoc/generateScalaDocumentation
2424
```
2525

26-
To actually view the documentation, the easiest way is to run the following in project root:
26+
To actually view the documentation, the easiest way is to run the following in the project root:
2727

2828
```
29-
cd output
29+
cd scaladoc/output
3030
python3 -m http.server 8080
3131
```
3232

scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
9696
val versionsDictionaryUrl: Setting[String] = StringSetting(
9797
"-versions-dictionary-url",
9898
"versions dictionary url",
99-
"A URL pointing to a JSON document containing a dictionary version -> documentation location. Useful for libraries that maintain different releases docs",
99+
"A URL pointing to a JSON document containing a dictionary `version label -> documentation location`. " +
100+
"The JSON file has single property \"versions\" that holds dictionary of labels of specific docs and URL pointing to their index.html top-level file. " +
101+
"Useful for libraries that maintain different versions of their documentation.",
100102
""
101103
)
102104

0 commit comments

Comments
 (0)