Skip to content

[rustdoc] URL fragments handling should be unified #148547

@GuillaumeGomez

Description

@GuillaumeGomez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.T-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions