Open
Description
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
kinnison commentedon May 5, 2020
cc @rust-lang/rustdoc
nwalfield commentedon May 5, 2020
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 commentedon Jul 31, 2020
Similar, if you have multiple
impl
blocks for a type, their anchors are calledimpl
,impl-1
, ... which is also unpredictable.jyn514 commentedon 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 commentedon Aug 25, 2020
@jyn514 hard to do that across crates.
GuillaumeGomez commentedon Aug 25, 2020
If it's a crate that is not one of your dependencies, it's not possible, indeed.
jyn514 commentedon Aug 25, 2020
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 commentedon Aug 25, 2020
I personally think that the generated HTML shouldn't be generated, I was just stating a fact. ;)
name.namespace.html
as the canonical URL, notkind.name.html
#55160kinnison commentedon Aug 25, 2020
Another difficulty is linking usefully to docs from (for example) an mdbook.
jsha commentedon Jan 21, 2022
FYI some of this is being updated in #92745 and #91759.