rust-lang / rust-lang/rust

[rustdoc] IndexItem initialization logic is duplicated

Open
#149,404 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

both add_item_to_search_index in formats/cache.rs and build_index in html/render/search_index.rs construct this type. Both functions have a decent bit of logic that is unique to them, but they also have a fair bit of logic that is the same for both.

I think moving this shared logic into an associated function on IndexItem would make the code easier to maintain.

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

Start by comparing add_item_to_search_index in formats/cache.rs with build_index in html/render/search_index.rs, then inspect IndexItem to identify the duplicated initialization logic. Done means the shared logic is provided by an associated function on IndexItem, while each caller retains its unique behavior and rustdoc search-index behavior is unchanged.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.