Skip to content

Commit 89b4f72

Browse files
authored
DOC: Style version switcher button (numpy#21451)
* DOC: use PR ref as version name in CircleCI preview * DOC: style version button depending on release * DOC: fix logic for switcher_version. [skip actions] [skip azp] [skip travis] * DOC: provision empty dataset attribute and simplify not. [skip actions] [skip azp] [skip travis]
1 parent 7f5d234 commit 89b4f72

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

doc/source/_static/numpy.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,36 @@ h3 {
3232
letter-spacing: -.03em;
3333
}
3434

35+
/* Style the active version button.
36+
37+
- dev: orange
38+
- stable: green
39+
- old, PR: red
40+
41+
Colors from:
42+
43+
Wong, B. Points of view: Color blindness.
44+
Nat Methods 8, 441 (2011). https://doi.org/10.1038/nmeth.1618
45+
*/
46+
47+
/* If the active version has the name "dev", style it orange */
48+
#version_switcher_button[data-active-version-name*="dev"] {
49+
background-color: #E69F00;
50+
border-color: #E69F00;
51+
}
52+
53+
/* green for `stable` */
54+
#version_switcher_button[data-active-version-name*="stable"] {
55+
background-color: #009E73;
56+
border-color: #009E73;
57+
}
58+
59+
/* red for `old` */
60+
#version_switcher_button:not([data-active-version-name*="stable"], [data-active-version-name*="dev"], [data-active-version-name=""]) {
61+
background-color: #980F0F;
62+
border-color: #980F0F;
63+
}
64+
3565
/* Main page overview cards */
3666

3767
.intro-card {

doc/source/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ def setup(app):
172172
html_favicon = '_static/favicon/favicon.ico'
173173

174174
# Set up the version switcher. The versions.json is stored in the devdocs.
175-
if ".dev" in version:
175+
if os.environ.get('CIRCLE_JOB', False) and \
176+
os.environ.get('CIRCLE_BRANCH', '') != 'main':
177+
# For PR, name is set to its ref
178+
switcher_version = os.environ['CIRCLE_BRANCH']
179+
elif ".dev" in version:
176180
switcher_version = "devdocs"
177181
else:
178182
switcher_version = f"doc/{version}"

0 commit comments

Comments
 (0)