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

Anchor names for some impls are not predictable #71912

Open
nwalfield opened this issue May 5, 2020 · 10 comments
Open

Anchor names for some impls are not predictable #71912

nwalfield opened this issue May 5, 2020 · 10 comments
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@nwalfield
Copy link

I have a struct with a generic type:

struct ComponentBundle<C> {
    component: C,
    ...
}

Then I have implementations for different concrete types, e.g.,:

impl ComponentBundle<UserID> {
    ...
}

I want to link to the documentation for one of those implementations. But their anchors are called "#method.revocation_status-1", "#method.revocation_status-2", etc., which is brittle. It would be nice if the anchor names were more predictable.

@nwalfield nwalfield added the C-bug Category: This is a bug. label May 5, 2020
@kinnison
Copy link
Contributor

kinnison commented May 5, 2020

cc @rust-lang/rustdoc

@kinnison kinnison added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 5, 2020
@nwalfield
Copy link
Author

As a workaround, I added <a name="userid_revocation_status"></a> to the right method's documentation and link to that. That links to the right documentation, but the link is in the documentation, not the method's signature. Also, the method isn't highlighted, which is unfortunate.

@teythoon
Copy link

Similar, if you have multiple impl blocks for a type, their anchors are called impl, impl-1, ... which is also unpredictable.

@jyn514
Copy link
Member

jyn514 commented Aug 25, 2020

IMO the links rustdoc generates are not and should not be stable. The fix is to use intra-doc links (#43466), which unfortunately are not yet stable (but should be stabilized in the next release: #74430). But I don't think we should change the anchors to be predictable, people shouldn't be depending on them in the first place.

@kinnison
Copy link
Contributor

@jyn514 hard to do that across crates.

@GuillaumeGomez
Copy link
Member

If it's a crate that is not one of your dependencies, it's not possible, indeed.

@jyn514
Copy link
Member

jyn514 commented Aug 25, 2020

If it's a crate that is not one of your dependencies, it's not possible, indeed.

If it's not one of your dependencies (and in particular not your crate), then you can't depend on the anchor being present, you have to first navigate to it and be sure it's there before hard-coding it. So I don't think that's an argument to make the anchor predictable, just that doc authors should verify their links are present.

@GuillaumeGomez
Copy link
Member

I personally think that the generated HTML shouldn't be generated, I was just stating a fact. ;)

@kinnison
Copy link
Contributor

Another difficulty is linking usefully to docs from (for example) an mdbook.

@jsha
Copy link
Contributor

jsha commented Jan 21, 2022

FYI some of this is being updated in #92745 and #91759.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

6 participants