Skip to content

Commit 19946a2

Browse files
committed
[docs] add version warning to documentation for non-latest versions
1 parent f341828 commit 19946a2

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% if not is_latest %}
2+
<div style="
3+
background-color: #fff8dc;
4+
border: 1px solid #f0e68c;
5+
color: #555;
6+
padding: 10px 15px;
7+
text-align: center;
8+
font-size: 0.95rem;
9+
margin-bottom: 1rem;
10+
border-radius: 4px;
11+
box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
12+
">
13+
⚠ You are viewing documentation for version <b>{{ current_version }}</b>.
14+
The latest version is <a href="/en/latest/">here</a>.
15+
</div>
16+
{% endif %}

docs/source/conf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@
3333
# Add any Sphinx extension module names here, as strings. They can be
3434
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3535
# ones.
36+
37+
html_context = {
38+
"is_latest": os.environ.get("READTHEDOCS_VERSION_TYPE") == "latest",
39+
"current_version": os.environ.get("READTHEDOCS_VERSION", "unknown"),
40+
}
41+
html_sidebars = {
42+
"**": [
43+
"navbar-logo.html",
44+
"icon-links.html",
45+
"version-warning.html",
46+
"search-button-field.html",
47+
"sbt-sidebar-nav.html",
48+
]
49+
}
50+
3651
extensions = [
3752
"sphinx.ext.autodoc",
3853
"sphinx_copybutton",

0 commit comments

Comments
 (0)