rust-lang / rust-lang/rust

[rustdoc] URL fragments handling should be unified

Open
#148,547 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-cleanup T-rustdoc T-rustdoc-frontend
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Currently, we handle URL fragments (the # part) in at least three different locations:

  • html::format::print_anchor
  • clean::Item::links (generates href from intra doc links)
  • html::render::assoc_href_attr

The two first can be merged in a straighforward way: href_with_root_path should be split to allow to pass the "parent" DefId (which would be the same as the item DefId if it's not an associated item) directly. That would make it easier to be used from clean::Item::links. It will likely require changes in collect_intra_doc_links because UrlFragment::Item holds a DefId supposed to be of the associated item, but sometimes both UrlFragment::Item and ItemLink::page_id are the same (like methods on a trait), meaning something needs to be fixed there.

Once these two have been merged, we can look at merging with the third one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read html::format::print_anchor, clean::Item::links, and html::render::assoc_href_attr to compare their URL-fragment handling. Trace href_with_root_path and collect_intra_doc_links, then unify the first two paths and determine how UrlFragment::Item and ItemLink::page_id should represent associated items before considering the third path.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.