-
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 relative links between crates? #204
Comments
It would be nice to have a solution to this. One option might be to add redirect URLs for companion crates, e.g. |
Good news! It seems we already can do it as a side effect of rust-lang/rfcs#1946 (tracking issue). See this test crate, in the docstring it simply has One restriction is that link should be for the crate dependency, in other words IIUC we can't (yet) link |
(From here.) Sounds like a solution, but not currently implemented; sounds like instead these cross-crate links are automatically generated but only for dependencies. Sometimes we refer in the documentation to things not used in the code (to suggest alternatives); this can even be from a crate which is not a dependency. This problem was already mentioned here but I am not aware of a solution. Anyway, it sounds like this solves around 98% of our cross-crate doc linking problems. |
@newpavlov Intra-doc links is supposed to work off all the It also looks like the introduction of the |
Thanks @QuietMisdreavus. So Then the question is how to specify this flag — for our own build (by Travis) this is easy enough, but for the documentation built and hosted on So we can maybe refer to |
It's possible to ask docs.rs to send custom flags (see the "Metadata for custom builds" on this page) but i don't think it will work, because the information of what's inside the crate will not be available to the name resolver that we use to look it up. That information needs to be available to the compiler (which is why local |
Oh I see; a link to We've also discussed linking to a crate's top-level API documentation, e.g. |
Doing it "properly" probably requires a big refactoring internal to the compiler (being able to load a downstream crate's metadata without creating circular dependencies), though so does the other major change i want for this feature (saving resolver scopes when compiling so re-exported docs can resolve intra-doc links in their original location), so it can come up in that discussion too.
Sadly, there's no good way to get this to work as-is. You'll have to hard-code a link somewhere, whether as a relative link (and break docs.rs) or as an absolute link to somewhere that's hosting it (and make offline docs awkward). I don't know a good way around it. Rocket's docs have the same problem, because they like to link the base library's docs to the "contrib" library, which is a downstream crate. |
See also rust-lang/rust#74481. |
Example: Rand has multiple crates in the same repo.
We have been using relative links between the crates, e.g.:
If we build doc with
cargo doc --all
, these links work fine locally. They do not work on docs.rs (e.g. blockBlockRng
here).Is there a good solution for this? We'd prefer not to use absolute links to docs.rs. We have documentation here which resolves the cross-linking just fine.
The text was updated successfully, but these errors were encountered: