Rustdoc merging with RFC3662#1297
Conversation
9ce1ca8 to
a1df493
Compare
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D101353961. (Because this pull request was imported automatically, there will not be any future comments.) |
bf4609c to
a126c20
Compare
Implements RFC 3662 mergeable rustdoc in the rust prelude with a BXL that merges per-crate docs into one HTML tree. The reusable rustdoc_merge helper lives in doc_merge.bzl so downstream BXL can bring its own target discovery and filtering. Uses --emit=html-non-static-files. This avoids writing shared js/css assets in every crate build. Since the flag has recently been renamed, we have a compat layer for the old flag names. This all means we don't have to touch this for another year hopefully.
And now that we know which ones are externed, we exclude them from the bxl target sets.
Rustdoc themes have to be provided when generating HTML for all crates. That means the naive way of adding themes results in full crate graph rebuilds every time you tweak the theme. This way is nicer.
We were getting a random crate in merge_output/src, as src itself was present in all crates' html outputs. We need to do a recursive directory merge, basically.
This handles hidden args better
a126c20 to
6615164
Compare
|
Maybe @dtolnay would like to review? There are some comments about how rustdoc resolves external links to docs.rs for third party crates, to the effect of "rustdoc is pretty annoying here" that might be appropriate to PR against rustdoc itself. If its priority order for getting a URL while documenting a downstream crate were not so weird, we could use the --extern-html-root-url override (or however you spell it) and not have to use The hacky way of adding Maybe the BXL could also do with some work, you are better at BXL than I am. Only other thing I can think to add is a wrapper script for the BXL that hosts it on localhost or opens an appropriate index.html in the browser. |
Fixes #1097. Basically you can now:
rustdoc --emit=invocation-specificto--emit=html-non-static-filesAlso deals somewhat with the problems in #876 by making
-Zcrate-attreasier to use with a simple attr onrust_library(rustdoc_html_root_url= ...). If this is merged, we should update reindeer to generate this automatically.Also makes rustdoc themes easier to use, by generating stub theme files so we don't force a rebuild of all crate docs when making tiny tweaks to themes. The only thing rustdoc actually looks at until the final merge step is the filename. This applies to regular [doc] subtargets, but they get the real theme files.
All this is exercised in the example project.