diff --git a/src/access.rs b/src/access.rs index ec5d40a..34930c0 100644 --- a/src/access.rs +++ b/src/access.rs @@ -102,13 +102,15 @@ impl CurrentMut<'_, S> { /// /// # Example /// -/// ```ignore +/// ``` +/// # /* /// fn spawn_new_menu(menu: NextStateRef) { /// match menu.unwrap() { /// Menu::Main => spawn_main_menu(), /// Menu::Settings => spawn_settings_menu(), /// } /// } +/// # */ /// ``` #[derive(SystemParam)] pub struct NextRef<'w, 's, S: State> { @@ -157,11 +159,13 @@ impl NextRef<'_, '_, S> { /// /// # Example /// -/// ```ignore +/// ``` +/// # /* /// fn toggle_blue(mut color: NextMut) { /// let mut color = color.unwrap_mut(); /// color.blue = !color.blue; /// } +/// # */ /// ``` #[derive(SystemParam)] pub struct NextMut<'w, 's, S: StateMut> { @@ -288,10 +292,12 @@ impl NextMut<'_, '_, S> { /// /// # Example /// -/// ```ignore +/// ``` +/// # /* /// fn same_red(color: FlushRef) -> bool { /// color.will_trans(&ColorState::when(|x, y| x.red == y.red)) /// } +/// # */ /// ``` #[derive(SystemParam)] pub struct FlushRef<'w, 's, S: State> { @@ -362,11 +368,13 @@ impl FlushRef<'_, '_, S> { /// /// # Example /// -/// ```ignore +/// ``` +/// # /* /// fn copy_red_to_green(mut color: FlushMut) { /// let (current, next) = color.unwrap_mut(); /// next.green = current.red; /// } +/// # */ /// ``` #[derive(SystemParam)] pub struct FlushMut<'w, 's, S: StateMut> { diff --git a/src/extra/bevy_state.rs b/src/extra/bevy_state.rs index f663a2b..80c64cc 100644 --- a/src/extra/bevy_state.rs +++ b/src/extra/bevy_state.rs @@ -6,7 +6,8 @@ //! //! Opt in to [`BevyStatePlugin`] for `GameState`: //! -//! ```ignore +//! ``` +//! # /* //! #[derive(State, Clone, PartialEq, Eq, Hash, Debug, Default)] //! #[state(bevy_state)] //! enum GameState { @@ -15,30 +16,37 @@ //! Loading, //! Playing, //! } +//! # */ //! ``` //! //! Add `GameState` along with its [`BevyState`] wrapper: //! -//! ```ignore +//! ``` +//! # /* //! app.init_state::(); +//! # */ //! ``` //! //! Change `GameState` to drive `BevyState`: //! -//! ```ignore +//! ``` +//! # /* //! app.add_systems(Update, GameState::Title.on_update( //! GameState::Loading.enter().run_if(input_just_pressed(KeyCode::Enter)), //! )); +//! # */ //! ``` //! //! Change `BevyState` to drive `GameState` (e.g. using //! [iyes_progress](https://github.com/IyesGames/iyes_progress)): //! -//! ```ignore +//! ``` +//! # /* //! app.add_plugins( //! ProgressPlugin::new(GameState::Loading.bevy()) //! .continue_to(GameState::Playing.bevy()), //! ); +//! # */ //! ``` #[cfg(feature = "bevy_app")] diff --git a/src/extra/split.rs b/src/extra/split.rs index 4b7b6cc..b8e5f30 100644 --- a/src/extra/split.rs +++ b/src/extra/split.rs @@ -15,9 +15,11 @@ /// /// Define your own split state type as a newtype: /// -/// ```ignore +/// ``` +/// # /* /// #[derive(State, Clone, PartialEq, Eq)] /// pub struct MyState(pub SplitState); +/// # */ /// ``` pub type SplitState = &'static str; @@ -25,9 +27,11 @@ pub type SplitState = &'static str; /// /// # Example /// -/// ```ignore +/// ``` +/// # /* /// add_to_split_state!(MyState, Foo, Bar); /// add_to_split_state!(MyState, Quux); +/// # */ /// ``` #[macro_export] macro_rules! add_to_split_state { diff --git a/src/lib.rs b/src/lib.rs index ca1e7f8..5c654dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,30 +27,37 @@ //! Define your own [`State`](state::State) type using the //! [derive macro](pyri_state_derive::State): //! -//! ```ignore +//! ``` +//! # /* //! #[derive(State, Clone, PartialEq, Eq, Default)] //! struct Level(pub usize); +//! # */ //! ``` //! //! Add [`StatePlugin`](setup::StatePlugin) and initialize your state type: //! -//! ```ignore +//! ``` +//! # /* //! app.add_plugins(StatePlugin).init_state::(); +//! # */ //! ``` //! //! Add update systems with [`StatePattern::on_update`](pattern::StatePattern::on_update): //! -//! ```ignore +//! ``` +//! # /* //! app.add_systems(Update, ( //! Level::ANY.on_update(update_level_timer), //! Level(10).on_update(update_boss_health_bar), //! state!(Level(4..=6)).on_update(spawn_enemy_waves), //! )); +//! # */ //! ``` //! //! Add flush hooks with other [`StatePattern`](pattern::StatePattern) methods: //! -//! ```ignore +//! ``` +//! # /* //! app.add_systems(StateFlush, ( //! // Short-hand for `on_exit` followed by `on_enter`. //! Level::ANY.on_edge(despawn_old_level, spawn_new_level), @@ -58,6 +65,7 @@ //! state!(Level(4 | 7 | 10)).on_enter(save_checkpoint), //! Level::with(|x| x.0 < 4).on_enter(spawn_tutorial_popup), //! )); +//! # */ //! ``` // Allow macros to refer to this crate as `pyri_state` internally. @@ -131,22 +139,27 @@ pub mod prelude { /// /// The derive macro requires `Clone`, `PartialEq`, and `Eq`: /// - /// ```ignore + /// ``` + /// # /* /// #[derive(State, Clone, PartialEq, Eq)] /// enum GameState { ... } + /// # */ /// ``` /// /// They can be omitted if you disable the default options: /// - /// ```ignore + /// ``` + /// # /* /// #[derive(State)] /// #[state(no_defaults)] /// struct RawState; + /// # */ /// ``` /// /// The following options are provided: /// - /// ```ignore + /// ``` + /// # /* /// #[derive(State, Clone, PartialEq, Eq, Hash, Debug)] /// #[state( /// // Disable default plugins: detect_change, flush_event, apply_flush. @@ -173,6 +186,7 @@ pub mod prelude { /// before(RawState), /// )] /// struct ConfiguredState; + /// # */ /// ``` pub use pyri_state_derive::State; } diff --git a/src/next_state.rs b/src/next_state.rs index 107c196..da510f4 100644 --- a/src/next_state.rs +++ b/src/next_state.rs @@ -55,10 +55,12 @@ impl Default for TriggerStateFlush { /// The default `NextState` type is [`NextStateBuffer`](buffer::NextStateBuffer). /// You can set a different `NextState` type in the [derive macro](pyri_state_derive::State): /// -/// ```ignore +/// ``` +/// # /* /// #[derive(State, Clone, PartialEq, Eq)] /// #[state(next(NextStateStack))] /// enum MenuState { ... } +/// # */ /// ``` pub trait NextState: Resource { /// The stored [`State`] type. diff --git a/src/pattern.rs b/src/pattern.rs index a79409d..d051d71 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -135,8 +135,10 @@ impl StatePattern for S { /// /// The usual way to use `AnyStatePattern` is through the associated constant [`State::ANY`]: /// -/// ```ignore +/// ``` +/// # /* /// Level::ANY.on_enter(reset_timer) +/// # */ /// ``` pub struct AnyStatePattern(pub(crate) PhantomData); @@ -159,9 +161,11 @@ impl StatePattern for AnyStatePattern { /// The usual way to construct this type is with the [`state!`](crate::state!) macro or /// [`State::with`]: /// -/// ```ignore +/// ``` +/// # /* /// state!(Level(4 | 7 | 10)).on_enter(save_checkpoint) /// Level::with(|x| x.0 < 4).on_refresh(my_systems) +/// # */ /// ``` #[derive(Clone)] pub struct FnStatePattern(F, PhantomData) @@ -257,11 +261,13 @@ impl, P2: StatePattern> StateTransPattern fo /// /// The usual way to use this type is through the associated constant [`State::ANY_TO_ANY`]: /// -/// ```ignore +/// ``` +/// # /* /// Level::ANY_TO_ANY.on_trans(reset_timer) /// /// // Equivalent to: /// (Level::ANY, Level::ANY).on_trans(reset_timer) +/// # */ /// ``` /// #[derive(Clone)] @@ -279,9 +285,11 @@ impl StateTransPattern for AnyStateTransPattern { /// The usual way to construct this type is with the [`state!`](crate::state!) macro or /// [`State::when`]: /// -/// ```ignore +/// ``` +/// # /* /// state!(Level(2..=5 | 7) => Level(8 | 10)).on_enter(spawn_something_cool) /// Level::when(|x, y| y.0 > x.0).on_enter(play_next_level_sfx) +/// # */ /// ``` #[derive(Clone)] pub struct FnStateTransPattern(F, PhantomData) @@ -313,14 +321,18 @@ where /// /// State pattern-matching: /// -/// ```ignore +/// ``` +/// # /* /// state!(Level(4 | 7 | 10)).on_enter(save_checkpoint) +/// # */ /// ``` /// /// State transition pattern-matching: /// -/// ```ignore +/// ``` +/// # /* /// state!(Level(x @ 1..=3) => y if y.0 == 10 - x).on_trans(do_something_cool) +/// # */ /// ``` #[macro_export] macro_rules! state { diff --git a/src/state.rs b/src/state.rs index d634a14..141c8af 100644 --- a/src/state.rs +++ b/src/state.rs @@ -17,7 +17,8 @@ use crate::{ /// /// This trait can be [derived](pyri_state_derive::State) or implemented manually: /// -/// ```ignore +/// ``` +/// # /* /// #[derive(State, Clone, PartialEq, Eq)] /// enum GameState { ... } /// @@ -26,6 +27,7 @@ use crate::{ /// impl State for MenuState { /// type Next = NextStateBuffer; /// } +/// # */ /// ``` /// /// The derive macro would also implement