diff --git a/docs/docs/usage/scaladoc/settings.md b/docs/docs/usage/scaladoc/settings.md index bc5e10c8c1c1..d83f59472ffe 100644 --- a/docs/docs/usage/scaladoc/settings.md +++ b/docs/docs/usage/scaladoc/settings.md @@ -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" + } +} +``` + diff --git a/docs/docs/usage/scaladoc/site-versioning.md b/docs/docs/usage/scaladoc/site-versioning.md new file mode 100644 index 000000000000..69a3f6687825 --- /dev/null +++ b/docs/docs/usage/scaladoc/site-versioning.md @@ -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) diff --git a/docs/images/scaladoc/nightly.gif b/docs/images/scaladoc/nightly.gif new file mode 100644 index 000000000000..d6e764a032d5 Binary files /dev/null and b/docs/images/scaladoc/nightly.gif differ diff --git a/scaladoc/README.md b/scaladoc/README.md index d63a9551b64c..5f7560372976 100644 --- a/scaladoc/README.md +++ b/scaladoc/README.md @@ -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 ``` diff --git a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala index 542cba0bc84d..c857f37222fc 100644 --- a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala +++ b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala @@ -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.", "" )