Description
The new rename-dependency
feature in Rust 1.31 makes it possible to depend on multiple versions of the same crate. This mostly works fine, but when building docs, the docs of one version overwrite the docs of the other version.
I'm working on adding support for converting arrays from the nalgebra
crate to the ndarray
crate, and I'd like this to work for multiple versions of nalgebra
. So, I've added this to the Cargo.toml
of ndarray
:
[dependencies]
nalgebra-crate-0_15 = { package = "nalgebra", version = "0.15", optional = true }
nalgebra-crate-0_16 = { package = "nalgebra", version = "0.16", optional = true }
[features]
nalgebra-0_15 = ["nalgebra-crate-0_15"]
nalgebra-0_16 = ["nalgebra-crate-0_16"]
In lib.rs
, the features are used for conditional compilation:
#[cfg(feature = "nalgebra-0_15")]
extern crate nalgebra_crate_0_15;
#[cfg(feature = "nalgebra-0_16")]
extern crate nalgebra_crate_0_16;
#[cfg(feature = "nalgebra-0_15")]
mod convert_nalgebra_0_15;
#[cfg(feature = "nalgebra-0_16")]
mod convert_nalgebra_0_16;
and the convert_nalgebra_0_15
and convert_nalgebra_0_16
modules implement the conversions. For example, convert_nalgebra_0_15
contains
use imp_prelude::*;
use nalgebra_crate_0_15 as na;
/// **Requires crate feature `"nalgebra-0_15"`**
impl<A, R, S1, S2> From<na::Matrix<A, R, na::U1, S1>> for ArrayBase<S2, Ix1>
where
A: na::Scalar,
R: na::Dim,
S1: na::storage::Storage<A, R, na::U1>,
S2: DataOwned<Elem = A>,
{
fn from(vector: na::Matrix<A, R, na::U1, S1>) -> ArrayBase<S2, Ix1> {
ArrayBase::from_vec(vector.iter().cloned().collect())
}
}
// ...
(See the full changes here.)
When I build with cargo +nightly doc --open --features=nalgebra-0_15,nalgebra-0_16
, I see both implementations as expected in docs of the ndarray
crate:
The problem is that both versions of the docs of nalgebra
are written to the same location, target/doc/nalgebra
. So, for example, when I click on Matrix
(a type defined in the nalgebra
crate), I get taken to target/doc/nalgebra/base/struct.Matrix.html
regardless of which version of nalgebra
it corresponds to.
To fix this, I would suggest naming the documentation directories according to the names the crates were renamed to. So, there would be target/doc/nalgebra-crate-0_15
and target/doc/nalgebra-crate-0_16
directories instead of just a single target/doc/nalgebra
directory.
Meta
rustup run nightly rustc --version --verbose
:
rustc 1.32.0-nightly (f1e2fa8f0 2018-11-20)
binary: rustc
commit-hash: f1e2fa8f0469aac1ea69dd5b6164e1d198d57934
commit-date: 2018-11-20
host: x86_64-unknown-linux-gnu
release: 1.32.0-nightly
LLVM version: 8.0