Skip to content

Support multi-crate projects #2021

Closed as not planned
Closed as not planned
@dhardy

Description

@dhardy

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 and rand_chacha are all in the same repo)

  • Manually via Cargo.toml, e.g.

    [package.metadata.docs.rs]
    all-features = true
    site = "rand"
    

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions