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

intra doc links towards parent crate succeed but create warnings #73699

Closed
rukai opened this issue Jun 24, 2020 · 7 comments
Closed

intra doc links towards parent crate succeed but create warnings #73699

rukai opened this issue Jun 24, 2020 · 7 comments
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@rukai
Copy link
Contributor

rukai commented Jun 24, 2020

Problem

intra doc links towards parent crate succeed when generating docs for the parent crate but creates warnings like:

warning: `[Device]` cannot be resolved, ignoring it.
   --> /home/rukai2/Projects/Crates/wgpu/wgpu/wgpu-types/src/lib.rs:343:18
    |
343 | /// Describes a [`Device`].
    |                  ^^^^^^^^ cannot be resolved, ignoring
    |
    = note: `#[warn(intra_doc_link_resolution_failure)]` on by default
    = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

But we can see here that it succeeds: https://wgpu.rs/doc/wgpu/struct.DeviceDescriptor.html

Steps

  1. create a crate A
  2. create a crate B that depends on A and reexports types from A (specify as local path dependency, issue does not occur with git)
  3. a type in A contains intra doc links to types in B, which is then reexported by B. (only succeeds when reexported)
  4. run cargo +nightly doc on crate B
  5. This actually succeeds, which is great. Unfortunately it also creates warnings, that the type cannot be resolved.

Notes

Output of cargo version: cargo 1.46.0-nightly (089cbb80b 2020-06-15)

A workaround PR for this issue was made for wgpu gfx-rs/wgpu#748

This issue is kind of obscure, so I wouldnt be surprised if the best solution is for the user to just add an allow for the warning, but figured I would make an issue in case its useful.

@ehuss ehuss transferred this issue from rust-lang/cargo Jun 24, 2020
@ehuss
Copy link
Contributor

ehuss commented Jun 24, 2020

Transferred to the rust-lang/rust repository, where the rustdoc tool lives.

@Alexendoo Alexendoo added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jun 24, 2020
@jyn514
Copy link
Member

jyn514 commented Jun 26, 2020

create a crate B that depends on A and reexports types from A (specify as local path dependency, issue does not occur with git)
a type in A contains intra doc links to types in B, which is then reexported by B. (only succeeds when reexported)

This will break links as well once #73101 is merged. In general I don't think intra-doc links were designed for this use case, but you could try using absolute paths on the off chance it works.

@jyn514
Copy link
Member

jyn514 commented Jun 26, 2020

Note also that the link would be broken currently if you only documented A, it looks like it works because you always document the two crates at the same time.

@rukai
Copy link
Contributor Author

rukai commented Jun 26, 2020

Ok, yeah thats fine, if the links break in the future we'll just remove them I guess.

@cwfitzgerald
Copy link

cwfitzgerald commented Jun 26, 2020

Absolute links absolutely work going forward in the dep tree (I did it before realizing that intra-doc links worked). I understand that this is the proper thing to do, but it makes me sad as my docs in wgpu-types will get much more annoying in the future.

@jyn514
Copy link
Member

jyn514 commented Jul 17, 2020

Now that #73101 has been merged this should be closed as wontfix, you can't refer to upstream crates because they're not in scope. The links will now both create warnings and not generate the links you meant.

@jyn514
Copy link
Member

jyn514 commented Jul 18, 2020

I opened #74481 for the general issue of linking to upstream documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants