8000 DOC: Restore banner indicating docs are unreleased · matplotlib/matplotlib@45c932f · GitHub
[go: up one dir, main page]

Skip to content

Commit 45c932f

Browse files
committed
DOC: Restore banner indicating docs are unreleased
This was dropped when switching to the pydata-sphinx-theme. They have a method of adding an announcement, but because it's a pure text substitution, we can't have it automatically search like our old banner. While the theme also supports loading from an http resource, that would mean writing some JavaScript instead of automatically creating this div at build time. So override the theme component, and create the search link at build time.
1 parent d780621 commit 45c932f

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

doc/_static/mpl.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99
margin: 0;
1010
}
1111

12+
/* Make announcement an error colour for unreleased documentation, and sticky. */
13+
#unreleased-message.bd-header-announcement {
14+
border-bottom: solid var(--pst-color-danger-highlight);
15+
font-weight: var(--pst-admonition-font-weight-heading);
16+
position: sticky;
17+
top: 0;
18+
z-index: 1050;
19+
}
20+
21+
#unreleased-message.bd-header-announcement:after {
22+
background-color: var(--pst-color-danger);
23+
}
24+
25+
#unreleased-message.bd-header-announcement a {
26+
color: var(--pst-color-base-text);
27+
}
28+
1229
/* multi column TOC */
1330
.contents ul {
1431
list-style-type: none;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% set header_classes = ["bd-header-announcement", "container-fluid"] %}
2+
{%- if '+' in release %}
3+
<div class="{{ header_classes | join(' ') }} bd-header-announcement" id="unreleased-message">
4+
<div class="bd-header-announcement__content">
5+
You are reading documentation for the unreleased version of Matplotlib.
6+
<a href="https://matplotlib.org/search.html?q={{ title | striptags | urlencode }}&amp;check_keywords=yes&amp;area=default">
7+
Try searching for the released version of this page instead?
8+
</a>
9+
</div>
10+
</div>
11+
{%- endif %}

doc/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,10 @@ def js_tag_with_cache_busting(js):
462462
},
463463
"navbar_end": ["theme-switcher", "version-switcher", "mpl_icon_links"],
464464
"secondary_sidebar_items": "page-toc.html",
465-
"footer_start": ["copyright", "sphinx-version", "doc_version"],
465+
"footer_start": ["copyright", "sphinx-version", "doc_version"],
466+
# We override the announcement template from pydata-sphinx-theme, so just
467+
# set a placeholder True here so that the parent template includes it.
468+
"announcement": True,
466469
}
467470
include_analytics = is_release_build
468471
if include_analytics:

0 commit comments

Comments
 (0)
0