Description
With this package that uses dependency renaming:
# Cargo.toml
[package]
name = "foobar"
version = "0.1.0"
edition = "2018"
[dependencies]
ac = { package = "async-compression", features = ["stream", "gzip"], version = "0.3" }
ac02 = { package = "async-compression", features = ["stream", "gzip"], version = "0.2" }
// src/main.rs
#[doc(inline)]
pub use {ac::stream::GzipDecoder, ac02::stream::GzipDecoder as GzipDecoder02};
#[doc(no_inline)]
pub use {ac::stream::GzipEncoder, ac02::stream::GzipEncoder as GzipEncoder02};
I tried to build documentation that can link to both of the upstream docs.rs documentation pages:
cargo rustdoc --locked -- -Z unstable-options
--extern-html-root-url ac02=https://docs.rs/async-compression/0.2.0
--extern-html-root-url ac=https://docs.rs/async-compression/0.3.5
rustdoc
--edition=2018
--crate-type lib
--crate-name foobar src/lib.rs
-o /tmp/tmp.ni0GV7DIZf/foobar/target/doc
--error-format=json --json=diagnostic-rendered-ansi
-Z unstable-options
--extern-html-root-url 'ac02=https://docs.rs/async-compression/0.2.0'
--extern-html-root-url 'ac=https://docs.rs/async-compression/0.3.5'
-L dependency=/tmp/tmp.ni0GV7DIZf/async-compression/target/debug/deps
--extern ac02=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-ad6b882a4c15a1f0.rmeta
--extern ac=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-875810b2ce8d0002.rmeta
--crate-version 0.1.0
This failed to link to either of the non-inlined exports because it seems that --extern-html-root-url
expects the library name instead, changing to use that:
cargo rustdoc --locked -- -Z unstable-options
--extern-html-root-url async_compression=https://docs.rs/async-compression/0.2.0
--extern-html-root-url async_compression=https://docs.rs/async-compression/0.3.5
rustdoc
--edition=2018
--crate-type lib
--crate-name foobar src/lib.rs
-o /tmp/tmp.ni0GV7DIZf/foobar/target/doc
--error-format=json --json=diagnostic-rendered-ansi
-Z unstable-options
--extern-html-root-url 'async_compression=https://docs.rs/async-compression/0.2.0'
--extern-html-root-url 'async_compression=https://docs.rs/async-compression/0.3.5'
-L dependency=/tmp/tmp.ni0GV7DIZf/async-compression/target/debug/deps
--extern ac02=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-ad6b882a4c15a1f0.rmeta
--extern ac=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-875810b2ce8d0002.rmeta
--crate-version 0.1.0
This successfully added links on both, but both directing to version 0.3.5
since that was the last flag specified.
(I'm not sure of the correct solution for this, currently docs.rs only passes --extern-html-root-url
for direct dependencies, so changing to use the same name as used for --extern
would work for that; but it seems to me that docs.rs should be passing a flag for all dependencies, since it's possible for documentation from a dependency of a dependency to bubble-up and be rendered, so it should be possible to set the html-root-url for them all, I'm not sure how we would identify the crates in that case).
Meta
rustdoc 1.47.0-nightly (7e6d6e5f5 2020-08-16)