Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df5d59a

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 abb2059 commit df5d59a

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

doc/_static/mpl.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
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+
color: var(--pst-color-danger-text);
16+
font-weight: var(--pst-admonition-font-weight-heading);
17+
position: sticky;
18+
top: 0;
19+
z-index: 1050;
20+
}
21+
22+
#unreleased-message.bd-header-announcement:after {
23+
background-color: var(--pst-color-danger);
24+
opacity: 1;
25+
}
26+
27+
#unreleased-message.bd-header-announcement a {
28+
color: var(--pst-color-danger-text);
29+
}
30+
31+
#unreleased-message.bd-header-announcement + .bd-navbar {
32+
top: 3rem; /* Minimum height of announcement header. */
33+
}
34+
1235
/* multi column TOC */
1336
.contents ul {
1437
list-style-type: none;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{%- if theme_announcement == "unreleased" -%}
2+
{% set header_classes = ["bd-header-announcement", "container-fluid"] %}
3+
<div class="{{ header_classes | join(' ') }}" 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+
{%- else -%}
12+
{%- extends "!sections/announcement.html" -%}
13+
{%- endif %}

doc/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,11 @@ 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, where
467+
# this special value indicates the use of the unreleased banner. If we need
468+
# an actual announcement, then just place the text here as usual.
469+
"announcement": "unreleased" if not is_release_build else "",
466470
}
467471
include_analytics = is_release_build
468472
if include_analytics:

0 commit comments

Comments
 (0)