-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multi-crate projects #2021
Comments
I definitely think it would be nice if we could do something like this. Both the suggestions on how to decide what to include in a site seem easy to game, anyone can set the One idea might be to make it fully explicit from the top-level crate defining the site # rand/Cargo.toml
[package.metadata.docs.rs.site-dependencies]
rand-core = { version = "0.6.4" }
rand-chacha = { version = "0.3.1" } That way it's fully under its control which other crates are built and bundled into its sidebar. It would also help with versioning, the versions selected and built during each release are what are available with it. If there is a new version of That wouldn't allow for redirecting from the bundled crates docs to the site though, since now anyone could bundle your crate docs into their site. So maybe it'd need notation on both sides (though that might become complex to track exactly which redirect target should be used for versioned urls). |
A possible work-around is not to redirect: each crate gets its own docs.rs site, but some include others (as above). Question: does the site get updated when a dependency gets a new patch version? Ideally yes, but... ... how do perma-links work when the version belongs to the site crate, but a site-dependency gets a new patch version? One could encourage people to use links to the crate's own docs for this, but it's a poor solution. So, possibly, the above works but without updating for new site-dependency versions. Another minor detail: a site-dependency might not be a crate dependency. It might even be a dependant, and published afterwards, therefore the mentioned version may not exist yet on crates.io when docs.rs attempts to generate docs. |
I'm closing this issue in favor of #2457 (the tracking issue for packages as optional namespaces. |
Summary
Suggestion: host multiple crate's docs under the same "site", e.g.
https://docs.rs/rand/
Motivation
Generated docs (at least sometimes) include a list of "Crates" in the sidebar. This can be seen, for example, on the Rand project's self-hosted docs, as well as on any locally built docs.
Example: https://rust-random.github.io/rand/rand/
This would also partially solve #204.
Details
Support building and serving docs for multiple (selected) crates from the same "site". For example:
Crates served from a different site would redirect, e.g. https://docs.rs/rand_core/latest/rand_core/trait.RngCore.html redirects to https://docs.rs/rand/latest/rand_core/trait.RngCore.html .
How to select when to serve a crate from a different site is worth considering; I can see two possibilities:
Automatically based on the repository (e.g.
rand
,rand_core
andrand_chacha
are all in the same repo)Manually via
Cargo.toml
, e.g.Issues
Versions are crate-specific. Even when projects release multiple crates simultaneously under the same number, this cannot be guaranteed. Hence a URL like this makes no sense:
0.8.5 is a rand version; there is no rand_core v0.8.5 (yet)!
How to solve this isn't obvious and it may kill this suggestion. Moving the version number after the crate name (
docs.rs/rand/rand_core/0.6.4/trait.Rng.html
) would break with current docs.rs behaviour and break relative to locally-functional links (as used in https://rust-random.github.io/rand/rand/).A possibility: replace the version in the URL with a date. Regenerate the whole "site" whenever any crate is updated (maybe after a delay to accommodate multiple simultaneous publications). Keep the crate version in the top-bar based on the currently viewed crate.
The text was updated successfully, but these errors were encountered: