forked from esp-rs/esp-hal
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch the generated documentation to include a version selector
- Loading branch information
1 parent
775eff6
commit 816e7a5
Showing
5 changed files
with
168 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div style="margin-top: 0.5rem; width: 100%"> | ||
<label for="version-select">Version:</label> | ||
<select id="version-select" name="version-select" style="text-align: center; width: 100%"> | ||
<option value="{{ version }}" selected="selected">{{ version }}</option> | ||
</select> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
const select = document.querySelector("#version-select"); | ||
select.addEventListener("change", (e) => { | ||
const selected = select.value; | ||
// Replace the existing version number in the URL with the newly | ||
// selected version: | ||
let href = window.location.href; | ||
href = href.replace(/[\d]+\.[\d]+\.[\d]+[^\/]*/g, selected); | ||
// Redirect to the new URL: | ||
window.location.href = href; | ||
}); | ||
document.addEventListener("DOMContentLoaded", (e) => { | ||
const selected = select.value; | ||
// Remove any options currently present in the select box: | ||
for (let child of select.children) { | ||
child.remove(); | ||
} | ||
// Load the manifest JSON file and re-populate the select box with new | ||
// options for all available versions: | ||
const manifestUrl = "{{ base_url }}/{{ package }}/manifest.json"; | ||
fetch(manifestUrl) | ||
.then((res) => res.json()) | ||
.then(({ versions }) => { | ||
for (let version of versions) { | ||
let option = document.createElement("option"); | ||
option.text = version; | ||
option.value = version; | ||
select.appendChild(option); | ||
} | ||
select.value = selected; | ||
}) | ||
.catch((err) => console.error(err)); | ||
}); | ||
</script> |
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
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
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
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