Skip to content

Fix Component require() IDE integration#18165

Merged
cart merged 2 commits intobevyengine:mainfrom
cart:fix-require-ide
Mar 6, 2025
Merged

Fix Component require() IDE integration#18165
cart merged 2 commits intobevyengine:mainfrom
cart:fix-require-ide

Conversation

@cart
Copy link
Copy Markdown
Member

@cart cart commented Mar 5, 2025

Objective

Component require() IDE integration is fully broken, as of #16575.

Solution

This reverts us back to the previous "put the docs on Component trait" impl. This does reduce the accessibility of the required components in rust docs, but the complete erasure of "required component IDE experience" is not worth the price of slightly increased prominence of requires in docs.

Additionally, Rust Analyzer has recently started including derive attributes in suggestions, so we aren't losing that benefit of the proc_macro attribute impl.

@cart cart added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use C-Bug An unexpected or incorrect behavior labels Mar 5, 2025
@cart cart added this to the 0.16 milestone Mar 5, 2025
@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Mar 5, 2025
@cart cart added this pull request to the merge queue Mar 6, 2025
Merged via the queue into bevyengine:main with commit 06cb5c5 Mar 6, 2025
31 checks passed
@aloucks
Copy link
Copy Markdown
Contributor

aloucks commented Mar 25, 2025

I don't see any IDE integration of required components after this change. For example, hovering over a Mesh3d:

Screenshot 2025-03-25 at 5 51 18 PM

Is it displayed somewhere else?

Why not add the generated docs both the struct and the Component impl?

@cart
Copy link
Copy Markdown
Member Author

cart commented Mar 26, 2025

Why not add the generated docs both the struct and the Component impl?

The crux of it is that adding it to the struct required a "hack" where we layered an additional attribute proc maco on top of the normal derive macro. This broke all Rust Analyzer integration (autocomplete, go-to-definition, doc hover on required types, etc). That is the only known method of adding docs directly to the struct. We had to pick one, and we chose Rust Analyzer integration. This is obviously a tradeoff, but we generally agree that this is the right call.

If you want to see requires, you can just press F12 on the type you are interested in and it will navigate you to the definition, which will have the require list. From there (thanks to Rust Analyzer working), you can hover the name of each require to see its docs.

Alternatively, if you are viewing the rust documentation directly (ex via docs.rs), you can scroll down to the Component trait impl and see the list there in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants