Skip to content

Commit

Permalink
Add link to Using bede from GH200 annoucement
Browse files Browse the repository at this point in the history
Fixes javascript for the updated sphinx-book-theme

Adds the ability to choose if the anchor is added to the full annoucncement or just the matched component.
  • Loading branch information
ptheywood committed Apr 19, 2024
1 parent 68ab1f1 commit 97ba084
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions _static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ so cannot use sphinx :ref: for output destination URIs relative to the current p
Instead, find the appropriate link within the current page, to add the anchor to the announcement.
This does not currently support linking outside of the documentation website.
*/
/* window.onload = function () {
expectedAnnouncementContent = "";
expectedAnchorContent = "";
var elements = document.getElementsByClassName("announcement");
window.onload = function () {
expectedAnnouncementContent = "Using Bede";
expectedAnchorContent = "Using Bede";
optionalTargetID = "grace-hopper-pilot"; // null if linking to page
fullAnnouncementAnchor = false;
var elements = document.getElementsByClassName("bd-header-announcement");
for (var i = 0; i < elements.length; i++) {
var element = elements.item(i);
originalContent = element.innerHTML;
Expand All @@ -28,10 +30,16 @@ This does not currently support linking outside of the documentation website.
// then append the optionalTargetID, which should no longer begin with a hash.
targetDestination += optionalTargetID;
}
newAnnouncementContent = '<a href="' + targetDestination + '">' + originalContent + '</a>'
element.innerHTML = newAnnouncementContent;
// Either wrap the full announcement body in the anchor, or just the expected anchor content
if (fullAnnouncementAnchor) {
newAnnouncementContent = '<a href="' + targetDestination + '">' + originalContent + '</a>'
element.innerHTML = newAnnouncementContent;
} else {
newAnnouncementContent = originalContent.replace(expectedAnchorContent, '<a href="' + targetDestination + '">' + expectedAnchorContent + '</a>')
element.innerHTML = newAnnouncementContent;
}
}
}
}
}
} */
}
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
# Code highlighting theme for dark mode
"pygment_dark_style": "github-dark-high-contrast",
# Add an announcement bar, visible at the top of each page.
"announcement": "3 NVIDIA Grace-Hopper nodes (GH200 480) are now available",
"announcement": "3 NVIDIA Grace-Hopper nodes (GH200 480) are now available. See Using Bede for more information.",
# Add the traditional footer theme and sphinx acknowledgements
"extra_footer": f"<p>&nbsp;Built with <a href=\"http://sphinx-doc.org/\">Sphinx</a> {sphinx.__version__} using a theme by the <a href=\"https://ebp.jupyterbook.org/\">Executable Book Project</a>.</p>"
}
Expand Down

0 comments on commit 97ba084

Please sign in to comment.