diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-06-17 23:19:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-17 23:19:33 +0200 |
| commit | 0772ee7f8b2b4acac1f6e82b0f65a78b38817502 (patch) | |
| tree | 07e18ed42de3ccfc561e1b3402872b52acad4222 /src/librustdoc/html/static/js/src-script.js | |
| parent | 17ab49a94a9dd34c54852778310277a7a13cc006 (diff) | |
| parent | 00c104225fad5d3eb27dc37719d9b6c26844c389 (diff) | |
| download | rust-0772ee7f8b2b4acac1f6e82b0f65a78b38817502.tar.gz rust-0772ee7f8b2b4acac1f6e82b0f65a78b38817502.zip | |
Rollup merge of #142100 - lolbinarycat:rustdoc-srcIndex-138467, r=GuillaumeGomez
rustdoc: make srcIndex no longer a global variable this is one-time initialization data, it can just be a function parameter. while we're doing that, we can more the json parsing into the function and save a few extra bytes of storage for free, at least in the case of multiple crates in a doc bundle. fixes https://github.com/rust-lang/rust/issues/138467
Diffstat (limited to 'src/librustdoc/html/static/js/src-script.js')
| -rw-r--r-- | src/librustdoc/html/static/js/src-script.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/librustdoc/html/static/js/src-script.js b/src/librustdoc/html/static/js/src-script.js index b9ab6e85603..0c6afbeed22 100644 --- a/src/librustdoc/html/static/js/src-script.js +++ b/src/librustdoc/html/static/js/src-script.js @@ -1,6 +1,3 @@ -// From rust: -/* global srcIndex */ - // Local js definitions: /* global addClass, onEachLazy, removeClass, browserSupportsHistoryApi */ /* global updateLocalStorage, getVar, nonnull */ @@ -100,11 +97,15 @@ window.rustdocToggleSrcSidebar = () => { // This function is called from "src-files.js", generated in `html/render/write_shared.rs`. // eslint-disable-next-line no-unused-vars -function createSrcSidebar() { +/** + * @param {string} srcIndexStr - strinified json map from crate name to dir structure + */ +function createSrcSidebar(srcIndexStr) { const container = nonnull(document.querySelector("nav.sidebar")); const sidebar = document.createElement("div"); sidebar.id = "src-sidebar"; + const srcIndex = new Map(JSON.parse(srcIndexStr)); let hasFoundFile = false; |
