[rustdoc] URL fragments handling should be unified
Nobody has claimed this yet.
- 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_anchorclean::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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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