From b0b789fad2d0ff6e8143f0171889835aaebe5cb1 Mon Sep 17 00:00:00 2001
From: sam edelsten <samedelsten1@gmail.com>
Date: Tue, 30 Apr 2024 13:00:09 +0100
Subject: [PATCH] fix docs links

---
 src/buffer.rs      |  22 +++++-----
 src/cosmic_edit.rs | 100 ++++++++++++++++++++-------------------------
 src/events.rs      |   2 +-
 3 files changed, 56 insertions(+), 68 deletions(-)

diff --git a/src/buffer.rs b/src/buffer.rs
index e38326d..782c0ff 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -1,7 +1,7 @@
 use crate::*;
 use bevy::{prelude::*, window::PrimaryWindow};
 
-/// Set of all buffer setup functions. Runs in `First`
+/// Set of all buffer setup functions. Runs in [`First`]
 #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
 pub struct BufferSet;
 
@@ -36,7 +36,7 @@ impl BufferExtras for Buffer {
     ///
     /// # Returns
     ///
-    /// A `String` containing the cosmic text content.
+    /// A [`String`] containing the cosmic text content.
     fn get_text(&self) -> String {
         let mut text = String::new();
         let line_count = self.lines.len();
@@ -69,7 +69,7 @@ impl<'s, 'r> CosmicBuffer {
     }
 
     // Das a lotta boilerplate just to hide the shaping argument
-    /// Add text to a newly created `CosmicBuffer`
+    /// Add text to a newly created [`CosmicBuffer`]
     pub fn with_text(
         mut self,
         font_system: &mut FontSystem,
@@ -80,9 +80,9 @@ impl<'s, 'r> CosmicBuffer {
         self
     }
 
-    /// Add rich text to a newly created `CosmicBuffer`
+    /// Add rich text to a newly created [`CosmicBuffer`]
     ///
-    /// Rich text is an iterable of `(&'s str, Attrs<'r>)
+    /// Rich text is an iterable of `(&'s str, Attrs<'r>)`
     pub fn with_rich_text<I>(
         mut self,
         font_system: &mut FontSystem,
@@ -111,7 +111,7 @@ impl<'s, 'r> CosmicBuffer {
 
     /// Replace buffer text with rich text
     ///
-    /// Rich text is an iterable of `(&'s str, Attrs<'r>)
+    /// Rich text is an iterable of `(&'s str, Attrs<'r>)`
     pub fn set_rich_text<I>(
         &mut self,
         font_system: &mut FontSystem,
@@ -168,7 +168,7 @@ impl<'s, 'r> CosmicBuffer {
     }
 }
 
-/// Adds a `FontSystem` to a newly created `CosmicBuffer` if one was not provided
+/// Adds a [`FontSystem`] to a newly created [`CosmicBuffer`] if one was not provided
 pub fn add_font_system(
     mut font_system: ResMut<CosmicFontSystem>,
     mut q: Query<&mut CosmicBuffer, Added<CosmicBuffer>>,
@@ -182,7 +182,7 @@ pub fn add_font_system(
     }
 }
 
-/// Initialises `CosmicBuffer` scale factor
+/// Initialises [`CosmicBuffer`] scale factor
 pub fn set_initial_scale(
     window_q: Query<&Window, With<PrimaryWindow>>,
     mut cosmic_query: Query<&mut CosmicBuffer, Added<CosmicBuffer>>,
@@ -196,21 +196,21 @@ pub fn set_initial_scale(
     }
 }
 
-/// Initialises new `CosmicBuffer` redraw flag to true
+/// Initialises new [`CosmicBuffer`] redraw flag to true
 pub fn set_redraw(mut q: Query<&mut CosmicBuffer, Added<CosmicBuffer>>) {
     for mut b in q.iter_mut() {
         b.set_redraw(true);
     }
 }
 
-/// Initialises new `CosmicEditor` redraw flag to true
+/// Initialises new [`CosmicEditor`] redraw flag to true
 pub fn set_editor_redraw(mut q: Query<&mut CosmicEditor, Added<CosmicEditor>>) {
     for mut b in q.iter_mut() {
         b.set_redraw(true);
     }
 }
 
-/// Sets image of UI elements to the `CosmicBuffer` output
+/// Sets image of UI elements to the [`CosmicBuffer`] output
 pub fn swap_target_handle(
     source_q: Query<&Handle<Image>, With<CosmicBuffer>>,
     mut dest_q: Query<
diff --git a/src/cosmic_edit.rs b/src/cosmic_edit.rs
index 4a33692..3ac21ed 100644
--- a/src/cosmic_edit.rs
+++ b/src/cosmic_edit.rs
@@ -1,7 +1,7 @@
 use crate::*;
 use bevy::prelude::*;
 
-/// Enum representing text wrapping in a cosmic `Buffer`
+/// Enum representing text wrapping in a cosmic [`Buffer`]
 #[derive(Clone, Component, PartialEq, Default)]
 pub enum CosmicWrap {
     InfiniteLine,
@@ -9,7 +9,7 @@ pub enum CosmicWrap {
     Wrap,
 }
 
-/// Enum representing the text alignment in a cosmic `Buffer`
+/// Enum representing the text alignment in a cosmic [`Buffer`]
 #[derive(Clone, Component)]
 pub enum CosmicTextAlign {
     Center { padding: i32 },
@@ -23,19 +23,19 @@ impl Default for CosmicTextAlign {
     }
 }
 
-/// Tag component to disable writing to a `CosmicBuffer`
+/// Tag component to disable writing to a [`CosmicBuffer`]
 // TODO: Code example
 #[derive(Component)]
 pub struct ReadOnly; // tag component
 
-/// Internal value used to decide what section of a `Buffer` to render
+/// Internal value used to decide what section of a [`Buffer`] to render
 #[derive(Component, Debug, Default)]
 pub struct XOffset {
     pub left: f32,
     pub width: f32,
 }
 
-/// Default text attributes to be used on a `CosmicBuffer`
+/// Default text attributes to be used on a [`CosmicBuffer`]
 #[derive(Component, Deref, DerefMut)]
 pub struct DefaultAttrs(pub AttrsOwned);
 
@@ -70,7 +70,7 @@ pub struct MaxLines(pub usize);
 #[derive(Component, Default)]
 pub struct MaxChars(pub usize);
 
-/// A pointer to an entity with a `CosmicEditBundle`, used to apply cosmic rendering to a UI
+/// A pointer to an entity with a [`CosmicEditBundle`], used to apply cosmic rendering to a UI
 /// element.
 ///
 ///```
@@ -78,41 +78,37 @@ pub struct MaxChars(pub usize);
 /// # use bevy_cosmic_edit::*;
 /// #
 /// # fn setup(mut commands: Commands) {
-///   // Create a new cosmic bundle
-///   let cosmic_edit = commands.spawn(CosmicEditBundle::default()).id();
+/// // Create a new cosmic bundle
+/// let cosmic_edit = commands.spawn(CosmicEditBundle::default()).id();
 ///
-///   // Spawn the target bundle
-///   commands
-///       .spawn(ButtonBundle {
-///           style: Style {
-///               width: Val::Percent(100.),
-///               height: Val::Percent(100.),
-///               ..default()
-///           },
-///           background_color: BackgroundColor(Color::WHITE),
-///           ..default()
-///       })
-///       // Add the source component to the target element
-///       .insert(CosmicSource(cosmic_edit));
-/// # }
-/// #
-/// # fn presetup(mut commands: Commands) {
-/// #     commands.spawn(Camera2dBundle::default());
+/// // Spawn the target bundle
+/// commands
+///     .spawn(ButtonBundle {
+///         style: Style {
+///             width: Val::Percent(100.),
+///             height: Val::Percent(100.),
+///             ..default()
+///         },
+///         background_color: BackgroundColor(Color::WHITE),
+///         ..default()
+///     })
+///     // Add the source component to the target element
+///     .insert(CosmicSource(cosmic_edit));
 /// # }
 /// #
 /// # fn main() {
 /// #     App::new()
 /// #         .add_plugins(MinimalPlugins)
 /// #         .add_plugins(CosmicEditPlugin::default())
-/// #         .add_systems(Startup, (presetup, setup));
+/// #         .add_systems(Startup, setup);
 /// # }
 #[derive(Component)]
 pub struct CosmicSource(pub Entity);
 
-/// A bundle containing all the required components for `CosmicBuffer` functionality.
+/// A bundle containing all the required components for [`CosmicBuffer`] functionality.
 ///
-/// Uses an invisible `SpriteBundle` for rendering by default, so should either be paired with another
-/// entity with a `CosmicSource` pointing to it's entity, or have the sprite set.
+/// Uses an invisible [`SpriteBundle`] for rendering by default, so should either be paired with another
+/// entity with a [`CosmicSource`] pointing to it's entity, or have the sprite set.
 ///
 /// ### UI mode
 ///
@@ -121,33 +117,29 @@ pub struct CosmicSource(pub Entity);
 /// # use bevy_cosmic_edit::*;
 /// #
 /// # fn setup(mut commands: Commands) {
-///   // Create a new cosmic bundle
-///   let cosmic_edit = commands.spawn(CosmicEditBundle::default()).id();
+/// // Create a new cosmic bundle
+/// let cosmic_edit = commands.spawn(CosmicEditBundle::default()).id();
 ///
-///   // Spawn the target bundle
-///   commands
-///       .spawn(ButtonBundle {
-///           style: Style {
-///               width: Val::Percent(100.),
-///               height: Val::Percent(100.),
-///               ..default()
-///           },
-///           background_color: BackgroundColor(Color::WHITE),
-///           ..default()
-///       })
-///       // Add the source component to the target element
-///       .insert(CosmicSource(cosmic_edit));
-/// # }
-/// #
-/// # fn presetup(mut commands: Commands) {
-/// #     commands.spawn(Camera2dBundle::default());
+/// // Spawn the target bundle
+/// commands
+///     .spawn(ButtonBundle {
+///         style: Style {
+///             width: Val::Percent(100.),
+///             height: Val::Percent(100.),
+///             ..default()
+///         },
+///         background_color: BackgroundColor(Color::WHITE),
+///         ..default()
+///     })
+///     // Add the source component to the target element
+///     .insert(CosmicSource(cosmic_edit));
 /// # }
 /// #
 /// # fn main() {
 /// #     App::new()
 /// #         .add_plugins(MinimalPlugins)
 /// #         .add_plugins(CosmicEditPlugin::default())
-/// #         .add_systems(Startup, (presetup, setup));
+/// #         .add_systems(Startup, setup);
 /// # }
 /// ```
 /// ### Sprite mode
@@ -169,15 +161,11 @@ pub struct CosmicSource(pub Entity);
 /// });
 /// # }
 /// #
-/// # fn presetup(mut commands: Commands) {
-/// #     commands.spawn(Camera2dBundle::default());
-/// # }
-/// #
 /// # fn main() {
 /// #     App::new()
 /// #         .add_plugins(MinimalPlugins)
 /// #         .add_plugins(CosmicEditPlugin::default())
-/// #         .add_systems(Startup, (presetup, setup));
+/// #         .add_systems(Startup, setup);
 /// # }
 #[derive(Bundle)]
 pub struct CosmicEditBundle {
@@ -229,11 +217,11 @@ impl Default for CosmicEditBundle {
     }
 }
 
-/// Holds the font system used internally by `cosmic_text`
+/// Holds the font system used internally by [`cosmic_text`]
 #[derive(Resource, Deref, DerefMut)]
 pub struct CosmicFontSystem(pub FontSystem);
 
-/// Wrapper component for an `Editor` with a few helpful values for cursor blinking
+/// Wrapper component for an [`Editor`] with a few helpful values for cursor blinking
 #[derive(Component, Deref, DerefMut)]
 pub struct CosmicEditor {
     #[deref]
diff --git a/src/events.rs b/src/events.rs
index 90ee52b..a2eb9d1 100644
--- a/src/events.rs
+++ b/src/events.rs
@@ -13,6 +13,6 @@ impl Plugin for EventsPlugin {
 
 /// Text change events
 /// Sent when text is changed in a cosmic buffer
-/// Contains the entity on which the text was changed, and the new text as a `String`
+/// Contains the entity on which the text was changed, and the new text as a [`String`]
 #[derive(Event, Debug)]
 pub struct CosmicTextChanged(pub (Entity, String));
-- 
GitLab