Make Rustdoc refer to my local copy of the libstd documentation instead of linking out to

Hello all,

One of my favorite parts about Rust is the ability to generate fully fledged searchable HTML documentation from the source code. With a single call to cargo doc, I can generate a fully local, copy of the documentation for every crate my project depends on, which (at least for me) solves one of the biggest hurdles to being a productive developer without an internet connection. But there's one slight problem. When asked to generate links between crates, Rustdoc emits a link to other local HTML files, but when linking to the standard library, it links out to the online documentation. Although I do have a local copy of the standard library docs (obtained via rustup), and it's trivial to manually rewrite the URL since the folder structure is the same, it's annoying to say the least to have to do every time. Is it possible to inform Rustdoc of the path to my local copy and have it generate links to that instead, and if not, how hard would it be to add that functionality? I'm looking for a good first contribution to a large open source project. Failing that, is there an existing postprocessor that can rewrite the links in the generated HTML, or would that be a good idea for a next project?

Will defining a custom command alias be acceptable to you? Like

alias doc-local="cargo doc | rg '' target/ -l | xargs sed -i 's#'"

There is an unstable --extern-html-root-url flag, but I've never been able to get it to work.

As an alternative, it's straightforward to substitute the URLs using a command-line (works on Linux, Mac and WSL on Windows):

find . -type f -name "*.html" -exec sed -i \
's;https://external;file:///internal;g' {} +