Skip to content

Add documentation and examples of [ScheduleLabel] usage.#19329

Merged
alice-i-cecile merged 3 commits into
bevyengine:mainfrom
kpreid:doc
May 22, 2025
Merged

Add documentation and examples of [ScheduleLabel] usage.#19329
alice-i-cecile merged 3 commits into
bevyengine:mainfrom
kpreid:doc

Conversation

@kpreid

@kpreid kpreid commented May 21, 2025

Copy link
Copy Markdown
Contributor

Objective

Add documentation useful to users of bevy_ecs not also using App.

Fixes #19270.

Solution

  • Add explanation of labels to Schedule documentation.
  • Add example of derive(ScheduleLabel) to trait ScheduleLabel.
  • Add a third example to Schedule which demonstrates using a schedule via label instead of owning it directly.
  • Add further explanation and links to World::add_schedule(), and World::run_schedule().

Testing

Reviewed generated documentation.

Please review this documentation carefully for correctness, as I have little experience with bevy_ecs and I am adding this information because it would have helped my own past confusion, but I may still be wrong about how things should be done.

This documentation is intended to be useful to users of `bevy_ecs`
not also using `App`.

Fixes bevyengine#19270.
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-ECS Entities, components, systems, and events S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 21, 2025
Comment thread crates/bevy_ecs/src/schedule/schedule.rs Outdated
Comment thread crates/bevy_ecs/src/schedule/set.rs Outdated

@alice-i-cecile alice-i-cecile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor wording nits but you've got the gist of this and it's nice to document this more fully.

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

@theotherphil theotherphil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! A couple of nits to address or not as you like. Do all of the new intra-doc links work correctly? (I'd check myself but am on mobile at the moment.)

///
/// // Declare a new schedule label.
/// #[derive(ScheduleLabel, Clone, Debug, PartialEq, Eq, Hash, Default)]
/// struct Update;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: might be a bit confusing that this is using the name of one of Bevy's default schedules.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Can you think of a good new example system name? I couldn't, at the time. …maybe something like “Synchronize”.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of examples use deliberately meaningless names like MySchedule. Your suggestion also sounds fine to me.


define_label!(
/// A strongly-typed class of labels used to identify a [`Schedule`](crate::schedule::Schedule).
/// A strongly-typed class of labels used to identify a [`Schedule`].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'm not sure what Bevy's approach is to example (near) duplication - might be better to just link?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is some value in allowing these examples to be visible without following a link, and potentially diverge in the future as the API is revised — in particular, this one focuses on defining a ScheduleLabel, and the other one focuses on a Schedule being in a World, hence the slightly different orderings. But I don't think there's a lot of value there.

Comment thread crates/bevy_ecs/src/world/mod.rs Outdated
Co-authored-by: theotherphil <phil.j.ellison@gmail.com>
@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 22, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 22, 2025
Merged via the queue into bevyengine:main with commit 870ad21 May 22, 2025
@kpreid kpreid deleted the doc branch January 5, 2026 20:43
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-Docs An addition or correction to our documentation S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explain how to use ScheduleLabels in bevy_ecs

3 participants