Skip to content

Update scaladoc docs #12787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/docs/usage/scaladoc/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,20 @@ A base URL to use as prefix and add `canonical` URLs to all pages. The canonical
##### -siteroot

A directory containing static files from which to generate documentation. Default directory is `./docs`

##### -versions-dictionary-url

A URL pointing to a JSON document containing a dictionary: `version label -> documentation location`.
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
Useful for libraries that maintain different versions of their documentation.

Example JSON file:
```
{
"versions": {
"3.0.x": "https://dotty.epfl.ch/3.0.x/docs/index.html",
"Nightly": "https://dotty.epfl.ch/docs/index.html"
}
}
```

36 changes: 36 additions & 0 deletions docs/docs/usage/scaladoc/site-versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Site versioning
---

# {{ page.title }}

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.

### How to setup it

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

Example JSON file:
```
{
"versions": {
"3.0.x": "https://dotty.epfl.ch/3.0.x/docs/index.html",
"Nightly": "https://dotty.epfl.ch/docs/index.html"
}
}
```

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.

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:

```
doc / scalacOptions ++= Seq("-versions-dictionary-url", "https://dotty.epfl.ch/versions.json")
```


### How does it look from user perspective

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.

![](../../../images/scaladoc/nightly.gif)
Binary file added docs/images/scaladoc/nightly.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scaladoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ sbt scaladoc/generateSelfDocumentation
sbt scaladoc/generateScalaDocumentation
```

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

```
cd output
cd scaladoc/output
python3 -m http.server 8080
```

Expand Down
4 changes: 3 additions & 1 deletion scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
val versionsDictionaryUrl: Setting[String] = StringSetting(
"-versions-dictionary-url",
"versions dictionary url",
"A URL pointing to a JSON document containing a dictionary version -> documentation location. Useful for libraries that maintain different releases docs",
"A URL pointing to a JSON document containing a dictionary `version label -> documentation location`. " +
"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. " +
"Useful for libraries that maintain different versions of their documentation.",
""
)

Expand Down