Created
October 15, 2024 19:39
-
-
Save tsibley/3c89f2342489e9a790e6d8e41e8752fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Revert *some* of what RTD's force-readthedocs-addons.js does. | |
* | |
* <https://github.com/readthedocs/common/blob/c766aa84a01b74d83c5fac061d92e31d512df99f/dockerfiles/force-readthedocs-addons.js#L96-L118> | |
*/ | |
let esc = text => String(text).replace(/[&<>"']/g, x => `&#${x.charCodeAt(0)};`); | |
// This HTML is very specific to sphinx_rtd_theme. | |
let rstVersions = ` | |
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="Versions"> | |
<span class="rst-current-version" data-toggle="rst-current-version"> | |
<span class="fa fa-book"> Read the Docs</span> | |
v: ${esc(window.READTHEDOCS_DATA.version)} | |
<span class="fa fa-caret-down"></span> | |
</span> | |
<div class="rst-other-versions"></div> | |
</div> | |
`; | |
document.body.insertAdjacentHTML("beforeend", rstVersions); | |
let docEmbedCss = document.createElement("link"); | |
docEmbedCss.rel = "stylesheet"; | |
docEmbedCss.href = "/_/static/css/readthedocs-doc-embed.css"; | |
document.head.append(docEmbedCss); | |
let docEmbedJs = document.createElement("script"); | |
docEmbedJs.src = "/_/static/core/js/readthedocs-doc-embed.js"; | |
document.body.append(docEmbedJs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment