Skip to content

Commit

Permalink
docs: fixed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukexor committed May 6, 2024
1 parent e88f9da commit 284b8dc
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 25 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ folder.
### Creating Your Application

Creating a visual or interactive application using `pix-engine` requires
implementing only a single method of the [`PixEngine`][appstate] trait for your
application: [`PixEngine::on_update`][appstate::on_update] which gets executed as
implementing only a single method of the [`PixEngine`][pixengine] trait for your
application: [`PixEngine::on_update`][pixengine::on_update] which gets executed as
often as possible. Within that function you'll have access to a mutable
[`PixState`][pixstate] object which provides several methods for modifying
settings and drawing to the screen.

[`PixEngine`][appstate] provides additional methods that can be implemented to
[`PixEngine`][pixengine] provides additional methods that can be implemented to
respond to user events and handle application startup and teardown.

Here's an example application which simply draws a circle following the mouse
Expand Down Expand Up @@ -490,8 +490,8 @@ implementation and evolution of this crate:
[wasm]: https://www.rust-lang.org/what/wasm
[tetanes]: https://crates.io/crates/tetanes
[nes]: https://en.wikipedia.org/wiki/Nintendo_Entertainment_System
[appstate]: crate::prelude::PixEngine
[appstate::on_update]: crate::prelude::PixEngine::on_update
[pixengine]: crate::prelude::PixEngine
[pixengine::on_update]: crate::prelude::PixEngine::on_update
[pixstate]: crate::prelude::PixState
[serde]: https://crates.io/crates/serde
[anyhow]: https://crates.io/crates/anyhow
Expand Down
18 changes: 9 additions & 9 deletions src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Primary [`PiEngine`] trait and functions which drive your application.
//! Primary [`PixEngine`] trait and functions which drive your application.
//!
//! This is the core module of the `pix-engine` crate and is responsible for building and running
//! any application using it.
Expand Down Expand Up @@ -67,7 +67,7 @@ use std::{
///
/// Please see the [module-level documentation] for more examples.
///
/// [module-level documentation]: crate::appstate
/// [module-level documentation]: crate::engine
#[allow(unused_variables)]
pub trait PixEngine {
/// Called once upon engine start when [`Engine::run`] is called.
Expand Down Expand Up @@ -980,7 +980,7 @@ impl EngineBuilder {
}

/// Set a target frame rate to render at, controls how often
/// [`Engine::on_update`] is called.
/// [`PixEngine::on_update`] is called.
pub fn target_frame_rate(&mut self, rate: usize) -> &mut Self {
self.settings.target_frame_rate = Some(rate);
self
Expand Down Expand Up @@ -1035,12 +1035,12 @@ impl Engine {

/// Starts the `Engine` application and begins executing the frame loop on a given
/// application which must implement [`Engine`]. The only required method of which is
/// [`Engine::on_update`].
/// [`PixEngine::on_update`].
///
/// # Errors
///
/// Any error in the entire library can propagate here and terminate the program. See the
/// [error](crate::error) module for details. Also see [`Engine::on_stop`].
/// [error](crate::error) module for details. Also see [`PixEngine::on_stop`].
///
/// # Example
///
Expand All @@ -1066,11 +1066,11 @@ impl Engine {
// Handle events before on_start to initialize window
self.handle_events(app)?;

debug!("Starting with `Engine::on_start`");
debug!("Starting with `PixEngine::on_start`");
self.state.clear()?;
let on_start = app.on_start(&mut self.state);
if on_start.is_err() || self.state.should_quit() {
debug!("Quitting during startup with `Engine::on_stop`");
debug!("Quitting during startup with `PixEngine::on_stop`");
if let Err(ref err) = on_start {
error!("Error: {}", err);
}
Expand All @@ -1080,7 +1080,7 @@ impl Engine {

// on_stop loop enables on_stop to prevent application close if necessary
'on_stop: loop {
debug!("Starting `Engine::on_update` loop.");
debug!("Starting `PixEngine::on_update` loop.");
// running loop continues until an event or on_update returns false or errors
let result = 'running: loop {
let start_time = Instant::now();
Expand Down Expand Up @@ -1116,7 +1116,7 @@ impl Engine {
}
};

debug!("Quitting with `Engine::on_stop`");
debug!("Quitting with `PixEngine::on_stop`");
let on_stop = app.on_stop(&mut self.state);
if self.state.should_quit() {
info!("Quitting `Engine`...");
Expand Down
8 changes: 4 additions & 4 deletions src/gui/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl ThemeBuilder {
self
}

/// Convert `Builder` into a [Theme] instance.
/// Convert `ThemeBuilder` into a [Theme] instance.
pub fn build(&self) -> Theme {
Theme {
name: self.name.clone(),
Expand Down Expand Up @@ -583,7 +583,7 @@ impl Spacing {

/// A UI `Theme` containing font families, sizes, styles, and colors.
///
/// See the [Builder] examples for building a custom theme.
/// See the [`ThemeBuilder`] examples for building a custom theme.
///
/// # Example
///
Expand Down Expand Up @@ -628,9 +628,9 @@ impl Default for Theme {
}

impl Theme {
/// Constructs a default [Builder] which can build a `Theme` instance.
/// Constructs a default [`ThemeBuilder`] which can build a `Theme` instance.
///
/// See [Builder] for examples.
/// See [`ThemeBuilder`] for examples.
#[inline]
pub fn builder() -> ThemeBuilder {
ThemeBuilder::default()
Expand Down
2 changes: 1 addition & 1 deletion src/shape/ellipse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use serde::{Deserialize, Serialize};
///
/// Please see the [module-level documentation] for examples.
///
/// [module-level documentation]: crate::shape::ellipse
/// [module-level documentation]: mod@crate::shape::ellipse
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[repr(transparent)]
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/shape/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use std::{fmt, ops::MulAssign};
///
/// Please see the [module-level documentation] for examples.
///
/// [module-level documentation]: crate::shape::point
/// [module-level documentation]: mod@crate::shape::point
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/shape/quad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
///
/// Please see the [module-level documentation] for examples.
///
/// [module-level documentation]: crate::shape::quad
/// [module-level documentation]: mod@crate::shape::quad
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[repr(transparent)]
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/shape/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use std::ops::{Add, Sub};
///
/// Please see the [module-level documentation] for examples.
///
/// [module-level documentation]: crate::shape::rect
/// [module-level documentation]: mod@crate::shape::rect
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[repr(transparent)]
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/shape/sphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use serde::{Deserialize, Serialize};
///
/// Please see the [module-level documentation] for examples.
///
/// [module-level documentation]: crate::shape::sphere
/// [module-level documentation]: mod@crate::shape::sphere
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[repr(transparent)]
#[must_use]
Expand Down
8 changes: 6 additions & 2 deletions src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ impl PixState {
/// }
/// # }
/// ```
///
/// [`Error::InvalidTexture`]: crate::error::Error::InvalidTexture
pub fn texture<R1, R2>(&mut self, texture_id: TextureId, src: R1, dst: R2) -> PixResult<()>
where
R1: Into<Option<Rect<i32>>>,
Expand Down Expand Up @@ -176,6 +178,8 @@ impl PixState {
/// }
/// # }
/// ```
///
/// [`Error::InvalidTexture`]: crate::error::Error::InvalidTexture
pub fn texture_transformed<R1, R2, C, F>(
&mut self,
texture_id: TextureId,
Expand Down Expand Up @@ -209,7 +213,7 @@ impl PixState {
/// Constructs a `Texture` to render to. Passing `None` for [`PixelFormat`] will use
/// [`PixelFormat::default`]. The texture will be created and tied to the current window
/// target. To create a texture for a window other than the primary window, call
/// [`PixState::set_window`].
/// [`PixState::set_window_target`].
///
/// # Errors
///
Expand Down Expand Up @@ -331,7 +335,7 @@ impl PixState {

/// Set a `Texture` as the priamry target for drawing operations. Pushes current settings and UI
/// cursor to the stack, so any changes made while a texture target is set will be in effect
/// until [`PixState::reset_texture_target`] is called.
/// until [`PixState::clear_texture_target`] is called.
///
/// # Errors
///
Expand Down

0 comments on commit 284b8dc

Please sign in to comment.