Skip to content

Genenerate doc comments from Required Components #14800

@killercup

Description

@killercup

What problem does this solve or what need does it fill?

As a user of components with Required Components (#14791),
I want to see what other components are going to be inserted easily.

What solution would you like?

Adding the #[required(…)] attribute should also add a doc comment.
This will be shown by many IDEs when hovering (or similar) over the type.

Example

/// Makes entity behave like a button by adding sparkle effects on hover.
#[derive(Component)]
#[require(Node, UiImage)]
struct Button;

generates

/// Makes entity behave like a button by adding sparkle effects on hover.
///
/// # Automatically added components
///
/// When inserting this component,
/// [`Node`], and [`UiImage`]
//  are also inserted if not already present.
struct Button;

What alternative(s) have you considered?

  • Telling people to do this manually
  • Hoping that IDEs will do something else to show this

Additional context

#14791 is only proposed as of writing this.
This issue may become invalid if it not accepted in its current state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-DocsAn addition or correction to our documentationC-FeatureA new feature, making something new possibleX-BlessedHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makers

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions