Skip to content
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

Feature request: #[doc(canonical)] #3011

Open
jyn514 opened this issue Nov 4, 2020 · 4 comments
Open

Feature request: #[doc(canonical)] #3011

jyn514 opened this issue Nov 4, 2020 · 4 comments
Labels
T-rustdoc Relevant to rustdoc team, which will review and decide on the RFC.

Comments

@jyn514
Copy link
Member

jyn514 commented Nov 4, 2020

I don't have time for a full write-up of this right now, so I'm just opening an issue so I have somewhere to point people when they open rustdoc issues.

Motivation:

doc(canonical) could tell rustdoc the 'one true path' the item should appear at.

Possible difficulties:

  • doc(canonical) is necessarily unique across all crates. rustdoc should give an error if it's duplicated.
  • rustdoc currently stores search-index.json per-crate. This will need a redesign if rustdoc only know to hide the item after the documentation has been generated and it goes onto the next crate

Unresolved questions:

  • Does inlining still make sense with doc(canonical)? Should all other usages just link to the canonical crate? How does this work if the canonical usage is in a reverse-dependency?

cc @camelid

@jyn514
Copy link
Member Author

jyn514 commented Mar 11, 2023

rust-lang/docs.rs#1588 (comment) has a lot of things that are very similar but not the same; I'd love to have a plan for how this affects links to transitive dependencies as well.

@jsha
Copy link

jsha commented Mar 12, 2024

We discussed this in the 2024-01-08 t-rustdoc meeting and the 2024-03-11 t-rustdoc meeting. To summarize:

This is a useful problem to solve, and we want to solve it, but we're still not sure yet exactly what the solution should look like. Getting concrete, there are two main use cases:

  1. facade crates (like std, bevy, to some extent tracing), where canonical path is in the facade crate, or outermost
  2. shared types crates (like pki-types, http), where canonical path is in the shared types crate, or innermost

For examples of (2):

For examples of (1):

  • tracing::Event vs tracing_core::Event. But this one is more complicated because the preferred path depends on the use case. Tracing subscribers are expected to depend on tracing-core instead of tracing, while other use cases are more likely to depend on tracing.

Another problem that came up is directionality. A crate that is depended-upon doesn't know about the crates that depend on it. So if, e.g. tracing declared that its version of Event should be canonical, that wouldn't allow tracing-core to do anything differently, because a doc build of tracing-core doesn't know anything about tracing. But also in general the situation for facade crates is probably more complicated than for shared types crates.

I also wrote down what I consider the important use case for a feature like this:

As a user, I am calling a function that returns hyper::Request. I want to know if I can pass that output to a different function that takes http::request::Request as a parameter

One idea that came up towards the end of the meeting was that rather than try to do something complicated with declaring things canonical, we could, when generating inlined re-export docs, add a notation saying "this is a re-export of foo::Bar."

@Lokathor
Copy link
Contributor

A notation to make clear that a re-export happened sounds very good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to rustdoc team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

5 participants