Skip to content

Commit

Permalink
Hide docs for concrete impls of Fetch, FetchState, and SystemParamSta…
Browse files Browse the repository at this point in the history
…te (#4250)

# Objective
 The following pages in the docs are rather noisy, and the types they point to are not particularly useful by themselves:

 - http://dev-docs.bevyengine.org/bevy/ecs/query/index.html
 - http://dev-docs.bevyengine.org/bevy/ecs/system/index.html

## Solution
 
- Replace docs on these types with `#[doc(hidden)]`.
- Hide `InputMarker`  too.
  • Loading branch information
james7132 committed Mar 21, 2022
1 parent 31636a3 commit 86907f1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
11 changes: 11 additions & 0 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ impl WorldQuery for Entity {
}

/// The [`Fetch`] of [`Entity`].
#[doc(hidden)]
#[derive(Clone)]
pub struct EntityFetch {
entities: *const Entity,
Expand All @@ -422,6 +423,7 @@ pub struct EntityFetch {
unsafe impl ReadOnlyFetch for EntityFetch {}

/// The [`FetchState`] of [`Entity`].
#[doc(hidden)]
pub struct EntityState;

// SAFETY: no component or archetype access
Expand Down Expand Up @@ -500,6 +502,7 @@ impl<T: Component> WorldQuery for &T {
}

/// The [`FetchState`] of `&T`.
#[doc(hidden)]
pub struct ReadState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -547,6 +550,7 @@ unsafe impl<T: Component> FetchState for ReadState<T> {
}

/// The [`Fetch`] of `&T`.
#[doc(hidden)]
pub struct ReadFetch<T> {
table_components: NonNull<T>,
entity_table_rows: *const usize,
Expand Down Expand Up @@ -656,6 +660,7 @@ impl<T: Component> WorldQuery for &mut T {
}

/// The [`Fetch`] of `&mut T`.
#[doc(hidden)]
pub struct WriteFetch<T> {
table_components: NonNull<T>,
table_ticks: *const UnsafeCell<ComponentTicks>,
Expand All @@ -681,6 +686,7 @@ impl<T> Clone for WriteFetch<T> {
}

/// The [`ReadOnlyFetch`] of `&mut T`.
#[doc(hidden)]
pub struct ReadOnlyWriteFetch<T> {
table_components: NonNull<T>,
entities: *const Entity,
Expand All @@ -703,6 +709,7 @@ impl<T> Clone for ReadOnlyWriteFetch<T> {
}

/// The [`FetchState`] of `&mut T`.
#[doc(hidden)]
pub struct WriteState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -940,6 +947,7 @@ impl<T: WorldQuery> WorldQuery for Option<T> {
}

/// The [`Fetch`] of `Option<T>`.
#[doc(hidden)]
#[derive(Clone)]
pub struct OptionFetch<T> {
fetch: T,
Expand All @@ -950,6 +958,7 @@ pub struct OptionFetch<T> {
unsafe impl<T: ReadOnlyFetch> ReadOnlyFetch for OptionFetch<T> {}

/// The [`FetchState`] of `Option<T>`.
#[doc(hidden)]
pub struct OptionState<T: FetchState> {
state: T,
}
Expand Down Expand Up @@ -1116,6 +1125,7 @@ impl<T: Component> WorldQuery for ChangeTrackers<T> {
}

/// The [`FetchState`] of [`ChangeTrackers`].
#[doc(hidden)]
pub struct ChangeTrackersState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -1163,6 +1173,7 @@ unsafe impl<T: Component> FetchState for ChangeTrackersState<T> {
}

/// The [`Fetch`] of [`ChangeTrackers`].
#[doc(hidden)]
pub struct ChangeTrackersFetch<T> {
table_ticks: *const ComponentTicks,
entity_table_rows: *const usize,
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ impl<T: Component> WorldQuery for With<T> {
}

/// The [`Fetch`] of [`With`].
#[doc(hidden)]
pub struct WithFetch<T> {
marker: PhantomData<T>,
}

/// The [`FetchState`] of [`With`].
#[doc(hidden)]
pub struct WithState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -202,11 +204,13 @@ impl<T: Component> WorldQuery for Without<T> {
}

/// The [`Fetch`] of [`Without`].
#[doc(hidden)]
pub struct WithoutFetch<T> {
marker: PhantomData<T>,
}

/// The [`FetchState`] of [`Without`].
#[doc(hidden)]
pub struct WithoutState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -325,6 +329,7 @@ unsafe impl<T> ReadOnlyFetch for WithoutFetch<T> {}
pub struct Or<T>(pub T);

/// The [`Fetch`] of [`Or`].
#[doc(hidden)]
pub struct OrFetch<T: FilterFetch> {
fetch: T,
matches: bool,
Expand Down Expand Up @@ -458,6 +463,7 @@ macro_rules! impl_tick_filter {
$(#[$meta])*
pub struct $name<T>(PhantomData<T>);

#[doc(hidden)]
$(#[$fetch_meta])*
pub struct $fetch_name<T> {
table_ticks: *const UnsafeCell<ComponentTicks>,
Expand All @@ -469,6 +475,7 @@ macro_rules! impl_tick_filter {
change_tick: u32,
}

#[doc(hidden)]
$(#[$state_meta])*
pub struct $state_name<T> {
component_id: ComponentId,
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_ecs/src/system/function_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ impl<In, Out, Sys: System<In = In, Out = Out>> IntoSystem<In, Out, AlreadyWasSys
/// }
/// ```
pub struct In<In>(pub In);
#[doc(hidden)]
pub struct InputMarker;

/// The [`System`] counter part of an ordinary function.
Expand Down
21 changes: 20 additions & 1 deletion crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ pub struct QuerySet<'w, 's, T> {
change_tick: u32,
}

#[doc(hidden)]
pub struct QuerySetState<T>(T);

impl_query_set!();
Expand Down Expand Up @@ -265,6 +266,7 @@ impl<'w, T: Resource> From<ResMut<'w, T>> for Res<'w, T> {
}

/// The [`SystemParamState`] of [`Res<T>`].
#[doc(hidden)]
pub struct ResState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -332,6 +334,7 @@ impl<'w, 's, T: Resource> SystemParamFetch<'w, 's> for ResState<T> {

/// The [`SystemParamState`] of [`Option<Res<T>>`].
/// See: [`Res<T>`]
#[doc(hidden)]
pub struct OptionResState<T>(ResState<T>);

impl<'a, T: Resource> SystemParam for Option<Res<'a, T>> {
Expand Down Expand Up @@ -369,6 +372,7 @@ impl<'w, 's, T: Resource> SystemParamFetch<'w, 's> for OptionResState<T> {
}

/// The [`SystemParamState`] of [`ResMut<T>`].
#[doc(hidden)]
pub struct ResMutState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -441,6 +445,7 @@ impl<'w, 's, T: Resource> SystemParamFetch<'w, 's> for ResMutState<T> {

/// The [`SystemParamState`] of [`Option<ResMut<T>>`].
/// See: [`ResMut<T>`]
#[doc(hidden)]
pub struct OptionResMutState<T>(ResMutState<T>);

impl<'a, T: Resource> SystemParam for Option<ResMut<'a, T>> {
Expand Down Expand Up @@ -512,6 +517,7 @@ impl<'w, 's> SystemParamFetch<'w, 's> for CommandQueue {
unsafe impl ReadOnlySystemParamFetch for WorldState {}

/// The [`SystemParamState`] of [`&World`](crate::world::World).
#[doc(hidden)]
pub struct WorldState;

impl<'w, 's> SystemParam for &'w World {
Expand Down Expand Up @@ -631,6 +637,7 @@ impl<'a, T: Resource> DerefMut for Local<'a, T> {
}

/// The [`SystemParamState`] of [`Local<T>`].
#[doc(hidden)]
pub struct LocalState<T: Resource>(T);

impl<'a, T: Resource + FromWorld> SystemParam for Local<'a, T> {
Expand Down Expand Up @@ -707,6 +714,7 @@ impl<'a, T: Component> RemovedComponents<'a, T> {
unsafe impl<T: Component> ReadOnlySystemParamFetch for RemovedComponentsState<T> {}

/// The [`SystemParamState`] of [`RemovedComponents<T>`].
#[doc(hidden)]
pub struct RemovedComponentsState<T> {
component_id: ComponentId,
marker: PhantomData<T>,
Expand Down Expand Up @@ -810,6 +818,7 @@ impl<'a, T> From<NonSendMut<'a, T>> for NonSend<'a, T> {
}

/// The [`SystemParamState`] of [`NonSend<T>`].
#[doc(hidden)]
pub struct NonSendState<T> {
component_id: ComponentId,
marker: PhantomData<fn() -> T>,
Expand Down Expand Up @@ -881,6 +890,7 @@ impl<'w, 's, T: 'static> SystemParamFetch<'w, 's> for NonSendState<T> {

/// The [`SystemParamState`] of [`Option<NonSend<T>>`].
/// See: [`NonSend<T>`]
#[doc(hidden)]
pub struct OptionNonSendState<T>(NonSendState<T>);

impl<'w, T: 'static> SystemParam for Option<NonSend<'w, T>> {
Expand Down Expand Up @@ -919,6 +929,7 @@ impl<'w, 's, T: 'static> SystemParamFetch<'w, 's> for OptionNonSendState<T> {
}

/// The [`SystemParamState`] of [`NonSendMut<T>`].
#[doc(hidden)]
pub struct NonSendMutState<T> {
component_id: ComponentId,
marker: PhantomData<fn() -> T>,
Expand Down Expand Up @@ -994,6 +1005,7 @@ impl<'w, 's, T: 'static> SystemParamFetch<'w, 's> for NonSendMutState<T> {

/// The [`SystemParamState`] of [`Option<NonSendMut<T>>`].
/// See: [`NonSendMut<T>`]
#[doc(hidden)]
pub struct OptionNonSendMutState<T>(NonSendMutState<T>);

impl<'a, T: 'static> SystemParam for Option<NonSendMut<'a, T>> {
Expand Down Expand Up @@ -1038,6 +1050,7 @@ impl<'a> SystemParam for &'a Archetypes {
unsafe impl ReadOnlySystemParamFetch for ArchetypesState {}

/// The [`SystemParamState`] of [`Archetypes`].
#[doc(hidden)]
pub struct ArchetypesState;

// SAFE: no component value access
Expand Down Expand Up @@ -1069,6 +1082,7 @@ impl<'a> SystemParam for &'a Components {
unsafe impl ReadOnlySystemParamFetch for ComponentsState {}

/// The [`SystemParamState`] of [`Components`].
#[doc(hidden)]
pub struct ComponentsState;

// SAFE: no component value access
Expand Down Expand Up @@ -1100,6 +1114,7 @@ impl<'a> SystemParam for &'a Entities {
unsafe impl ReadOnlySystemParamFetch for EntitiesState {}

/// The [`SystemParamState`] of [`Entities`].
#[doc(hidden)]
pub struct EntitiesState;

// SAFE: no component value access
Expand Down Expand Up @@ -1131,6 +1146,7 @@ impl<'a> SystemParam for &'a Bundles {
unsafe impl ReadOnlySystemParamFetch for BundlesState {}

/// The [`SystemParamState`] of [`Bundles`].
#[doc(hidden)]
pub struct BundlesState;

// SAFE: no component value access
Expand All @@ -1154,6 +1170,7 @@ impl<'w, 's> SystemParamFetch<'w, 's> for BundlesState {
}
}

/// The [`SystemParamState`] of [`SystemChangeTick`].
#[derive(Debug)]
pub struct SystemChangeTick {
pub last_change_tick: u32,
Expand All @@ -1168,6 +1185,7 @@ impl SystemParam for SystemChangeTick {
}

/// The [`SystemParamState`] of [`SystemChangeTick`].
#[doc(hidden)]
pub struct SystemChangeTickState {}

unsafe impl SystemParamState for SystemChangeTickState {
Expand Down Expand Up @@ -1330,7 +1348,8 @@ impl<'w, 's, P: SystemParam> StaticSystemParam<'w, 's, P> {
}
}

/// The [`SystemParamState`] of [`SystemChangeTick`].
/// The [`SystemParamState`] of [`StaticSystemParam`].
#[doc(hidden)]
pub struct StaticSystemParamState<S, P>(S, PhantomData<fn() -> P>);

// Safe: This doesn't add any more reads, and the delegated fetch confirms it
Expand Down

0 comments on commit 86907f1

Please sign in to comment.