rustdoc: deterministic sorting for doc_cfg badges#156401
Conversation
|
r? @fmease rustbot has assigned @fmease. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
79fbdd0 to
8181743
Compare
|
Some changes occurred in GUI tests. |
|
Sorting the As for |
|
Also, would be nice to have a unit test with different scenarios directly in |
8181743 to
7cbc028
Compare
@GuillaumeGomez Thanks for the review! That makes complete sense. I've just pushed a commit that drops the importance heuristic and replaces it with the logic you suggested. Updates:
I completely agree these are tricky! Here is how this commit handles them:
Does pushing the complex nested blocks to the end seem like the best UX call to you, or would you prefer them sorted differently? |
Sounds like the right way to handle them indeed. Good call! |
Fixes #156391
Currently, target-exclusive
doc_cfgbadges (eg. "Available on...") reuse the order of predicates as they appear in the source code. This often buries popular targets behind niche ones and leads to inconsistent UI rendering.This PR introduces a deterministic sorting mechanism to the
CfgAST prior to HTML/JSON rendering.Note for Reviewers:
To provide the best UX, I implemented a lightweight tiering heuristic (prioritizing major platforms like Linux/Apple/Windows first, followed by mobile, then BSDs, and alphabetizing the rest). However, I am completely open to tweaking these priority groupings or falling back to a different sorting logic if the team prefers. Let me know what you think!