You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* update supporting files
* improve code comments
* do switcher loading as a function; add warning banner function
* fix variable rename
* cleanup after rebase
* banner background color
* docs
* add TODO
* be forgiving about version specs
* update package-lock
* more documentation
* handle more prerelease indicators in version strings
* Update docs/user_guide/announcements.rst
* add HTML snippet to docs
* unrelated formatting fix
* disambiguate button message
* use parsable version string for stable entry in JSON
* update test for new color palette
* handle Bokeh case elegantly
In addition to the general-purpose announcement banner, the theme includes a built-in banner to warn users when they are viewing versions of your docs other than the latest stable version. To use this feature, add the following to your ``conf.py``:
51
+
52
+
.. code-block:: python
53
+
:caption: conf.py
54
+
55
+
html_theme_options = {
56
+
...
57
+
"show_version_warning_banner": True,
58
+
}
59
+
60
+
.. important::
61
+
62
+
This functionality relies on the :ref:`version switcher <version-dropdowns>` to determine the version number of the latest stable release.
63
+
*It will only work* if your version switcher ``.json`` has exactly one entry with property ``"preferred": true``
64
+
and your entries have ``version`` properties that are parsable by the `compare-versions node module <https://www.npmjs.com/package/compare-versions>`__, for example:
65
+
66
+
.. code-block:: json
67
+
68
+
{
69
+
"name": "stable",
70
+
"version": "9.9.9",
71
+
"url": "https://anything",
72
+
"preferred": true
73
+
}
74
+
75
+
If you want similar functionality for *older* versions of your docs (i.e. those built before the ``show_version_warning_banner`` configuration option was available), you can manually add a banner by prepending the following HTML to all pages (be sure to replace ``URL_OF_STABLE_VERSION_OF_PROJECT`` with a valid URL, and adjust styling as desired):
Copy file name to clipboardExpand all lines: docs/user_guide/version-dropdown.rst
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,5 @@
1
+
.. _version-dropdowns:
2
+
1
3
Version switcher dropdowns
2
4
==========================
3
5
@@ -40,6 +42,8 @@ each can have the following fields:
40
42
- ``url``: the URL for this version.
41
43
- ``name``: an optional name to display in the switcher dropdown instead of the
42
44
version string (e.g., "latest", "stable", "dev", etc.).
45
+
- ``preferred``: an optional field that *should occur on at most one entry* in the JSON file.
46
+
It specifies which version is considered "latest stable", and is used to customize the message used on :ref:`version-warning-banners` (if they are enabled).
0 commit comments