cargo icon indicating copy to clipboard operation
cargo copied to clipboard

clarify default behavior of `documentation` field

Open RalfJung opened this issue 1 year ago • 7 comments

Cc https://github.com/rust-lang/cargo/issues/11777, https://github.com/rust-lang/crates.io/issues/1484

RalfJung avatar Mar 27 '24 09:03 RalfJung

r? @ehuss

rustbot has assigned @ehuss. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Mar 27 '24 09:03 rustbot

For myself, I feel like its a bug in the system that we have to add so much nuance here. If that bug isn't being fixed, should we just not reference this and encourage people to set the links?

epage avatar Mar 27 '24 12:03 epage

Yea, I would agree this seems like weird bug to document. I'm also a little confused, as it seems like the accepted solution should be relatively trivial (something like documentation.or_else(|| format!("https://docs.rs/{name}/latest/{name}")) in the search code).

ehuss avatar Mar 27 '24 13:03 ehuss

See https://github.com/rust-lang/crates.io/issues/1484, apparently what the crate page does is a lot more complicated than documentation.or_else and involves querying the docs.rs API to check if the crate is actually documented there.

RalfJung avatar Mar 27 '24 13:03 RalfJung

My comment was based on https://github.com/rust-lang/crates.io/issues/1484#issuecomment-885620320, which says that the search results should not do that query, and instead just always link to the latest version if the documentation field is not specified. That might cause an issue when the docs are not yet ready, or failed to build, but would be no different than if the user specified the documentation field manually.

ehuss avatar Mar 27 '24 13:03 ehuss

Yeah, agreed.

RalfJung avatar Mar 27 '24 13:03 RalfJung

If we agree on seeing a fix on crates.io or other services, should this be closed?

weihanglo avatar Apr 10 '24 01:04 weihanglo

Close as it is more like a buggy behavior in crates.io that we don't want to document. Thanks everyone for the discussion.

weihanglo avatar Sep 17 '24 21:09 weihanglo

Does the cargo team define whether this is a bug in crates.io? That seems like a crates.io decision to me. https://github.com/rust-lang/crates.io/issues/1484 is marked as "enhancement".

Meanwhile, we are doing our users a disservice by having documentation that actively contradicts reality.

RalfJung avatar Sep 18 '24 05:09 RalfJung

Even if this is a bug in crates.io, it is clearly a long-standing issue and hard to fix. So telling users in the cargo docs that they can just leave the docs field empty if they use docs.rs (which is effectively what the docs are doing) is not helping.

I have to say I am quite disappointed with how this has been handled -- we have docs that actively confuse users and lead them in the wrong direction, and instead of trying to fix this we're squabbling about whether this is a bug or not?

It would be better to not mention this crates.io feature at all then: https://github.com/rust-lang/cargo/pull/14561.

RalfJung avatar Sep 18 '24 05:09 RalfJung

Meanwhile, we are doing our users a disservice by having documentation that actively contradicts reality.

Its fairly close to reality

Even if this is a bug in crates.io, it is clearly a long-standing issue and hard to fix. So telling users in the cargo docs that they can just leave the docs field empty if they use docs.rs (which is effectively what the docs are doing) is not helping.

While its long standing, there has been recent progress to fixing it. iiuc the blocker for fixing it is on docs.rs's side and the PR for that was started this summer (rust-lang/docs.rs#2533).

I mentioned that I was fine with removal if this was going to the status quo but that doesn't appear to be the case, so I lean towards keeping the documentation.

epage avatar Sep 18 '24 13:09 epage

It's far enough from reality to cause actual problems: many crates have no "Documentation" link in the crates.io search results, adding an entirely unnecessary extra click for the quite common flow of "go search some crate to find its docs". I think these docs (and the others that should still be fixed) take a good chunk of responsibility for that.

RalfJung avatar Sep 18 '24 13:09 RalfJung

If the concern is about browsing crates.io, at this point, it would be a major undertaking to get people to notice the documentation change to specify package.documentation and for people to act on it. It doesn't seem worthwhile to make that shift when we'll just switch back again.

epage avatar Sep 18 '24 13:09 epage