8000 Backport PR #16255 on branch v2.2.x (Move version info to sidebar) by timhoffm · Pull Request #16352 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #16255 on branch v2.2.x (Move version info to sidebar) #16352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions doc/_static/mpl.css
Original file line number Diff line number Diff line change
Expand Up @@ -1006,15 +1006,24 @@ div.viewcode-block:target {

}

.sidebar-announcement {
.sidebar-announcement,
.sidebar-versions {
border: 1px solid #11557C;
background: #eff9ff;
padding: 2px;
padding: 0.2em 0.5em;
margin-top: 1em;
}

.sidebar-announcement {
margin-top: 40px;
}

.sidebar-versions {
margin-top: 1em;
}

.sidebar-announcement p {
margin: 0.4em 0.4em 0.6em 0.4em;
margin: 0.4em 0 0.6em 0;
}

/* new main nav */
Expand Down
38 changes: 38 additions & 0 deletions doc/_templates/sidebar_versions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div class="sidebar-versions">
<script>
function getSnippet(id, url) {
var req = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch (e) {
req = false;
}
} else if (window.ActiveXObject) {
// For Internet Explorer on Windows
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
req = false;
}
}
}
var element = document.querySelector(".sidebar-versions");
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', url, false);
req.send(null);
if (req.status == 200) {
element.innerHTML = req.responseText;
} else {
element.innerHTML = "<mark>Could not find Snippet to insert at " + url + "</mark>"
}
}
}
getSnippet('other_versions', '/versions.html');
</script>
</div>
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def _check_deps():

# Custom sidebar templates, maps page names to templates.
html_sidebars = {
'index': ['searchbox.html', 'sidebar_announcement.html',
'index': ['searchbox.html', 'sidebar_announcement.html', 'sidebar_versions.html',
'donate_sidebar.html'],
'**': ['searchbox.html', 'localtoc.html', 'relations.html',
'pagesource.html']
Expand Down
43 changes: 0 additions & 43 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,51 +54,8 @@ Visit the :doc:`Matplotlib installation instructions <users/installing>`.
Documentation
-------------

This is the documentation for Matplotlib version |version|.

To get started, read the :doc:`User's Guide <users/index>`.

.. raw:: html

<p id="other_versions"></p>

<script>
function getSnippet(id, url) {
var req = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch (e) {
req = false;
}
} else if (window.ActiveXObject) {
// For Internet Explorer on Windows
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
req = false;
}
}
}
var element = document.getElementById(id);
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', url, false);
req.send(null);
if (req.status == 200) {
element.innerHTML = req.responseText;
} else {
element.innerHTML = "<mark>Could not find Snippet to insert at " + url + "</mark>"
}
}
}
getSnippet('other_versions', '/versions.html');
</script>

Trying to learn how to do a particular kind of plot? Check out the
:doc:`examples gallery <gallery/index>` or the :doc:`list of plotting commands
<api/pyplot_summary>`.
Expand Down
0