-
Notifications
You must be signed in to change notification settings - Fork 203
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
Link to dependency of dependency #1588
Comments
Note: unfortunately the workaround does not work for Bevy, I believe due to some bug in the |
I don't quite understand why this happens (I would expect -Zrustdoc-map to fix any issue with facade crates), but if you can reproduce it locally then it's a rustdoc bug and not a docs.rs bug; you should report it in rust-lang/rust. |
The issue is with |
Ah, and I remember what the related issues are about now. If we fix |
cc rust-lang/cargo#8296 (comment), rust-lang/rust#42301.
@dtolnay had an interesting suggestion in #2081: If rustdoc in If rustdoc has I think that would do the correct thing for bevy, without needing rust-lang/rfcs#3011 to be fixed first, but it will do the wrong thing for non-facade crates, so making As an aside, this issue is large/complicated enough and spread across sufficiently many projects that I think any change here should involve an RFC. |
Summary: the rustdocs for mocks can be a bit confusing because there's no documentation for any of the individual mock fields. this is because the module in which the mock field objects are defined is private. to expose them in rustdoc, just `pub` that module. each of the mock field objects have private fields, so downstream crates will still be unable to instantiate these mock fields on their own (and this makes `unimplemented` `pub(crate)` to ensure that as well). the link to some mock fields is still broken, e.g. `FacebookService`, but that's because of rust-lang/docs.rs#1588 (comment). Reviewed By: thepacketgeek Differential Revision: D45406779 fbshipit-source-id: 91f14ef2e022857969540c82d2482e81bda1421c
Summary: the rustdocs for mocks can be a bit confusing because there's no documentation for any of the individual mock fields. this is because the module in which the mock field objects are defined is private. to expose them in rustdoc, just `pub` that module. each of the mock field objects have private fields, so downstream crates will still be unable to instantiate these mock fields on their own (and this makes `unimplemented` `pub(crate)` to ensure that as well). the link to some mock fields is still broken, e.g. `FacebookService`, but that's because of rust-lang/docs.rs#1588 (comment). Reviewed By: thepacketgeek Differential Revision: D45406779 fbshipit-source-id: 91f14ef2e022857969540c82d2482e81bda1421c
* readme: fix link to bevy doc * workaround to link to bevy type see rust-lang/docs.rs#1588 * readme: move the link to bevy at the end * add a link to `CursorInfo` doc
Links to Bevy types don't work on docs.rs. The workaround is to use actual url to docs.rs. That seems tedious and fragile, so we'll just remove the links and inser the word "Bevy" so that people know where to look. See rust-lang/docs.rs#1588
Since a few nightlies ago, |
@Nemo157 so this issue can be closed? Or is something is missing? Or do we just need a rebuild? |
Yeah I guess so, the main thing we somewhat controlled about getting the html-root-url passed through has been fixed, having links to the facade instead of the origin requires a new rustdoc feature (tracked in rust-lang/rfcs#3011) and shouldn't require any docs.rs changes. |
This is a follow-up issue from a discussion on Discord with @Nemo157 about a bug in a crate's doc trying to link a type in another crate, which is actually a re-export from a third crate (dependency-of-dependency).
Description
The situation is as follow:
bevy
that projects are expected to take a dependency on.bevy_XXX
, and the public types are re-exported from the facade.bevy::
.*I'm using "facade" in this issue as what I think it means, a "top-level" crate that re-export many other "internal" ones, but maybe I misunderstood the meaning given in rust-lang/rust#22083. If so, sorry for the confusion, and please take "facade" as the meaning I just described.
The result is that unfortunately links on docs.rs are broken, rendering verbatim instead of being actual links to the HTML page of the documentation of the type.
Bug example
Note: To avoid confusion, the example is from my crate
bevy_tweening
, which is not an official Bevy crate, and not part of the official repo. So in particular that crate has no direct access to internal Bevy crates, and should be seen as "third-party".See an example of published crate here, where the
[Entity]
link toward the top of the page doesn't link anywhere (the HTML link contains the verbatim Rust pathbevy::ecs::entity::Entity
). The source code those docs are generated from is:https://github.com/djeedai/bevy_extra/blob/f9c8049fb7674ea314a2c1a9c59a2b316d5d0abf/crates/bevy_tweening/src/lib.rs#L32
For reference (as for some reason GitHub refuses to expand the above link into code) the link is:
The
Entity
type is defined in the internal cratebevy_ecs
, then re-exported in the facade cratebevy
under thebevy::ecs::entity::Entity
path.Repro steps
I'm mentioning it here for completeness because @Nemo157 provided the command to run to replicate what docs.rs does, to test this:
rustdoc
seem to link them :rm -rf target/doc
or similar for other OSescargo doc -Zrustdoc-map --no-deps
Workaround
A workaround would be to directly link the internal type. Unfortunately since Bevy uses a facade crate, a third-party crate typically does not directly take a dependency to those Bevy internal crates, only to the facade, so simply changing the link makes the build fail. This means in addition of changing all broken links to target internal Bevy crates, a crate maintainer has to add a docs.rs-specific feature to depend on all those internal crates for documentation purpose only.
The
html_root_url
attribute was also mentioned, and I'm chatting with the Bevy docs team (CC: @alice-i-cecile) to see if we can try it, but we haven't yet.Related issues
As explained by @Nemo157 on Discord, the scenario detailed above is likely related to rust-lang/rust#22083 and rust-lang/rfcs#3011, although it was under our impression that those issues do not cover entirely the problem at hand, and in particular the dependency-of-dependency linking.
The text was updated successfully, but these errors were encountered: