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

Add support for fragment specifiers in intra-doc-links #51284

Closed
Manishearth opened this issue Jun 1, 2018 · 4 comments
Closed

Add support for fragment specifiers in intra-doc-links #51284

Manishearth opened this issue Jun 1, 2018 · 4 comments
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Manishearth
Copy link
Member

It should be possible to link to things like https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#indexing via [Vec#indexing].

This is pretty straightforward to implement. We already track fragment specifiers for things like methods and enum variants, which we extract here. What we can do additionally is when parsing if we come across #foo, strip it out, continue resolution, and if the resolved thing doesn't already have a fragment, use this instead.

I volunteer @sunjay to work on this, because he's the one who wanted this feature 😉

cc @QuietMisdreavus

Unsure if this needs an RFC.

@killercup
Copy link
Member

Looks useful to me.

I agree a simplistic version of this is trivial to implement. The original idea with intra-doc-links howeve was to ensure at rustdoc-render-time that the links are valid. To implement that vision here, we'd need to ensure that the target item actually has a fragment with given name. This might not be trivial: Most fragment identifiers are generated by turning a headline into a valid HTML ID. (I'm not sure if rustdoc does anything more than that. It try to should prevent setting the same ID twice, but that is probable another issue.)

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jun 4, 2018

Just like @killercup said: won't be as easy as might look like. But where would be the fun otherwise? 😛

EDIT: oh and no need for an RFC, just add it to the implementation issue of the intra-links.

@GuillaumeGomez GuillaumeGomez added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Jun 4, 2018
@JohnTitor JohnTitor added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Mar 8, 2020
@Manishearth
Copy link
Member Author

Don't we already support this?

(parts[0].to_owned(), Some(parts[1].to_owned()))

@GuillaumeGomez
Copy link
Member

We actually already do it, indeed. I'm closing this issue then.

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-enhancement Category: An issue proposing an enhancement or a PR with one. 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

4 participants